[gjs] coverage: Test for strings in case statements



commit 8bbdbae13c54ebfdad3b511c03749c7cb3bf8962
Author: Sam Spilsbury <smspillaz gmail com>
Date:   Mon Jun 15 14:58:36 2015 +0800

    coverage: Test for strings in case statements
    
    I was seeing the JS engine occassionally execute these as those
    they were executable. Added a test to check that this is not
    something which happens in most cases.

 installed-tests/js/testCoverage.js |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/installed-tests/js/testCoverage.js b/installed-tests/js/testCoverage.js
index f34c820..ad8f461 100644
--- a/installed-tests/js/testCoverage.js
+++ b/installed-tests/js/testCoverage.js
@@ -157,6 +157,22 @@ function testExpressionLinesFoundForCaseStatements() {
                       JSUnit.assertEquals);
 }
 
+function testExpressionLinesFoundForCaseStatementsCharacters() {
+    let foundLinesInsideCaseStatements =
+        parseScriptForExpressionLines("var a = 'a';\n" +
+                                      "switch (a) {\n" +
+                                      "case 'a':\n" +
+                                      "    a++;\n" +
+                                      "    break;\n" +
+                                      "case 'b':\n" +
+                                      "    a++;\n" +
+                                      "    break;\n" +
+                                      "}\n");
+    assertArrayEquals(foundLinesInsideCaseStatements,
+                      [1, 2, 4, 5, 7, 8],
+                      JSUnit.assertEquals);
+}
+
 function testExpressionLinesFoundForLoop() {
     let foundLinesInsideLoop =
         parseScriptForExpressionLines("for (let i = 0; i < 1; i++) {\n" +


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]