]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/mozilla/js1_2/function/tostring-1.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / mozilla / js1_2 / function / tostring-1.js
index d532d65af13eb662ce54a3dd2251633de5a23a94..cf83f48c1af31560707ca9d68bfda906afd73d6c 100644 (file)
     Date:               12 november 1997
 */
 
+// These test cases should not be testing for a particular
+// whitespace formatting (this is implementation defined).
+// Strip out whitespace, or in the case of whitespace
+// abutting a word character reduce to a single space.
+function simplify(str)
+{
+    return str.replace(/\s+/g, " ").replace(/ (\W)/g, "$1").replace(/(\W) /g, "$1").trim();
+}
+
     var SECTION = "tostring-1";
     var VERSION = "JS1_2";
     startTest();
 
     testcases[tc++] = new TestCase( SECTION,
                                     "stub.toString()",
-                                    t1.valueOf(),
-                                    stub.toString() );
+                                    simplify(t1.valueOf()),
+                                    simplify(stub.toString()) );
 
     testcases[tc++] = new TestCase( SECTION,
                                     "ToString.toString()",
-                                    t2.valueOf(),
-                                    ToString.toString() );
+                                    simplify(t2.valueOf()),
+                                    simplify(ToString.toString()) );
 
     testcases[tc++] = new TestCase( SECTION,
                                     "Add.toString()",
-                                    t3.valueOf(),
-                                    Add.toString() );
+                                    simplify(t3.valueOf()),
+                                    simplify(Add.toString()) );
 
     testcases[tc++] = new TestCase( SECTION,
                                     "noop.toString()",
-                                    t4.toString(),
-                                    noop.toString() );
+                                    simplify(t4.toString()),
+                                    simplify(noop.toString()) );
 
     testcases[tc++] = new TestCase( SECTION,
                                     "f.toString()",
-                                    t5.toString(),
-                                    f.toString() );
+                                    simplify(t5.toString()),
+                                    simplify(f.toString()) );
     test();
 
 function noop( value ) {