- Added some "special" tests that were left out before.
authorchristian.plesner.hansen@gmail.com <christian.plesner.hansen@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 3 Sep 2008 07:31:19 +0000 (07:31 +0000)
committerchristian.plesner.hansen@gmail.com <christian.plesner.hansen@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 3 Sep 2008 07:31:19 +0000 (07:31 +0000)
- Added option to test runner that allows us to run the tests under
  valgrind.
- Added test status for the failing arm simulator tests.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@116 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

test/mjsunit/fuzz-natives.js [new file with mode: 0644]
test/mjsunit/greedy.js [new file with mode: 0644]
test/mjsunit/leakcheck.js [new file with mode: 0644]
test/mjsunit/mjsunit.status
test/mjsunit/number-tostring-small.js [new file with mode: 0644]
test/mjsunit/regress/regress-1134697.js [new file with mode: 0644]
tools/test.py

diff --git a/test/mjsunit/fuzz-natives.js b/test/mjsunit/fuzz-natives.js
new file mode 100644 (file)
index 0000000..f5cdcc1
--- /dev/null
@@ -0,0 +1,138 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+function makeArguments() {
+  var result = [ ];
+  result.push(17);
+  result.push(-31);
+  result.push(Number.MAX_VALUE);
+  result.push(new Array(5003));
+  result.push(Number.MIN_VALUE);
+  result.push("whoops");
+  result.push("x");
+  result.push({"x": 1, "y": 2});
+  var slowCaseObj = {"a": 3, "b": 4, "c": 5};
+  delete slowCaseObj.c;
+  result.push(slowCaseObj);
+  result.push(function () { return 8; });
+  return result;
+}
+
+var kArgObjects = makeArguments().length;
+
+function makeFunction(name, argc) {
+  var args = [];
+  for (var i = 0; i < argc; i++)
+    args.push("x" + i);
+  var argsStr = args.join(", ");
+  return new Function(args.join(", "), "return %" + name + "(" + argsStr + ");");
+}
+
+function testArgumentCount(name) {
+  for (var i = 0; i < 10; i++) {
+    var func = makeFunction(name, i);
+    var args = [ ];
+    for (var j = 0; j < i; j++)
+      args.push(0);
+    try {
+      func.apply(void 0, args);
+    } catch (e) {
+      // we don't care what happens as long as we don't crash
+    }
+  }
+}
+
+function testArgumentTypes(name, argc) {
+  var type = 0;
+  var hasMore = true;
+  var func = makeFunction(name, argc);
+  while (hasMore) {
+    var argPool = makeArguments();
+    var current = type;
+    var hasMore = false;
+    var argList = [ ];
+    for (var i = 0; i < argc; i++) {
+      var index = current % kArgObjects;
+      current = (current / kArgObjects) << 0;
+      if (index != (kArgObjects - 1))
+        hasMore = true;
+      argList.push(argPool[index]);
+    }
+    try {
+      func.apply(void 0, argList);
+    } catch (e) {
+      // we don't care what happens as long as we don't crash
+    }
+    type++;
+  }
+}
+
+var knownProblems = {
+  "Abort": true,
+  
+  // These functions use pseudo-stack-pointers and are not robust
+  // to unexpected integer values.
+  "DebugEvaluate": true,
+
+  // These functions do nontrivial error checking in recursive calls,
+  // which means that we have to propagate errors back.
+  "SetFunctionBreakPoint": true,
+  "SetScriptBreakPoint": true,
+  "ChangeBreakOnException": true,
+  "PrepareStep": true,
+  
+  // These functions should not be callable as runtime functions.
+  "NewContext": true,
+  "PushContext": true,
+  "LazyCompile": true,
+  "CreateObjectLiteralBoilerplate": true,
+  "CloneObjectLiteralBoilerplate": true,
+  "IS_VAR": true
+};
+
+var currentlyUncallable = {
+  // We need to find a way to test this without breaking the system.
+  "SystemBreak": true
+};
+
+function testNatives() {
+  var allNatives = %ListNatives();
+  for (var i = 0; i < allNatives.length; i++) {
+    var nativeInfo = allNatives[i];
+    var name = nativeInfo[0];
+    if (name in knownProblems || name in currentlyUncallable)
+      continue;
+    print(name);
+    var argc = nativeInfo[1];
+    testArgumentCount(name);
+    testArgumentTypes(name, argc);
+  }
+}
+
+testNatives();
diff --git a/test/mjsunit/greedy.js b/test/mjsunit/greedy.js
new file mode 100644 (file)
index 0000000..2ebfc66
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --gc-greedy
+
+function IterativeFib(n) {
+  var f0 = 0, f1 = 1;
+  for (; n > 0; --n) {
+    var f2 = f0 + f1;
+    f0 = f1; f1 = f2;
+  }
+  return f0;
+}
+
+function RecursiveFib(n) {
+  if (n <= 1) return n;
+  return RecursiveFib(n - 1) + RecursiveFib(n - 2);
+}
+
+function Check(n, expected) {
+  var i = IterativeFib(n);
+  var r = RecursiveFib(n);
+  assertEquals(i, expected);
+  assertEquals(r, expected);
+}
+
+Check(0, 0);
+Check(1, 1);
+Check(2, 1);
+Check(3, 1 + 1);
+Check(4, 2 + 1);
+Check(5, 3 + 2);
+Check(10, 55);
+Check(15, 610);
+Check(20, 6765);
+assertEquals(IterativeFib(75), 2111485077978050);
diff --git a/test/mjsunit/leakcheck.js b/test/mjsunit/leakcheck.js
new file mode 100644 (file)
index 0000000..18b2680
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/**
+ * This test is run with leak detection when running special tests.
+ * Don't do too much work here or running it will take forever.
+ */
+
+function fac(n) {
+  if (n > 0) return fac(n - 1) * n;
+  else return 1;
+}
+
+function testFac() {
+  if (fac(6) != 720) throw "Error";
+}
+
+function testRegExp() {
+  var input = "123456789";
+  var result = input.replace(/[4-6]+/g, "xxx");
+  if (result != "123xxx789") throw "Error";
+}
+
+function main() {
+  testFac();
+  testRegExp();
+}
+
+main();
index 145aeab..df1a34f 100644 (file)
 prefix mjsunit
 
 # All tests in the bug directory are expected to fail.
-
 bugs: FAIL
 
 # This one fails in debug mode.
-
 regexp-multiline-stack-trace: PASS IF $MODE==RELEASE, FAIL IF $MODE==DEBUG
+
+# This one uses a built-in that's only present in debug mode.
+fuzz-natives: PASS, SKIP IF $MODE==RELEASE
+
+[ $arch == arm ]
+
+#1020483: Debug tests fail on arm
+debug-constructor: FAIL
+debug-continue: FAIL
+debug-backtrace-text: FAIL
+debug-backtrace: FAIL
+debug-evaluate-recursive: FAIL
+debug-changebreakpoint: FAIL
+debug-clearbreakpoint: FAIL
+debug-conditional-breakpoints: FAIL
+debug-enable-disable-breakpoints: FAIL
+debug-evaluate: FAIL
+debug-event-listener: FAIL
+debug-ignore-breakpoints: FAIL
+debug-multiple-breakpoints: FAIL
+# Bug number 1308895. This passes on the ARM simulator, fails on the ARM Linux machine.
+debug-script-breakpoints: PASS || FAIL
+debug-setbreakpoint: FAIL
+debug-step-stub-callfunction: FAIL
+debug-stepin-constructor: FAIL
+debug-step: FAIL
+regress/regress-998565: FAIL
+regress/regress-1081309: FAIL
diff --git a/test/mjsunit/number-tostring-small.js b/test/mjsunit/number-tostring-small.js
new file mode 100644 (file)
index 0000000..b168ac0
--- /dev/null
@@ -0,0 +1,395 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// This file is a concatenation of the number-tostring and
+// to-precision mjsunit tests where the mjsunit assert code has been
+// removed.
+
+// ----------------------------------------------------------------------
+// toString
+(NaN).toString();
+(1/0).toString();
+(-1/0).toString();
+(0).toString();
+(9).toString();
+(90).toString();
+(90.12).toString();
+(0.1).toString();
+(0.01).toString();
+(0.0123).toString();
+(111111111111111111111).toString();
+(1111111111111111111111).toString();
+(11111111111111111111111).toString();
+(0.00001).toString();
+(0.000001).toString();
+(0.0000001).toString();
+(0.00000012).toString();
+(0.000000123).toString();
+(0.00000001).toString();
+(0.000000012).toString();
+(0.0000000123).toString();
+
+(-0).toString();
+(-9).toString();
+(-90).toString();
+(-90.12).toString();
+(-0.1).toString();
+(-0.01).toString();
+(-0.0123).toString();
+(-111111111111111111111).toString();
+(-1111111111111111111111).toString();
+(-11111111111111111111111).toString();
+(-0.00001).toString();
+(-0.000001).toString();
+(-0.0000001).toString();
+(-0.00000012).toString();
+(-0.000000123).toString();
+(-0.00000001).toString();
+(-0.000000012).toString();
+(-0.0000000123).toString();
+
+(NaN).toString(16);
+(1/0).toString(16);
+(-1/0).toString(16);
+(0).toString(16);
+(9).toString(16);
+(90).toString(16);
+(90.12).toString(16);
+(0.1).toString(16);
+(0.01).toString(16);
+(0.0123).toString(16);
+(111111111111111111111).toString(16);
+(1111111111111111111111).toString(16);
+(11111111111111111111111).toString(16);
+(0.00001).toString(16);
+(0.000001).toString(16);
+(0.0000001).toString(16);
+(0.00000012).toString(16);
+(0.000000123).toString(16);
+(0.00000001).toString(16);
+(0.000000012).toString(16);
+(0.0000000123).toString(16);
+
+(-0).toString(16);
+(-9).toString(16);
+(-90).toString(16);
+(-90.12).toString(16);
+(-0.1).toString(16);
+(-0.01).toString(16);
+(-0.0123).toString(16);
+(-111111111111111111111).toString(16);
+(-1111111111111111111111).toString(16);
+(-11111111111111111111111).toString(16);
+(-0.00001).toString(16);
+(-0.000001).toString(16);
+(-0.0000001).toString(16);
+(-0.00000012).toString(16);
+(-0.000000123).toString(16);
+(-0.00000001).toString(16);
+(-0.000000012).toString(16);
+(-0.0000000123).toString(16);
+
+(2,32).toString();
+(Math.pow(2,32)-1).toString(16);
+(Math.pow(2,32)-1).toString(2);
+(10000007).toString(36);
+(0).toString(36);
+(0).toString(16);
+(0).toString(10);
+(0).toString(8);
+(0).toString(2);
+(2,32).toString(2);
+(Math.pow(2,32) + 1).toString(2);
+(0x100000000000081).toString(16);
+(-(-'0x1000000000000081')).toString(16);
+(0x100000000000081).toString(2);
+(-(Math.pow(2,32)-1)).toString(2);
+(-10000007).toString(36);
+(-Math.pow(2,32)).toString(2);
+(-(Math.pow(2,32) + 1)).toString(2);
+(-0x100000000000081).toString(16);
+(-0x100000000000081).toString(2);
+(1000).toString();
+(0.00001).toString();
+(1000000000000000128).toString();
+(1000000000000000012800).toString();
+(-1000000000000000012800).toString();
+(0.0000001).toString();
+(-0.0000001).toString();
+(1000000000000000128000).toString();
+(0.000001).toString();
+(0.0000001).toString();
+(8.5).toString(16);
+(-8.5).toString(16);
+
+// ----------------------------------------------------------------------
+// toFixed
+(NaN).toFixed(2);
+(1/0).toFixed(2);
+(-1/0).toFixed(2);
+
+(1111111111111111111111).toFixed(8);
+(0.1).toFixed(1);
+(0.1).toFixed(2);
+(0.1).toFixed(3);
+(0.01).toFixed(2);
+(0.01).toFixed(3);
+(0.01).toFixed(4);
+(0.001).toFixed(2);
+(0.001).toFixed(3);
+(0.001).toFixed(4);
+(1).toFixed(4);
+(1).toFixed(1);
+(1).toFixed(0);
+(12).toFixed(0);
+(1.1).toFixed(0);
+(12.1).toFixed(0);
+(1.12).toFixed(0);
+(12.12).toFixed(0);
+(0.0000006).toFixed(7);
+(0.00000006).toFixed(8);
+(0.00000006).toFixed(9);
+(0.00000006).toFixed(10);
+(0).toFixed(0);
+(0).toFixed(1);
+(0).toFixed(2);
+
+(-1111111111111111111111).toFixed(8);
+(-0.1).toFixed(1);
+(-0.1).toFixed(2);
+(-0.1).toFixed(3);
+(-0.01).toFixed(2);
+(-0.01).toFixed(3);
+(-0.01).toFixed(4);
+(-0.001).toFixed(2);
+(-0.001).toFixed(3);
+(-0.001).toFixed(4);
+(-1).toFixed(4);
+(-1).toFixed(1);
+(-1).toFixed(0);
+(-1.1).toFixed(0);
+(-12.1).toFixed(0);
+(-1.12).toFixed(0);
+(-12.12).toFixed(0);
+(-0.0000006).toFixed(7);
+(-0.00000006).toFixed(8);
+(-0.00000006).toFixed(9);
+(-0.00000006).toFixed(10);
+(-0).toFixed(0);
+(-0).toFixed(1);
+(-0).toFixed(2);
+
+(1000).toFixed();
+(0.00001).toFixed();
+(0.00001).toFixed(5);
+(0.0000000000000000001).toFixed(20);
+(0.00001).toFixed(17);
+(1).toFixed(17);
+(1000000000000000128).toFixed();
+(100000000000000128).toFixed(1);
+(10000000000000128).toFixed(2);
+(10000000000000128).toFixed(20);
+(0).toFixed();
+((-42).toFixed(3));
+(-1000000000000000128).toFixed();
+(-0.0000000000000000001).toFixed(20);
+(0.123123123123123).toFixed(20);
+// Test that we round up even when the last digit generated is even.
+// dtoa does not do this in its original form.
+(0.5).toFixed(0);
+(-0.5).toFixed(0);
+(1.25).toFixed(1);
+// This is bizare, but Spidermonkey and KJS behave the same.
+(234.20405).toFixed(4);
+(234.2040506).toFixed(4);
+
+// ----------------------------------------------------------------------
+// toExponential
+(1).toExponential();
+(11).toExponential();
+(112).toExponential();
+(1).toExponential(0);
+(11).toExponential(0);
+(112).toExponential(0);
+(1).toExponential(1);
+(11).toExponential(1);
+(112).toExponential(1);
+(1).toExponential(2);
+(11).toExponential(2);
+(112).toExponential(2);
+(1).toExponential(3);
+(11).toExponential(3);
+(112).toExponential(3);
+(0.1).toExponential();
+(0.11).toExponential();
+(0.112).toExponential();
+(0.1).toExponential(0);
+(0.11).toExponential(0);
+(0.112).toExponential(0);
+(0.1).toExponential(1);
+(0.11).toExponential(1);
+(0.112).toExponential(1);
+(0.1).toExponential(2);
+(0.11).toExponential(2);
+(0.112).toExponential(2);
+(0.1).toExponential(3);
+(0.11).toExponential(3);
+(0.112).toExponential(3);
+
+(-1).toExponential();
+(-11).toExponential();
+(-112).toExponential();
+(-1).toExponential(0);
+(-11).toExponential(0);
+(-112).toExponential(0);
+(-1).toExponential(1);
+(-11).toExponential(1);
+(-112).toExponential(1);
+(-1).toExponential(2);
+(-11).toExponential(2);
+(-112).toExponential(2);
+(-1).toExponential(3);
+(-11).toExponential(3);
+(-112).toExponential(3);
+(-0.1).toExponential();
+(-0.11).toExponential();
+(-0.112).toExponential();
+(-0.1).toExponential(0);
+(-0.11).toExponential(0);
+(-0.112).toExponential(0);
+(-0.1).toExponential(1);
+(-0.11).toExponential(1);
+(-0.112).toExponential(1);
+(-0.1).toExponential(2);
+(-0.11).toExponential(2);
+(-0.112).toExponential(2);
+(-0.1).toExponential(3);
+(-0.11).toExponential(3);
+(-0.112).toExponential(3);
+
+(NaN).toExponential(2);
+(Infinity).toExponential(2);
+(-Infinity).toExponential(2);
+(1).toExponential(0);
+(0).toExponential();
+(0).toExponential(2);
+(11.2356).toExponential(0);
+(11.2356).toExponential(4);
+(0.000112356).toExponential(4);
+(-0.000112356).toExponential(4);
+(0.000112356).toExponential();
+(-0.000112356).toExponential();
+
+// ----------------------------------------------------------------------
+// toPrecision
+(NaN).toPrecision(1);
+(Infinity).toPrecision(2);
+(-Infinity).toPrecision(2);
+(0.000555).toPrecision(15);
+(0.000000555).toPrecision(15);
+(-0.000000555).toPrecision(15);
+(123456789).toPrecision(1);
+(123456789).toPrecision(9);
+(123456789).toPrecision(8);
+(123456789).toPrecision(7);
+(-123456789).toPrecision(7);
+(-.0000000012345).toPrecision(2);
+(-.000000012345).toPrecision(2);
+(-.00000012345).toPrecision(2);
+(-.0000012345).toPrecision(2);
+(-.000012345).toPrecision(2);
+(-.00012345).toPrecision(2);
+(-.0012345).toPrecision(2);
+(-.012345).toPrecision(2);
+(-.12345).toPrecision(2);
+(-1.2345).toPrecision(2);
+(-12.345).toPrecision(2);
+(-123.45).toPrecision(2);
+(-1234.5).toPrecision(2);
+(-12345).toPrecision(2);
+(-12345.67).toPrecision(4);
+Number(-12344.67).toPrecision(4);
+// Test that we round up even when the last digit generated is even.
+// dtoa does not do this in its original form.
+(1.25).toPrecision(2);
+(1.35).toPrecision(2);
+
+// Test the exponential notation output.
+(1.2345e+27).toPrecision(1);
+(1.2345e+27).toPrecision(2);
+(1.2345e+27).toPrecision(3);
+(1.2345e+27).toPrecision(4);
+(1.2345e+27).toPrecision(5);
+(1.2345e+27).toPrecision(6);
+(1.2345e+27).toPrecision(7);
+
+(-1.2345e+27).toPrecision(1);
+(-1.2345e+27).toPrecision(2);
+(-1.2345e+27).toPrecision(3);
+(-1.2345e+27).toPrecision(4);
+(-1.2345e+27).toPrecision(5);
+(-1.2345e+27).toPrecision(6);
+(-1.2345e+27).toPrecision(7);
+
+
+// Test the fixed notation output.
+(7).toPrecision(1);
+(7).toPrecision(2);
+(7).toPrecision(3);
+
+(-7).toPrecision(1);
+(-7).toPrecision(2);
+(-7).toPrecision(3);
+
+(91).toPrecision(1);
+(91).toPrecision(2);
+(91).toPrecision(3);
+(91).toPrecision(4);
+
+(-91).toPrecision(1);
+(-91).toPrecision(2);
+(-91).toPrecision(3);
+(-91).toPrecision(4);
+
+(91.1234).toPrecision(1);
+(91.1234).toPrecision(2);
+(91.1234).toPrecision(3);
+(91.1234).toPrecision(4);
+(91.1234).toPrecision(5);
+(91.1234).toPrecision(6);
+(91.1234).toPrecision(7);
+(91.1234).toPrecision(8);
+
+(-91.1234).toPrecision(1);
+(-91.1234).toPrecision(2);
+(-91.1234).toPrecision(3);
+(-91.1234).toPrecision(4);
+(-91.1234).toPrecision(5);
+(-91.1234).toPrecision(6);
+(-91.1234).toPrecision(7);
+(-91.1234).toPrecision(8);
+
diff --git a/test/mjsunit/regress/regress-1134697.js b/test/mjsunit/regress/regress-1134697.js
new file mode 100644 (file)
index 0000000..c6a1f93
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2008 Google Inc. All Rights Reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Regression test case for issue 1134697.
+// Must run using valgrind.
+
+(-90).toPrecision(6);
index 9ce66c8..c23ca29 100755 (executable)
@@ -261,8 +261,9 @@ class TestCase(object):
 
   def Run(self):
     command = self.GetCommand()
-    output = Execute(command, self.context, self.context.timeout)
-    return TestOutput(self, command, output)
+    full_command = self.context.processor(command)
+    output = Execute(full_command, self.context, self.context.timeout)
+    return TestOutput(self, full_command, output)
 
 
 class TestOutput(object):
@@ -472,12 +473,13 @@ PREFIX = {'debug': '_g', 'release': ''}
 
 class Context(object):
 
-  def __init__(self, workspace, buildspace, verbose, vm, timeout):
+  def __init__(self, workspace, buildspace, verbose, vm, timeout, processor):
     self.workspace = workspace
     self.buildspace = buildspace
     self.verbose = verbose
     self.vm_root = vm
     self.timeout = timeout
+    self.processor = processor
 
   def GetVm(self, mode):
     name = self.vm_root + PREFIX[mode]
@@ -945,6 +947,7 @@ def BuildOptions():
       default=60, type="int")
   result.add_option("--arch", help='The architecture to run tests for',
       default=ARCH_GUESS)
+  result.add_option("--special-command", default=None)
   return result
 
 
@@ -1005,6 +1008,20 @@ def SplitPath(s):
   return [ Pattern(s) for s in stripped if len(s) > 0 ]
 
 
+def GetSpecialCommandProcessor(value):
+  if (not value) or (value.find('@') == -1):
+    def ExpandCommand(args):
+      return args
+    return ExpandCommand
+  else:
+    pos = value.find('@')
+    prefix = value[:pos].split()
+    suffix = value[pos+1:].split()
+    def ExpandCommand(args):
+      return prefix + args + suffix
+    return ExpandCommand
+
+
 BUILT_IN_TESTS = ['mjsunit', 'cctest']
 
 
@@ -1032,7 +1049,8 @@ def Main():
   buildspace = abspath('.')
   context = Context(workspace, buildspace, VERBOSE,
                     join(buildspace, 'shell'),
-                    options.timeout)
+                    options.timeout,
+                    GetSpecialCommandProcessor(options.special_command))
   if not options.no_build:
     reqs = [ ]
     for path in paths: