This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit 3fd41ac496d672450a1728a55fd9ef670cd361e2 Author: Josh Tynjala <[email protected]> AuthorDate: Thu Oct 27 14:24:41 2022 -0700 linter: more tests --- .../royale/linter/rules/StrictEqualityRule.java | 1 - .../linter/rules/TestStaticConstantsRule.java | 72 +++++++++++ .../linter/rules/TestStrictEqualityRule.java | 84 +++++++++++++ .../linter/rules/TestSwitchWithoutDefaultRule.java | 59 ++++++++++ .../linter/rules/TestUnsafeNegationRule.java | 109 +++++++++++++++++ .../royale/linter/rules/TestValidTypeofRule.java | 131 +++++++++++++++++++++ .../linter/rules/TestVariablesOnTopRule.java | 84 +++++++++++++ 7 files changed, 539 insertions(+), 1 deletion(-) diff --git a/linter/src/main/java/org/apache/royale/linter/rules/StrictEqualityRule.java b/linter/src/main/java/org/apache/royale/linter/rules/StrictEqualityRule.java index 4ba214e8a..89645c0ad 100644 --- a/linter/src/main/java/org/apache/royale/linter/rules/StrictEqualityRule.java +++ b/linter/src/main/java/org/apache/royale/linter/rules/StrictEqualityRule.java @@ -29,7 +29,6 @@ import org.apache.royale.compiler.tree.as.IOperatorNode; import org.apache.royale.linter.LinterRule; import org.apache.royale.linter.TokenVisitor; import org.apache.royale.linter.problems.ILinterProblem; -import org.apache.royale.linter.rules.StrictEqualityRule.StrictEqualityLinterProblem; /** * Checks for uses of the '==' and '!='' operators instead of the stricter '===' diff --git a/linter/src/test/java/org/apache/royale/linter/rules/TestStaticConstantsRule.java b/linter/src/test/java/org/apache/royale/linter/rules/TestStaticConstantsRule.java new file mode 100644 index 000000000..ad4476360 --- /dev/null +++ b/linter/src/test/java/org/apache/royale/linter/rules/TestStaticConstantsRule.java @@ -0,0 +1,72 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.royale.linter.rules; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.linter.ASLinter; +import org.apache.royale.linter.LinterRule; +import org.apache.royale.linter.LinterSettings; +import org.junit.Test; + +public class TestStaticConstantsRule { + @Test + public void testStaticConstant() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StaticConstantsRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "class MyClass{static const HELLO:String = \"hello\";}", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testFieldConstant() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StaticConstantsRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "class MyClass{const HELLO:String = \"hello\";}", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof StaticConstantsRule.StaticConstantsLinterProblem); + } + + @Test + public void testLocalConstant() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StaticConstantsRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + // this rule tests only class members, and not locals + linter.lint("file.as", "class MyClass{function myMethod():void{const HELLO:String = \"hello\";}}", problems); + assertEquals(0, problems.size()); + } +} \ No newline at end of file diff --git a/linter/src/test/java/org/apache/royale/linter/rules/TestStrictEqualityRule.java b/linter/src/test/java/org/apache/royale/linter/rules/TestStrictEqualityRule.java new file mode 100644 index 000000000..04aacde4d --- /dev/null +++ b/linter/src/test/java/org/apache/royale/linter/rules/TestStrictEqualityRule.java @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.royale.linter.rules; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.linter.ASLinter; +import org.apache.royale.linter.LinterRule; +import org.apache.royale.linter.LinterSettings; +import org.junit.Test; + +public class TestStrictEqualityRule { + @Test + public void testStrictEquality() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "a === b", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testStrictInquality() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "a !== b", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testLooseEquality() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "a == b", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof StrictEqualityRule.StrictEqualityLinterProblem); + } + + @Test + public void testLooseInquality() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "a != b", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof StrictEqualityRule.StrictEqualityLinterProblem); + } +} \ No newline at end of file diff --git a/linter/src/test/java/org/apache/royale/linter/rules/TestSwitchWithoutDefaultRule.java b/linter/src/test/java/org/apache/royale/linter/rules/TestSwitchWithoutDefaultRule.java new file mode 100644 index 000000000..f23cf9fc7 --- /dev/null +++ b/linter/src/test/java/org/apache/royale/linter/rules/TestSwitchWithoutDefaultRule.java @@ -0,0 +1,59 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.royale.linter.rules; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.linter.ASLinter; +import org.apache.royale.linter.LinterRule; +import org.apache.royale.linter.LinterSettings; +import org.junit.Test; + +public class TestSwitchWithoutDefaultRule { + @Test + public void testSwitchWithoutDefault() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new SwitchWithoutDefaultRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "switch(a) {case 1:break;}", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof SwitchWithoutDefaultRule.SwitchWithoutDefaultLinterProblem); + } + + @Test + public void testSwitchWithDefault() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new SwitchWithoutDefaultRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "switch(a) {case 1:break;default:}", problems); + assertEquals(0, problems.size()); + } +} \ No newline at end of file diff --git a/linter/src/test/java/org/apache/royale/linter/rules/TestUnsafeNegationRule.java b/linter/src/test/java/org/apache/royale/linter/rules/TestUnsafeNegationRule.java new file mode 100644 index 000000000..960b7927a --- /dev/null +++ b/linter/src/test/java/org/apache/royale/linter/rules/TestUnsafeNegationRule.java @@ -0,0 +1,109 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.royale.linter.rules; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.linter.ASLinter; +import org.apache.royale.linter.LinterRule; +import org.apache.royale.linter.LinterSettings; +import org.junit.Test; + +public class TestUnsafeNegationRule { + @Test + public void testUnsafeNegationIn() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new UnsafeNegationRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "!a in b", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof UnsafeNegationRule.UnsafeNegationLinterProblem); + } + + @Test + public void testUnsafeNegationIs() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new UnsafeNegationRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "!a is b", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof UnsafeNegationRule.UnsafeNegationLinterProblem); + } + + @Test + public void testUnsafeNegationInstanceOf() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new UnsafeNegationRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "!a instanceof b", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof UnsafeNegationRule.UnsafeNegationLinterProblem); + } + + @Test + public void testSafeNegationIn() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "!(a in b)", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testSafeNegationIs() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "!(a is b)", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testSafeNegationInstanceOf() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new StrictEqualityRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "!(a instanceof b)", problems); + assertEquals(0, problems.size()); + } +} \ No newline at end of file diff --git a/linter/src/test/java/org/apache/royale/linter/rules/TestValidTypeofRule.java b/linter/src/test/java/org/apache/royale/linter/rules/TestValidTypeofRule.java new file mode 100644 index 000000000..c95c4527c --- /dev/null +++ b/linter/src/test/java/org/apache/royale/linter/rules/TestValidTypeofRule.java @@ -0,0 +1,131 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.royale.linter.rules; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.linter.ASLinter; +import org.apache.royale.linter.LinterRule; +import org.apache.royale.linter.LinterSettings; +import org.junit.Test; + +public class TestValidTypeofRule { + @Test + public void testInvalidTypeof() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"other\"", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof ValidTypeofRule.ValidTypeofLinterProblem); + } + + @Test + public void testValidTypeofBoolean() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"boolean\"", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testValidTypeofFunction() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"function\"", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testValidTypeofNumber() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"number\"", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testValidTypeofObject() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"object\"", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testValidTypeofString() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"string\"", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testValidTypeofXml() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"xml\"", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testValidTypeofUndefined() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new ValidTypeofRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "typeof a == \"undefined\"", problems); + assertEquals(0, problems.size()); + } +} \ No newline at end of file diff --git a/linter/src/test/java/org/apache/royale/linter/rules/TestVariablesOnTopRule.java b/linter/src/test/java/org/apache/royale/linter/rules/TestVariablesOnTopRule.java new file mode 100644 index 000000000..2227d3b33 --- /dev/null +++ b/linter/src/test/java/org/apache/royale/linter/rules/TestVariablesOnTopRule.java @@ -0,0 +1,84 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package org.apache.royale.linter.rules; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.royale.compiler.problems.ICompilerProblem; +import org.apache.royale.linter.ASLinter; +import org.apache.royale.linter.LinterRule; +import org.apache.royale.linter.LinterSettings; +import org.junit.Test; + +public class TestVariablesOnTopRule { + @Test + public void testOneVariableOnTop() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new VariablesOnTopRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "function myFunction():void{var a:String = null;while(true){}}", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testMultipleVariablesOnTop() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new VariablesOnTopRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "function myFunction():void{var a:String = null;var b:Number = 123.4;while(true){}}", problems); + assertEquals(0, problems.size()); + } + + @Test + public void testVariableNotOnTop() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new VariablesOnTopRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "function myFunction():void{while(true){}var a:String = null;}", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof VariablesOnTopRule.VariablesOnTopLinterProblem); + } + + @Test + public void testVariableOnTopAndVariableNotOnTop() { + List<LinterRule> rules = new ArrayList<LinterRule>(); + rules.add(new VariablesOnTopRule()); + LinterSettings settings = new LinterSettings(); + settings.rules = rules; + ASLinter linter = new ASLinter(settings); + List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); + linter.lint("file.as", "function myFunction():void{var a:String = null;while(true){}var b:Number = 123.4;}", problems); + assertEquals(1, problems.size()); + assertTrue(problems.get(0) instanceof VariablesOnTopRule.VariablesOnTopLinterProblem); + } +} \ No newline at end of file
