From 91ef4dee5d72c1009da64b97ad8246b014f576af Mon Sep 17 00:00:00 2001 From: AlexHaxe Date: Fri, 29 Nov 2024 21:57:16 +0100 Subject: [PATCH] moved from munit+mcover to utest+instrument --- .github/workflows/checkstyle-linux.yml | 15 +- .haxerc | 2 +- build/commonCoverage.hxml | 13 + build/commonTest.hxml | 10 +- haxe_libraries/haxeparser.hxml | 4 +- haxe_libraries/hxnodejs.hxml | 12 +- haxe_libraries/instrument.hxml | 4 + haxe_libraries/safety.hxml | 3 + haxe_libraries/utest.hxml | 4 + src/checkstyle/Main.hx | 2 +- test/TestMain.hx | 65 ++-- test/TestSuite.hx | 24 -- test/checkstyle/checks/CheckTestCase.hx | 20 +- test/checkstyle/config/ConfigParserTest.hx | 54 +-- test/checkstyle/config/ExcludeManagerTest.hx | 10 +- .../detect/DetectCodingStyleTest.hx | 350 +++++++++--------- test/import.hx | 3 +- test/misc/CheckerTest.hx | 12 +- test/misc/ThreadTest.hx | 18 +- testAndResources.hxml | 1 + testCoverage.hxml | 3 + 21 files changed, 320 insertions(+), 309 deletions(-) create mode 100644 build/commonCoverage.hxml create mode 100644 haxe_libraries/instrument.hxml create mode 100644 haxe_libraries/safety.hxml create mode 100644 haxe_libraries/utest.hxml delete mode 100644 test/TestSuite.hx create mode 100644 testCoverage.hxml diff --git a/.github/workflows/checkstyle-linux.yml b/.github/workflows/checkstyle-linux.yml index 649bef90..b618a4c6 100644 --- a/.github/workflows/checkstyle-linux.yml +++ b/.github/workflows/checkstyle-linux.yml @@ -65,22 +65,9 @@ jobs: - name: Build JSON schema run: npx haxe buildSchema.hxml - name: Run eval tests - run: npx haxe -D codecov_json testAndResources.hxml + run: npx haxe testAndResources.hxml - name: Run JVM tests run: npx haxe testJava.hxml - - name: Format and upload codeclimate coverage - if: success() && matrix.haxe-version == 'nightly' - run: | - ( \ - cd src; \ - ../cc-test-reporter format-coverage -t lcov ../lcov.info; \ - ../cc-test-reporter upload-coverage; \ - ) - # - name: Checkstyle report annotations - # if: success() - # uses: jwgmeligmeyling/checkstyle-github-action@master - # with: - # path: '**/check-style-report.xml' - name: Upload results to codecov if: success() && (matrix.haxe-version == 'nightly') run: bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" diff --git a/.haxerc b/.haxerc index 22c3a572..ef431268 100644 --- a/.haxerc +++ b/.haxerc @@ -1,4 +1,4 @@ { - "version": "4.3.4", + "version": "4.3.6", "resolveLibs": "scoped" } \ No newline at end of file diff --git a/build/commonCoverage.hxml b/build/commonCoverage.hxml new file mode 100644 index 00000000..644f9921 --- /dev/null +++ b/build/commonCoverage.hxml @@ -0,0 +1,13 @@ +-lib instrument + +-D coverage-console-summary-reporter +-D coverage-console-file-summary-reporter +-D coverage-console-package-summary-reporter +-D coverage-lcov-reporter +-D coverage-codecov-reporter + +-lib instrument +--macro instrument.Instrumentation.coverage(['checkstyle'], ['src'], []) +# --macro instrument.Instrumentation.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) + +#--macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) diff --git a/build/commonTest.hxml b/build/commonTest.hxml index 307b6281..c0be8d85 100644 --- a/build/commonTest.hxml +++ b/build/commonTest.hxml @@ -1,8 +1,12 @@ build/common.hxml -cp test --lib mcover --lib munit +-lib utest -lib test-adapter -D unittest +-D UTEST_PRINT_TESTS +# -D UTEST_FAILURE_THROW + # -debug ---macro mcover.MCover.coverage(['checkstyle'], ['src'], ['checkstyle.reporter', 'checkstyle.Main']) + +--macro CompileTime.importPackage("checkstyle.checks") +--macro CompileTime.importPackage("misc") diff --git a/haxe_libraries/haxeparser.hxml b/haxe_libraries/haxeparser.hxml index 4c888226..dab39131 100644 --- a/haxe_libraries/haxeparser.hxml +++ b/haxe_libraries/haxeparser.hxml @@ -1,4 +1,4 @@ -# @install: lix --silent download "gh://github.com/HaxeCheckstyle/haxeparser#a5fce2ecf5fb3bdfebfd7efd8b05329d456ec0d2" into haxeparser/4.3.0-rc.1/github/a5fce2ecf5fb3bdfebfd7efd8b05329d456ec0d2 +# @install: lix --silent download "gh://github.com/HaxeCheckstyle/haxeparser#49db59c303242c7e6ef1293e35ac5983f31f654d" into haxeparser/4.3.0-rc.1/github/49db59c303242c7e6ef1293e35ac5983f31f654d -lib hxparse --cp ${HAXE_LIBCACHE}/haxeparser/4.3.0-rc.1/github/a5fce2ecf5fb3bdfebfd7efd8b05329d456ec0d2/src +-cp ${HAXE_LIBCACHE}/haxeparser/4.3.0-rc.1/github/49db59c303242c7e6ef1293e35ac5983f31f654d/src -D haxeparser=4.3.0-rc.1 \ No newline at end of file diff --git a/haxe_libraries/hxnodejs.hxml b/haxe_libraries/hxnodejs.hxml index 577e96a5..b4982046 100644 --- a/haxe_libraries/hxnodejs.hxml +++ b/haxe_libraries/hxnodejs.hxml @@ -1,7 +1,7 @@ -# @install: lix --silent download "haxelib:/hxnodejs#12.1.0" into hxnodejs/12.1.0/haxelib --cp ${HAXE_LIBCACHE}/hxnodejs/12.1.0/haxelib/src +# @install: lix --silent download "haxelib:/hxnodejs#12.2.0" into hxnodejs/12.2.0/haxelib +-cp ${HAXE_LIBCACHE}/hxnodejs/12.2.0/haxelib/src -D hxnodejs=12.1.0 ---macro allowPackage('sys') -# should behave like other target defines and not be defined in macro context ---macro define('nodejs') ---macro _internal.SuppressDeprecated.run() +--macro allowPackage('sys') +# should behave like other target defines and not be defined in macro context +--macro define('nodejs') +--macro _internal.SuppressDeprecated.run() diff --git a/haxe_libraries/instrument.hxml b/haxe_libraries/instrument.hxml new file mode 100644 index 00000000..ea7cc93f --- /dev/null +++ b/haxe_libraries/instrument.hxml @@ -0,0 +1,4 @@ +# @install: lix --silent download "haxelib:/instrument#1.2.0" into instrument/1.2.0/haxelib +-lib safety +-cp ${HAXE_LIBCACHE}/instrument/1.2.0/haxelib/src +-D instrument=1.2.0 \ No newline at end of file diff --git a/haxe_libraries/safety.hxml b/haxe_libraries/safety.hxml new file mode 100644 index 00000000..973dc8b9 --- /dev/null +++ b/haxe_libraries/safety.hxml @@ -0,0 +1,3 @@ +# @install: lix --silent download "haxelib:/safety#1.1.2" into safety/1.1.2/haxelib +-cp ${HAXE_LIBCACHE}/safety/1.1.2/haxelib/src +-D safety=1.1.2 \ No newline at end of file diff --git a/haxe_libraries/utest.hxml b/haxe_libraries/utest.hxml new file mode 100644 index 00000000..02ee1cad --- /dev/null +++ b/haxe_libraries/utest.hxml @@ -0,0 +1,4 @@ +# @install: lix --silent download "gh://github.com/haxe-utest/utest#f759c0aa257aa723b3dd607cf7cb53d16194d13f" into utest/2.0.0-alpha/github/f759c0aa257aa723b3dd607cf7cb53d16194d13f +-cp ${HAXE_LIBCACHE}/utest/2.0.0-alpha/github/f759c0aa257aa723b3dd607cf7cb53d16194d13f/src +-D utest=2.0.0-alpha +--macro utest.utils.Macro.importEnvSettings() diff --git a/src/checkstyle/Main.hx b/src/checkstyle/Main.hx index ca863c2f..442aafb6 100644 --- a/src/checkstyle/Main.hx +++ b/src/checkstyle/Main.hx @@ -70,7 +70,7 @@ class Main { TEXT_PATH = path; }, @doc("Set reporter style (XSLT)") - ["-x", "--xslt"] => function(style:String) STYLE = style, + ["-x", "--xslt"] => function(style:String) STYLE = style, @doc("verbose logging") ["-v", "--verbose"] => function() checker.verbose = true, @doc("Sets the number of checker threads") diff --git a/test/TestMain.hx b/test/TestMain.hx index 0c4c38cf..26027f0e 100644 --- a/test/TestMain.hx +++ b/test/TestMain.hx @@ -1,42 +1,45 @@ -import massive.munit.TestRunner; -import mcover.coverage.MCoverage; -import mcover.coverage.munit.client.MCoverPrintClient; -#if (neko || cpp || hl) -import haxe.EntryPoint; -#end -#if codecov_json -import mcover.coverage.client.CodecovJsonPrintClient; -#else -import mcover.coverage.client.LcovPrintClient; -#end +import checkstyle.checks.CheckTestCase; +import checkstyle.config.ConfigParserTest; +import checkstyle.config.ExcludeManagerTest; +import checkstyle.detect.DetectCodingStyleTest; +import misc.CheckerTest; +import misc.ThreadTest; +import sys.io.File; +import utest.Runner; +import utest.ui.text.DiagnosticsReport; class TestMain { public function new() { - var suites:Array> = [TestSuite]; + var runner:Runner = new Runner(); - var client:MCoverPrintClient = new MCoverPrintClient(); - #if codecov_json - MCoverage.getLogger().addClient(new CodecovJsonPrintClient()); - #else - MCoverage.getLogger().addClient(new LcovPrintClient("Checkstyle Unittests")); - #end - var runner:TestRunner = new TestRunner(client); - runner.completionHandler = completionHandler; - #if (neko || cpp || hl) - EntryPoint.addThread(function() { - while (true) Sys.sleep(1.0); + var failed = false; + runner.onProgress.add(r -> { + if (!r.result.allOk()) { + failed = true; + } }); - #end - runner.run(suites); + runner.onComplete.add(_ -> { + completionHandler(!failed); + }); + + new DiagnosticsReport(runner); + + var testClasses = CompileTime.getAllClasses(CheckTestCase); + for (test in testClasses) { + runner.addCase(Type.createInstance(test, [])); + } + + runner.addCase(new CheckerTest()); + runner.addCase(new ConfigParserTest()); + runner.addCase(new DetectCodingStyleTest()); + runner.addCase(new ThreadTest()); + + runner.run(); } function completionHandler(success:Bool) { - #if eval - if (!success) { - Sys.exit(1); - } - #else - Sys.exit(success ? 0 : 1); + #if instrument + instrument.coverage.Coverage.endCoverage(); #end } diff --git a/test/TestSuite.hx b/test/TestSuite.hx deleted file mode 100644 index 28d9fb62..00000000 --- a/test/TestSuite.hx +++ /dev/null @@ -1,24 +0,0 @@ -import checkstyle.checks.CheckTestCase; -import checkstyle.config.ConfigParserTest; -import checkstyle.config.ExcludeManagerTest; -import checkstyle.detect.DetectCodingStyleTest; -import misc.CheckerTest; -import misc.ThreadTest; - -class TestSuite extends massive.munit.TestSuite { - public function new() { - super(); - - CompileTime.importPackage("checkstyle.checks"); - CompileTime.importPackage("misc"); - - add(CheckerTest); - add(ConfigParserTest); - add(ExcludeManagerTest); - add(DetectCodingStyleTest); - add(ThreadTest); - - var tests = CompileTime.getAllClasses(CheckTestCase); - for (testClass in tests) add(testClass); - } -} \ No newline at end of file diff --git a/test/checkstyle/checks/CheckTestCase.hx b/test/checkstyle/checks/CheckTestCase.hx index 0e07cd22..0c50325d 100644 --- a/test/checkstyle/checks/CheckTestCase.hx +++ b/test/checkstyle/checks/CheckTestCase.hx @@ -4,20 +4,24 @@ import byte.ByteData; import checkstyle.CheckFile; import checkstyle.Checker; import checkstyle.Message; +import checkstyle.config.ExcludeManager; import checkstyle.reporter.IReporter; import checkstyle.reporter.ReporterManager; -class CheckTestCase { +class CheckTestCase implements ITest { static inline var FILE_NAME:String = "Test.hx"; var checker:Checker; var reporter:TestReporter; + public function new() {} + @Before - public function setup() {} + public function setup() { + ExcludeManager.INSTANCE.clear(); + } - function assertMsg(check:Check, testCase:T, expected:String, ?defines:Array>, ?fileName:String, allowFailingAST:Bool = false, - ?pos:PosInfos) { + function assertMsg(check:Check, testCase:T, expected:String, ?defines:Array>, ?fileName:String, allowFailingAST:Bool = false, ?pos:PosInfos) { assertMessages(check, testCase, [expected], defines, fileName, allowFailingAST, pos); } @@ -40,12 +44,12 @@ class CheckTestCase { var messages:Array = checkMessages(testCase, check, defines, fileName, allowFailingAST, pos); if ((expected.length == 1) && (expected.length != messages.length)) { for (i in 0...messages.length) { - Assert.areEqual(expected[0], messages[i].message, pos); + Assert.equals(expected[0], messages[i]?.message, pos); } } - Assert.areEqual(expected.length, messages.length, pos); + Assert.equals(expected.length, messages.length, pos); for (i in 0...expected.length) { - Assert.areEqual(expected[i], messages[i].message, pos); + Assert.equals(expected[i], messages[i]?.message, pos); } } @@ -66,7 +70,7 @@ class CheckTestCase { } @After - public function tearDown() { + public function teardown() { checker = null; reporter = null; } diff --git a/test/checkstyle/config/ConfigParserTest.hx b/test/checkstyle/config/ConfigParserTest.hx index c3a0c7ed..383a7d2d 100644 --- a/test/checkstyle/config/ConfigParserTest.hx +++ b/test/checkstyle/config/ConfigParserTest.hx @@ -2,20 +2,22 @@ package checkstyle.config; import checkstyle.utils.ConfigUtils; -class ConfigParserTest { +class ConfigParserTest implements ITest { static inline var LOCAL_PATH:String = "./"; static inline var TEST_COUNT:Int = 81; + public function new() {} + @Test public function testCheckstyleConfig() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.loadConfig("checkstyle.json"); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length > 0); Assert.isTrue(configParser.checker.checks.length != configParser.getCheckCount()); } @@ -24,14 +26,14 @@ class ConfigParserTest { public function testExtendsConfigPath() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseAndValidateConfig({ extendsConfigPath: "checkstyle.json" }, LOCAL_PATH); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length > 0); } @@ -39,35 +41,35 @@ class ConfigParserTest { public function testValidateParserThread() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); configParser.parseAndValidateConfig({numberOfCheckerThreads: 0}, ""); - Assert.areEqual(5, configParser.numberOfCheckerThreads); + Assert.equals(5, configParser.numberOfCheckerThreads); configParser.parseAndValidateConfig({numberOfCheckerThreads: 10}, ""); - Assert.areEqual(10, configParser.numberOfCheckerThreads); + Assert.equals(10, configParser.numberOfCheckerThreads); configParser.parseAndValidateConfig({numberOfCheckerThreads: 50}, ""); - Assert.areEqual(15, configParser.numberOfCheckerThreads); + Assert.equals(15, configParser.numberOfCheckerThreads); configParser.overrideCheckerThreads = 13; configParser.parseAndValidateConfig({numberOfCheckerThreads: 14}, ""); - Assert.areEqual(13, configParser.numberOfCheckerThreads); + Assert.equals(13, configParser.numberOfCheckerThreads); configParser.overrideCheckerThreads = 18; configParser.parseAndValidateConfig({numberOfCheckerThreads: 14}, ""); - Assert.areEqual(15, configParser.numberOfCheckerThreads); + Assert.equals(15, configParser.numberOfCheckerThreads); } @Test public function testCheckCount() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.areEqual(TEST_COUNT, configParser.getCheckCount()); + Assert.equals(TEST_COUNT, configParser.getCheckCount()); } @Test public function testUnusedChecks() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.areEqual(0, configParser.getUsedCheckCount()); + Assert.equals(0, configParser.getUsedCheckCount()); configParser.addAllChecks(); - Assert.areEqual(TEST_COUNT, configParser.getUsedCheckCount()); + Assert.equals(TEST_COUNT, configParser.getUsedCheckCount()); } @Test @@ -80,22 +82,22 @@ class ConfigParserTest { configParser = new ConfigParser(reportConfigParserFailure); configParser.parseAndValidateConfig(config, ""); - Assert.areEqual(configParser.getCheckCount(), configParser.getUsedCheckCount()); - Assert.areEqual(11, configParser.numberOfCheckerThreads); + Assert.equals(configParser.getCheckCount(), configParser.getUsedCheckCount()); + Assert.equals(11, configParser.numberOfCheckerThreads); } @Test public function testConfigVersion1() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseAndValidateConfig({ version: 1 }, LOCAL_PATH); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); } @@ -106,23 +108,23 @@ class ConfigParserTest { failMessage = message; }); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseAndValidateConfig({ version: 0 }, LOCAL_PATH); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); - Assert.areEqual("configuration file has unknown version: 0", failMessage); + Assert.equals("configuration file has unknown version: 0", failMessage); } @Test public function testExcludeConfigVersion1() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseExcludes({ @@ -137,14 +139,14 @@ class ConfigParserTest { failMessage = message; }); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseExcludes({ version: 0 }); - Assert.areEqual("exclude configuration file has unknown version: 0", failMessage); + Assert.equals("exclude configuration file has unknown version: 0", failMessage); } @Test @@ -155,7 +157,7 @@ class ConfigParserTest { }); configParser.validateMode = RELAXED; - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); var config:Config = { @@ -171,11 +173,11 @@ class ConfigParserTest { }; configParser.parseAndValidateConfig(config, LOCAL_PATH); - Assert.areEqual("", failMessage); + Assert.equals("", failMessage); configParser.validateMode = STRICT; configParser.parseAndValidateConfig(config, LOCAL_PATH); - Assert.areEqual("Check Trace has no property named 'non_existing_property'", failMessage); + Assert.equals("Check Trace has no property named 'non_existing_property'", failMessage); } function reportConfigParserFailure(message:String) { diff --git a/test/checkstyle/config/ExcludeManagerTest.hx b/test/checkstyle/config/ExcludeManagerTest.hx index cdcb3154..b2039b88 100644 --- a/test/checkstyle/config/ExcludeManagerTest.hx +++ b/test/checkstyle/config/ExcludeManagerTest.hx @@ -21,7 +21,7 @@ class ExcludeManagerTest extends CheckTestCase { public function testExcludeAllConfig() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseExcludes({ @@ -39,7 +39,7 @@ class ExcludeManagerTest extends CheckTestCase { public function testExcludeAllConfig2() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.paths = ["src", "test"]; @@ -59,7 +59,7 @@ class ExcludeManagerTest extends CheckTestCase { public function testExcludeConfigDynamic() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseExcludes(cast { @@ -80,7 +80,7 @@ class ExcludeManagerTest extends CheckTestCase { public function testExcludeConfigDynamicRange() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseExcludes(cast { @@ -101,7 +101,7 @@ class ExcludeManagerTest extends CheckTestCase { public function testExcludeConfigAllRange() { var configParser:ConfigParser = new ConfigParser(reportConfigParserFailure); - Assert.isNotNull(configParser.checker.checks); + Assert.notNull(configParser.checker.checks); Assert.isTrue(configParser.checker.checks.length == 0); configParser.parseExcludes(cast { diff --git a/test/checkstyle/detect/DetectCodingStyleTest.hx b/test/checkstyle/detect/DetectCodingStyleTest.hx index 3c9f0a9a..f5c812d2 100644 --- a/test/checkstyle/detect/DetectCodingStyleTest.hx +++ b/test/checkstyle/detect/DetectCodingStyleTest.hx @@ -61,80 +61,82 @@ import checkstyle.checks.whitespace.WhitespaceCheckBase.WhitespacePolicy; import checkstyle.checks.whitespace.WrapCheckBase.WrapCheckBaseOption; import checkstyle.config.CheckConfig; -class DetectCodingStyleTest { +class DetectCodingStyleTest implements ITest { + public function new() {} + // checkstyle.checks.block @Test public function testBlockBreakingConditional() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new BlockBreakingConditionalCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("BlockBreakingConditional", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("BlockBreakingConditional", detectedChecks[0].type); } @Test public function testDetectConditionalCompilation() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ConditionalCompilationCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ConditionalCompilation", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ConditionalCompilation", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("aligned", props.policy); + Assert.equals("aligned", props.policy); Assert.isTrue(props.allowSingleline); } @Test public function testDetectLeftCurly() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new LeftCurlyCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(2, detectedChecks.length); - Assert.areEqual("LeftCurly", detectedChecks[0].type); + Assert.equals(2, detectedChecks.length); + Assert.equals("LeftCurly", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("eol", props.option); + Assert.equals("eol", props.option); Assert.isTrue(props.ignoreEmptySingleline); - Assert.areEqual("LeftCurly", detectedChecks[1].type); + Assert.equals("LeftCurly", detectedChecks[1].type); props = cast detectedChecks[1].props; - Assert.areEqual("nl", props.option); + Assert.equals("nl", props.option); Assert.isTrue(props.ignoreEmptySingleline); } @Test public function testDetectRightCurly() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new RightCurlyCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(2, detectedChecks.length); - Assert.areEqual("RightCurly", detectedChecks[0].type); + Assert.equals(2, detectedChecks.length); + Assert.equals("RightCurly", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("aloneorsingle", props.option); - Assert.areEqual("RightCurly", detectedChecks[1].type); + Assert.equals("aloneorsingle", props.option); + Assert.equals("RightCurly", detectedChecks[1].type); var props = cast detectedChecks[1].props; - Assert.areEqual("same", props.option); + Assert.equals("same", props.option); } // checkstyle.checks.coding @Test public function testDetectArrowFunction() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ArrowFunctionCheck()], [buildCheckFile(SAMPLE_CODING_STYLE_HAXE_4)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ArrowFunction", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ArrowFunction", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(true, props.allowReturn); - Assert.areEqual(true, props.allowFunction); - Assert.areEqual(true, props.allowCurlyBody); - Assert.areEqual(true, props.allowSingleArgParens); + Assert.equals(true, props.allowReturn); + Assert.equals(true, props.allowFunction); + Assert.equals(true, props.allowCurlyBody); + Assert.equals(true, props.allowSingleArgParens); } @Test public function testDetectCodeSimilarity() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new CodeSimilarityCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("CodeSimilarity", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("CodeSimilarity", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(60, props.thresholdIdentical); - Assert.areEqual(120, props.thresholdSimilar); + Assert.equals(60, props.thresholdIdentical); + Assert.equals(120, props.thresholdSimilar); } @Test public function testDetectHiddenField() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new HiddenFieldCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("HiddenField", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("HiddenField", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.ignoreSetter); Assert.isTrue(props.ignoreConstructorParameter); @@ -144,134 +146,134 @@ class DetectCodingStyleTest { public function testDetectInnerAssignment() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new InnerAssignmentCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); // ignored not enough data points - Assert.areEqual(0, detectedChecks.length); + Assert.equals(0, detectedChecks.length); } @Test public function testDetectNestedControlFlowC() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new NestedControlFlowCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("NestedControlFlow", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("NestedControlFlow", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(3, props.max); + Assert.equals(3, props.max); } @Test public function testDetectNestedForDepth() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new NestedForDepthCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("NestedForDepth", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("NestedForDepth", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(2, props.max); + Assert.equals(2, props.max); } @Test public function testDetectNestedIfDepth() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new NestedIfDepthCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("NestedIfDepth", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("NestedIfDepth", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(2, props.max); + Assert.equals(2, props.max); } @Test public function testDetectNestedTryDepth() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new NestedTryDepthCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("NestedTryDepth", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("NestedTryDepth", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(2, props.max); + Assert.equals(2, props.max); } @Test public function testDetectNullableParameter() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new NullableParameterCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("NullableParameter", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("NullableParameter", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("questionMark", props.option); + Assert.equals("questionMark", props.option); } @Test public function testDetectReturnCount() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ReturnCountCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ReturnCount", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ReturnCount", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(10, props.max); + Assert.equals(10, props.max); } @Test public function testDetectTrace() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new TraceCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Trace", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Trace", detectedChecks[0].type); } @Test public function testDetectUnusedLocalVar() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new UnusedLocalVarCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("UnusedLocalVar", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("UnusedLocalVar", detectedChecks[0].type); } // checkstyle.checks.comments @Test public function testCommentedOutCode() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new CommentedOutCodeCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("CommentedOutCode", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("CommentedOutCode", detectedChecks[0].type); } @Test public function testDetectDocCommentStyle() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new DocCommentStyleCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("DocCommentStyle", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("DocCommentStyle", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("twostars", props.startStyle); - Assert.areEqual("none", props.lineStyle); + Assert.equals("twostars", props.startStyle); + Assert.equals("none", props.lineStyle); } @Test public function testDetectFieldDocComment() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new FieldDocCommentCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("FieldDocComment", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("FieldDocComment", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.isNotNull(props.tokens); - Assert.areEqual(5, props.tokens.length); + Assert.notNull(props.tokens); + Assert.equals(5, untyped props.tokens.length); Assert.isFalse(props.requireParams); Assert.isFalse(props.requireReturn); - Assert.isNotNull(props.excludeNames); - Assert.areEqual(2, props.excludeNames.length); - Assert.areEqual(FUNCTIONS, props.fieldType); - Assert.areEqual(PUBLIC, props.modifier); + Assert.notNull(props.excludeNames); + Assert.equals(2, untyped props.excludeNames.length); + Assert.equals(FUNCTIONS, props.fieldType); + Assert.equals(PUBLIC, props.modifier); } @Test public function testDetectTODOComment() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new TODOCommentCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("TODOComment", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("TODOComment", detectedChecks[0].type); } @Test public function testDetectTypeDocComment() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new TypeDocCommentCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("TypeDocComment", detectedChecks[0].type); - var props = cast detectedChecks[0].props; - Assert.isNotNull(props.tokens); - Assert.areEqual(5, props.tokens.length); + Assert.equals(1, detectedChecks.length); + Assert.equals("TypeDocComment", detectedChecks[0].type); + var props = detectedChecks[0].props; + Assert.notNull(untyped props.tokens); + Assert.equals(5, untyped props.tokens.length); } // checkstyle.checks.design @Test public function testDetectEmptyPackage() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new EmptyPackageCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("EmptyPackage", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("EmptyPackage", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isTrue(props.enforceEmptyPackage); } @@ -279,8 +281,8 @@ class DetectCodingStyleTest { @Test public function testDetectInterface() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new InterfaceCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Interface", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Interface", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.allowProperties); Assert.isTrue(props.allowMarkerInterfaces); @@ -289,33 +291,33 @@ class DetectCodingStyleTest { @Test public function testDetectUnnecessaryConstructor() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new UnnecessaryConstructorCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("UnnecessaryConstructor", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("UnnecessaryConstructor", detectedChecks[0].type); } // checkstyle.checks.imports @Test public function testDetectAvoidStarImport() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new AvoidStarImportCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("AvoidStarImport", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("AvoidStarImport", detectedChecks[0].type); } @Test public function testDetectUnusedImport() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new UnusedImportCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("UnusedImport", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("UnusedImport", detectedChecks[0].type); } // checkstyle.checks.literal @Test public function testDetectStringLiteral() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new StringLiteralCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("StringLiteral", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("StringLiteral", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("onlySingle", props.policy); + Assert.equals("onlySingle", props.policy); Assert.isTrue(props.allowException); } @@ -323,8 +325,8 @@ class DetectCodingStyleTest { @Test public function testDetectRedundantAccessMeta() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new RedundantAccessMetaCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("RedundantAccessMeta", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("RedundantAccessMeta", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.prohibitMeta); } @@ -332,8 +334,8 @@ class DetectCodingStyleTest { @Test public function testDetectRedundantAllowMeta() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new RedundantAllowMetaCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("RedundantAllowMeta", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("RedundantAllowMeta", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.prohibitMeta); } @@ -342,28 +344,28 @@ class DetectCodingStyleTest { @Test public function testDetectCyclomaticComplexity() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new CyclomaticComplexityCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("CyclomaticComplexity", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("CyclomaticComplexity", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(11, props.thresholds[0].complexity); - Assert.areEqual(SeverityLevel.WARNING, props.thresholds[0].severity); - Assert.areEqual(21, props.thresholds[1].complexity); - Assert.areEqual(SeverityLevel.ERROR, props.thresholds[1].severity); + Assert.equals(11, props.thresholds[0].complexity); + Assert.equals(SeverityLevel.WARNING, props.thresholds[0].severity); + Assert.equals(21, props.thresholds[1].complexity); + Assert.equals(SeverityLevel.ERROR, props.thresholds[1].severity); } // checkstyle.checks.modifier @Test public function testDetectInlineFinal() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new FinalCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Final", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Final", detectedChecks[0].type); } @Test public function testDetectRedundantModifier() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new RedundantModifierCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("RedundantModifier", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("RedundantModifier", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.enforcePublicPrivate); Assert.isTrue(props.enforcePublic); @@ -374,17 +376,17 @@ class DetectCodingStyleTest { @Test public function testDetectConstantName() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ConstantNameCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ConstantName", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ConstantName", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("^[A-Z][A-Z0-9]*(_[A-Z0-9_]+)*$", props.format); + Assert.equals("^[A-Z][A-Z0-9]*(_[A-Z0-9_]+)*$", props.format); } @Test public function testDetectFileNameCase() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new FileNameCaseCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("FileNameCase", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("FileNameCase", detectedChecks[0].type); } // checkstyle.checks.size @@ -392,42 +394,42 @@ class DetectCodingStyleTest { public function testDetectFileLength() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new FileLengthCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); // ignored not enough data points - Assert.areEqual(0, detectedChecks.length); + Assert.equals(0, detectedChecks.length); } @Test public function testDetectLineLength() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new LineLengthCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("LineLength", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("LineLength", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(100, props.max); + Assert.equals(100, props.max); } @Test public function testDetectMethodCount() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new MethodCountCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); // ignored not enough data points - Assert.areEqual(0, detectedChecks.length); + Assert.equals(0, detectedChecks.length); } @Test public function testDetectMethodLength() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new MethodLengthCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("MethodLength", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("MethodLength", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(35, props.max); + Assert.equals(35, props.max); Assert.isFalse(props.ignoreEmptyLines); } @Test public function testDetectParameterNumber() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ParameterNumberCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ParameterNumber", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ParameterNumber", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(6, props.max); + Assert.equals(6, props.max); Assert.isFalse(props.ignoreOverriddenMethods); } @@ -435,22 +437,22 @@ class DetectCodingStyleTest { @Test public function testDetectAnonymous() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new AnonymousCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Anonymous", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Anonymous", detectedChecks[0].type); } @Test public function testDetectDynamic() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new DynamicCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Dynamic", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Dynamic", detectedChecks[0].type); } @Test public function testDetectReturn() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ReturnCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Return", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Return", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.enforceReturnTypeForAnonymous); Assert.isTrue(props.allowEmptyReturn); @@ -460,16 +462,16 @@ class DetectCodingStyleTest { @Test public function testDetectType() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new TypeCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Type", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Type", detectedChecks[0].type); } // checkstyle.checks.whitespace @Test public function testDetectArrayAccess() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ArrayAccessCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ArrayAccess", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ArrayAccess", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isTrue(props.spaceBefore); Assert.isTrue(props.spaceInside); @@ -478,14 +480,14 @@ class DetectCodingStyleTest { @Test public function testDetectEmptyLines() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new EmptyLinesCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("EmptyLines", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("EmptyLines", detectedChecks[0].type); var props = cast detectedChecks[0].props; Assert.isFalse(props.requireEmptyLineAfterPackage); Assert.isFalse(props.requireEmptyLineAfterInterface); Assert.isFalse(props.requireEmptyLineAfterAbstract); Assert.isTrue(props.allowEmptyLineAfterSingleLineComment); - Assert.areEqual(1, props.max); + Assert.equals(1, props.max); Assert.isFalse(props.requireEmptyLineAfterClass); Assert.isTrue(props.allowEmptyLineAfterMultiLineComment); } @@ -493,105 +495,105 @@ class DetectCodingStyleTest { @Test public function testDetectExtendedEmptyLines() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new ExtendedEmptyLinesCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("ExtendedEmptyLines", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("ExtendedEmptyLines", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(1, props.max); - Assert.areEqual(true, props.skipSingleLineTypes); - Assert.areEqual(EmptyLinesPolicy.UPTO, props.defaultPolicy); + Assert.equals(1, props.max); + Assert.equals(true, props.skipSingleLineTypes); + Assert.equals(EmptyLinesPolicy.UPTO, props.defaultPolicy); } @Test public function testDetectIndentationCharacter() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new IndentationCharacterCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("IndentationCharacter", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("IndentationCharacter", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("tab", props.character); + Assert.equals("tab", props.character); } @Test public function testDetectIndentation() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new IndentationCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Indentation", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Indentation", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("tab", props.character); + Assert.equals("tab", props.character); Assert.isFalse(props.ignoreConditionals); Assert.isFalse(props.ignoreComments); - Assert.areEqual("exact", props.wrapPolicy); + Assert.equals("exact", props.wrapPolicy); } @Test public function testDetectOperatorWhitespace() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new OperatorWhitespaceCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("OperatorWhitespace", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("OperatorWhitespace", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(WhitespacePolicy.IGNORE, props.ternaryOpPolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.unaryOpPolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.boolOpPolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.intervalOpPolicy); - Assert.areEqual(WhitespacePolicy.AROUND, props.assignOpPolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.oldFunctionTypePolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.newFunctionTypePolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.arrowFunctionPolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.bitwiseOpPolicy); - Assert.areEqual(WhitespacePolicy.AROUND, props.arithmeticOpPolicy); - Assert.areEqual(WhitespacePolicy.AROUND, props.compareOpPolicy); - Assert.areEqual(WhitespacePolicy.IGNORE, props.arrowPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.ternaryOpPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.unaryOpPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.boolOpPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.intervalOpPolicy); + Assert.equals(WhitespacePolicy.AROUND, props.assignOpPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.oldFunctionTypePolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.newFunctionTypePolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.arrowFunctionPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.bitwiseOpPolicy); + Assert.equals(WhitespacePolicy.AROUND, props.arithmeticOpPolicy); + Assert.equals(WhitespacePolicy.AROUND, props.compareOpPolicy); + Assert.equals(WhitespacePolicy.IGNORE, props.arrowPolicy); } @Test public function testDetectOperatorWrap() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new OperatorWrapCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("OperatorWrap", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("OperatorWrap", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(WrapCheckBaseOption.EOL, props.option); + Assert.equals(WrapCheckBaseOption.EOL, props.option); } @Test public function testDetectSeparatorWhitespace() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new SeparatorWhitespaceCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("SeparatorWhitespace", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("SeparatorWhitespace", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual("after", props.commaPolicy); - Assert.areEqual("after", props.semicolonPolicy); - Assert.areEqual("before", props.dotPolicy); + Assert.equals("after", props.commaPolicy); + Assert.equals("after", props.semicolonPolicy); + Assert.equals("before", props.dotPolicy); } @Test public function testDetectSeparatorWrap() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new SeparatorWrapCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("SeparatorWrap", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("SeparatorWrap", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(WrapCheckBaseOption.EOL, props.option); + Assert.equals(WrapCheckBaseOption.EOL, props.option); } @Test public function testDetectSpacing() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new SpacingCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("Spacing", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("Spacing", detectedChecks[0].type); var props = cast detectedChecks[0].props; - Assert.areEqual(SpacingPolicy.SHOULD, props.spaceIfCondition); + Assert.equals(SpacingPolicy.SHOULD, props.spaceIfCondition); Assert.isFalse(props.spaceAroundBinop); - Assert.areEqual(SpacingPolicy.SHOULD, props.spaceForLoop); + Assert.equals(SpacingPolicy.SHOULD, props.spaceForLoop); Assert.isFalse(props.ignoreRangeOperator); - Assert.areEqual(SpacingPolicy.SHOULD, props.spaceWhileLoop); - Assert.areEqual(SpacingPolicy.SHOULD_NOT, props.spaceCatch); - Assert.areEqual(SpacingPolicy.SHOULD, props.spaceSwitchCase); + Assert.equals(SpacingPolicy.SHOULD, props.spaceWhileLoop); + Assert.equals(SpacingPolicy.SHOULD_NOT, props.spaceCatch); + Assert.equals(SpacingPolicy.SHOULD, props.spaceSwitchCase); Assert.isFalse(props.noSpaceAroundUnop); } @Test public function testDetectTrailingWhitespace() { var detectedChecks:Array = DetectCodingStyle.detectCodingStyle([new TrailingWhitespaceCheck()], [buildCheckFile(SAMPLE_CODING_STYLE)]); - Assert.areEqual(1, detectedChecks.length); - Assert.areEqual("TrailingWhitespace", detectedChecks[0].type); + Assert.equals(1, detectedChecks.length); + Assert.equals("TrailingWhitespace", detectedChecks[0].type); } function buildCheckFile(src:String):CheckFile { diff --git a/test/import.hx b/test/import.hx index 13b351df..d5dac959 100644 --- a/test/import.hx +++ b/test/import.hx @@ -1,2 +1,3 @@ import haxe.PosInfos; -import massive.munit.Assert; \ No newline at end of file +import utest.Assert; +import utest.ITest; \ No newline at end of file diff --git a/test/misc/CheckerTest.hx b/test/misc/CheckerTest.hx index adac7fb6..e16b1b48 100644 --- a/test/misc/CheckerTest.hx +++ b/test/misc/CheckerTest.hx @@ -2,7 +2,9 @@ package misc; import checkstyle.Checker; -class CheckerTest { +class CheckerTest implements ITest { + public function new() {} + @Test public function testEmptyLinesIdx() { var checker:Checker = new Checker(); @@ -53,9 +55,9 @@ class CheckerTest { function checkLinePos(checker:Checker, ofs:Int, expectedLine:Int, expectedOfs:Int, ?pos:PosInfos) { var linePos:LinePos = checker.getLinePos(ofs); - Assert.isNotNull(linePos, pos); - Assert.areEqual(expectedLine, linePos.line, pos); - Assert.areEqual(expectedOfs, linePos.ofs, pos); + Assert.notNull(linePos, pos); + Assert.equals(expectedLine, linePos.line, pos); + Assert.equals(expectedOfs, linePos.ofs, pos); } function throwsBadOffset(checker:Checker, ofs:Int, ?pos:PosInfos) { @@ -64,7 +66,7 @@ class CheckerTest { Assert.fail("line pos calculation should fail", pos); } catch (e:Any) { - Assert.areEqual("Bad offset", '$e', pos); + Assert.equals("Bad offset", '$e', pos); } } } \ No newline at end of file diff --git a/test/misc/ThreadTest.hx b/test/misc/ThreadTest.hx index 7a38a239..4f0febf4 100644 --- a/test/misc/ThreadTest.hx +++ b/test/misc/ThreadTest.hx @@ -2,20 +2,22 @@ package misc; import byte.ByteData; import checkstyle.CheckFile; -import checkstyle.reporter.ReporterManager; import checkstyle.Checker; -import checkstyle.ParserQueue; import checkstyle.CheckerPool; +import checkstyle.ParserQueue; +import checkstyle.checks.CheckTestCase.TestReporter; import checkstyle.checks.whitespace.IndentationCheck; import checkstyle.checks.whitespace.IndentationCheckTest.IndentationCheckTests; -import checkstyle.checks.CheckTestCase.TestReporter; +import checkstyle.reporter.ReporterManager; -class ThreadTest { +class ThreadTest implements ITest { static inline var FILE_NAME:String = "Test.hx"; var checker:Checker; var reporter:TestReporter; + public function new() {} + @Before public function setup() { checker = setupChecker(); @@ -30,9 +32,9 @@ class ThreadTest { var parseQueue = new ParserQueue(files, checker); parseQueue.start(1); + Sys.sleep(1); Assert.isFalse(parseQueue.isFinished()); - Sys.sleep(1); var failCount:Int = 0; var count:Int = 0; Assert.isFalse(parseQueue.isFinished()); @@ -48,7 +50,7 @@ class ThreadTest { if (count == 13) break; } Assert.isTrue(parseQueue.isFinished()); - Assert.areEqual(13, count); + Assert.equals(13, count); Assert.isNull(parseQueue.nextFile()); } @@ -61,10 +63,10 @@ class ThreadTest { var checkerPool = new CheckerPool(parseQueue, checker); checkerPool.start(5); + Sys.sleep(1); Assert.isFalse(parseQueue.isFinished()); Assert.isFalse(checkerPool.isFinished()); - Sys.sleep(1); var failCount:Int = 0; while (true) { if (failCount > 5) Assert.fail("parsing failed"); @@ -98,7 +100,7 @@ class ThreadTest { } @After - public function tearDown() { + public function teardown() { checker = null; reporter = null; } diff --git a/testAndResources.hxml b/testAndResources.hxml index fda7ae18..5dc54ba8 100644 --- a/testAndResources.hxml +++ b/testAndResources.hxml @@ -1,4 +1,5 @@ build/commonTest.hxml +build/commonCoverage.hxml -x TestMain -cmd neko run -s src -s test -s schema -s build -p resources/static-analysis.txt diff --git a/testCoverage.hxml b/testCoverage.hxml new file mode 100644 index 00000000..111034bc --- /dev/null +++ b/testCoverage.hxml @@ -0,0 +1,3 @@ +build/commonTest.hxml +build/commonCoverage.hxml +-x TestMain