Index: test/webkit/fast/js/string-anchor.js |
diff --git a/test/webkit/cached-call-uninitialized-arguments.js b/test/webkit/fast/js/string-anchor.js |
similarity index 57% |
copy from test/webkit/cached-call-uninitialized-arguments.js |
copy to test/webkit/fast/js/string-anchor.js |
index de3f098800776a4d3ea0493b4db7876824f0d1e4..f213b89156daa2a2810b94de3183d0ed3fc10896 100644 |
--- a/test/webkit/cached-call-uninitialized-arguments.js |
+++ b/test/webkit/fast/js/string-anchor.js |
@@ -22,45 +22,32 @@ |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
description( |
-"This test checks that uninitialized parameters for cached call functions correctly defaults to undefined." |
- |
+'This is a test case for String.prototype.anchor(name).' |
); |
-function doForEach(arr) { |
- function callback(element, index, array, arg4, arg5, arg6) { |
+// This test is based on http://mathias.html5.org/tests/javascript/string/. |
+ |
+// Simple case. |
+shouldBe("'_'.anchor('b')", '"<a name=\\"b\\">_</a>"'); |
+ |
+// Does not escape special characters in `this` value. |
+shouldBe("'<'.anchor('b')", '"<a name=\\"b\\"><</a>"'); |
- function shouldBeUndefined(_a) { |
- var exception; |
- var _av; |
- try { |
- _av = eval(_a); |
- } catch (e) { |
- exception = e; |
- } |
+// first argument gets ToString()ed. |
+shouldBe("'_'.anchor(0x2A)", '"<a name=\\"42\\">_</a>"'); |
- if (exception) |
- testFailed(_a + " should be undefined. Threw exception " + exception); |
- else if (typeof _av == "undefined") |
- testPassed(_a + " is undefined."); |
- else |
- testFailed(_a + " should be undefined. Was " + _av); |
- } |
+// Check that the quotation mark is correctly escaped. |
+shouldBe("'_'.anchor('\"')", '"<a name=\\""\\">_</a>"'); |
+shouldBe("'_'.anchor('\" href=\"http://www.evil.com')", '"<a name=\\"" href="http://www.evil.com\\">_</a>"'); |
- shouldBeUndefined("arg4"); |
- shouldBeUndefined("arg5"); |
- shouldBeUndefined("arg6"); |
- } |
+// Generic use on Number object. |
+shouldBe("String.prototype.anchor.call(0x2A, 0x2A)", '"<a name=\\"42\\">42</a>"'); |
- arr.forEach(callback); |
-} |
+// Generic use on non-coercible object `undefined`. |
+shouldThrow("String.prototype.anchor.call(undefined)", '"TypeError: Type error"'); |
-function callAfterRecursingForDepth(depth, func, arr) { |
- if (depth > 0) { |
- callAfterRecursingForDepth(depth - 1, func, arr); |
- } else { |
- func(arr); |
- } |
-} |
+// Generic use on non-coercible object `null`. |
+shouldThrow("String.prototype.anchor.call(null)", '"TypeError: Type error"'); |
-var arr = [1]; |
-callAfterRecursingForDepth(20, doForEach, arr); |
+// Check anchor.length. |
+shouldBe("String.prototype.anchor.length", "1"); |