public void Config() { JsLintConfiguration config = new JsLintConfiguration(); Assert.AreEqual("maxerr: 50", config.OptionsToString(), "Default has no options set."); Assert.AreEqual(String.Empty, config.GlobalsToString(), "Default has no globals set."); Assert.AreEqual(50, config.MaxErrors, "Maxerrors=99999"); Assert.AreEqual(true, config.ErrorOnUnused, "Unused default"); Assert.AreEqual(config.MaxErrors, config.GetOption <int>("maxerr"), config.MaxErrors, "Maxerrors = options(maxerr)"); config.SetOption("unused"); config.SetOption("evil"); config.SetOption("maxerr", 50); config.SetOption("immed"); Assert.AreEqual("maxerr: 50, unused: true, evil: true, immed: true", config.OptionsToString(), "Basic option setting worked."); JsLintConfiguration config2 = new JsLintConfiguration(); config2.SetOption("eqeqeq", true); config2.SetOption("maxerr", 25); config2.SetOption("immed", false); config.MergeOptions(config2); Assert.AreEqual("maxerr: 25, unused: true, evil: true, immed: false, eqeqeq: true", config.OptionsToString(), "Basic option setting worked."); }
public void TestMultipleDifferentOptions() { JsLintConfiguration config = new JsLintConfiguration(); SharpLinter lint = new SharpLinter(config); config.SetOption("eqeqeq",true); config.SetOption("plusplus",true); JsLintResult result = lint.Lint( @"function annon() { var i, number, x; for (i = 0; i == 5; i++) { number += ++i; } }" ); Assert.AreEqual(3, result.Errors.Count); config = new JsLintConfiguration(); config.SetOption("unused", false); // should fail on ++ since "plusplus=true" -- note that we are testing with JSHINT so the // behavior is opposite of JSLINT for this options JsLintResult result2 = lint.Lint( @"function annon() { var i, number; for (i = 0; i === 5; i++) { number += i; } }"); Assert.AreEqual(1, result2.Errors.Count); }
public void TestMultipleDifferentOptions() { JsLintConfiguration config = new JsLintConfiguration(); SharpLinter lint = new SharpLinter(config); config.SetOption("eqeqeq", true); config.SetOption("plusplus", true); JsLintResult result = lint.Lint( @"function annon() { var i, number, x; for (i = 0; i == 5; i++) { number += ++i; } }" ); Assert.AreEqual(3, result.Errors.Count); config = new JsLintConfiguration(); config.SetOption("unused", false); // should fail on ++ since "plusplus=true" -- note that we are testing with JSHINT so the // behavior is opposite of JSLINT for this options JsLintResult result2 = lint.Lint( @"function annon() { var i, number; for (i = 0; i === 5; i++) { number += i; } }"); Assert.AreEqual(1, result2.Errors.Count); }
public void Config() { JsLintConfiguration config = new JsLintConfiguration(); Assert.AreEqual("maxerr: 50", config.OptionsToString(), "Default has no options set."); Assert.AreEqual(String.Empty, config.GlobalsToString(), "Default has no globals set."); Assert.AreEqual(50, config.MaxErrors, "Maxerrors=99999"); Assert.AreEqual(true, config.ErrorOnUnused, "Unused default"); Assert.AreEqual(config.MaxErrors,config.GetOption<int>("maxerr") , config.MaxErrors, "Maxerrors = options(maxerr)"); config.SetOption("unused"); config.SetOption("evil"); config.SetOption("maxerr", 50); config.SetOption("immed"); Assert.AreEqual("maxerr: 50, unused: true, evil: true, immed: true", config.OptionsToString(), "Basic option setting worked."); JsLintConfiguration config2 = new JsLintConfiguration(); config2.SetOption("eqeqeq", true); config2.SetOption("maxerr", 25); config2.SetOption("immed", false); config.MergeOptions(config2); Assert.AreEqual("maxerr: 25, unused: true, evil: true, immed: false, eqeqeq: true", config.OptionsToString(), "Basic option setting worked."); }