Restore lost or/and tests (hg strikes again, grrrr!)
authorBrendan Eich <brendan@mozilla.org>
Sat, 02 Aug 2008 15:56:28 -0700
changeset 17942 cb14a0450087dc740be59222f0b27b677b4fe4eb
parent 17941 760cbe78be8e06ca0faad5b80e34baed995be1b0
child 17943 b7918e1ba3c6da2fce868b2c73171b37dfc96e81
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherderautoland@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Restore lost or/and tests (hg strikes again, grrrr!)
js/src/trace-test.js
--- a/js/src/trace-test.js
+++ b/js/src/trace-test.js
@@ -396,11 +396,56 @@ function stringConvert()
     a[7] = s3 & "7";
     // a[8] = ~s3;
   }
   return a.toString();
 }
 stringConvert.expected = "1,8.7,75,37,,,,5";
 test(stringConvert);
 
+function orTestHelper(a, b, n)
+{
+  var k = 0;
+  for (var i = 0; i < n; i++) {
+    if (a || b)
+      k += i;
+  }
+  return k;
+}
+
+function andTestHelper(a, b, n)
+{
+  var k = 0;
+  for (var i = 0; i < n; i++) {
+    if (a && b)
+      k += i;
+  }
+  return k;
+}
+
+(function () {
+  var opsies   = ["||", "&&"];
+  var falsies  = [null, undefined, false, NaN, 0, /*""*/];
+  var truthies = [{}, true, 1, 42, 1/0, -1/0, /*"blah"*/];
+  var boolies  = [falsies, truthies];
+
+  for each (var op in opsies) {
+    for (var i in boolies) {
+      for (var j in boolies[i]) {
+        var x = uneval(boolies[i][j]);
+        for (var k in boolies) {
+          for (var l in boolies[k]) {
+            var y = uneval(boolies[k][l]);
+            var prefix = (op == "||") ? "or" : "and";
+            var f = new Function("return " + prefix + "TestHelper(" + x + "," + y + ",10)");
+            f.name = prefix + "Test(" + x + "," + y + ")";
+            f.expected = eval(x + op + y) ? 45 : 0;
+            test(f);
+          }
+        }
+      }
+    }
+  }
+})();
+
 /* Keep these at the end so that we can see the summary after the trace-debug spew. */
-print("pass:", passes.length ? passes.join(",") : "<none>");
-print("FAIL:", fails.length ? fails.join(",") : "<none>");
+print("\npassed:", passes.length && passes.join(","));
+print("\nFAILED:", fails.length && fails.join(","));