Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 15.5.4.8-1.js |
michael@0 | 9 | ECMA Section: 15.5.4.8 String.prototype.split( separator ) |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | Returns an Array object into which substrings of the result of converting |
michael@0 | 13 | this object to a string have been stored. The substrings are determined by |
michael@0 | 14 | searching from left to right for occurrences of the given separator; these |
michael@0 | 15 | occurrences are not part of any substring in the returned array, but serve |
michael@0 | 16 | to divide up this string value. The separator may be a string of any length. |
michael@0 | 17 | |
michael@0 | 18 | As a special case, if the separator is the empty string, the string is split |
michael@0 | 19 | up into individual characters; the length of the result array equals the |
michael@0 | 20 | length of the string, and each substring contains one character. |
michael@0 | 21 | |
michael@0 | 22 | If the separator is not supplied, then the result array contains just one |
michael@0 | 23 | string, which is the string. |
michael@0 | 24 | |
michael@0 | 25 | Author: christine@netscape.com, pschwartau@netscape.com |
michael@0 | 26 | Date: 12 November 1997 |
michael@0 | 27 | Modified: 14 July 2002 |
michael@0 | 28 | Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 |
michael@0 | 29 | ECMA-262 Ed.3 Section 15.5.4.14 |
michael@0 | 30 | The length property of the split method is 2 |
michael@0 | 31 | * |
michael@0 | 32 | */ |
michael@0 | 33 | |
michael@0 | 34 | var SECTION = "15.5.4.8-1"; |
michael@0 | 35 | var VERSION = "ECMA_1"; |
michael@0 | 36 | startTest(); |
michael@0 | 37 | var TITLE = "String.prototype.split"; |
michael@0 | 38 | |
michael@0 | 39 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 40 | |
michael@0 | 41 | new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length ); |
michael@0 | 42 | new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length ); |
michael@0 | 43 | new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") ); |
michael@0 | 44 | |
michael@0 | 45 | // test cases for when split is called with no arguments. |
michael@0 | 46 | |
michael@0 | 47 | // this is a string object |
michael@0 | 48 | |
michael@0 | 49 | new TestCase( SECTION, |
michael@0 | 50 | "var s = new String('this is a string object'); typeof s.split()", |
michael@0 | 51 | "object", |
michael@0 | 52 | eval("var s = new String('this is a string object'); typeof s.split()") ); |
michael@0 | 53 | |
michael@0 | 54 | new TestCase( SECTION, |
michael@0 | 55 | "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()", |
michael@0 | 56 | "[object Array]", |
michael@0 | 57 | eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") ); |
michael@0 | 58 | |
michael@0 | 59 | new TestCase( SECTION, |
michael@0 | 60 | "var s = new String('this is a string object'); s.split().length", |
michael@0 | 61 | 1, |
michael@0 | 62 | eval("var s = new String('this is a string object'); s.split().length") ); |
michael@0 | 63 | |
michael@0 | 64 | new TestCase( SECTION, |
michael@0 | 65 | "var s = new String('this is a string object'); s.split()[0]", |
michael@0 | 66 | "this is a string object", |
michael@0 | 67 | eval("var s = new String('this is a string object'); s.split()[0]") ); |
michael@0 | 68 | |
michael@0 | 69 | // this is an object object |
michael@0 | 70 | new TestCase( SECTION, |
michael@0 | 71 | "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()", |
michael@0 | 72 | "object", |
michael@0 | 73 | eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") ); |
michael@0 | 74 | |
michael@0 | 75 | new TestCase( SECTION, |
michael@0 | 76 | "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", |
michael@0 | 77 | "[object Array]", |
michael@0 | 78 | eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); |
michael@0 | 79 | |
michael@0 | 80 | new TestCase( SECTION, |
michael@0 | 81 | "var obj = new Object(); obj.split = String.prototype.split; obj.split().length", |
michael@0 | 82 | 1, |
michael@0 | 83 | eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") ); |
michael@0 | 84 | |
michael@0 | 85 | new TestCase( SECTION, |
michael@0 | 86 | "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]", |
michael@0 | 87 | "[object Object]", |
michael@0 | 88 | eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") ); |
michael@0 | 89 | |
michael@0 | 90 | // this is a function object |
michael@0 | 91 | new TestCase( SECTION, |
michael@0 | 92 | "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()", |
michael@0 | 93 | "object", |
michael@0 | 94 | eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") ); |
michael@0 | 95 | |
michael@0 | 96 | new TestCase( SECTION, |
michael@0 | 97 | "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", |
michael@0 | 98 | "[object Array]", |
michael@0 | 99 | eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); |
michael@0 | 100 | |
michael@0 | 101 | new TestCase( SECTION, |
michael@0 | 102 | "var obj = new Function(); obj.split = String.prototype.split; obj.split().length", |
michael@0 | 103 | 1, |
michael@0 | 104 | eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") ); |
michael@0 | 105 | |
michael@0 | 106 | new TestCase( SECTION, |
michael@0 | 107 | "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]", |
michael@0 | 108 | "[object Function]", |
michael@0 | 109 | eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") ); |
michael@0 | 110 | |
michael@0 | 111 | // this is a number object |
michael@0 | 112 | new TestCase( SECTION, |
michael@0 | 113 | "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()", |
michael@0 | 114 | "object", |
michael@0 | 115 | eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") ); |
michael@0 | 116 | |
michael@0 | 117 | new TestCase( SECTION, |
michael@0 | 118 | "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", |
michael@0 | 119 | "[object Array]", |
michael@0 | 120 | eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); |
michael@0 | 121 | |
michael@0 | 122 | new TestCase( SECTION, |
michael@0 | 123 | "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length", |
michael@0 | 124 | 1, |
michael@0 | 125 | eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") ); |
michael@0 | 126 | |
michael@0 | 127 | new TestCase( SECTION, |
michael@0 | 128 | "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]", |
michael@0 | 129 | "-1e+21", |
michael@0 | 130 | eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") ); |
michael@0 | 131 | |
michael@0 | 132 | |
michael@0 | 133 | // this is the Math object |
michael@0 | 134 | new TestCase( SECTION, |
michael@0 | 135 | "var obj = Math; obj.split = String.prototype.split; typeof obj.split()", |
michael@0 | 136 | "object", |
michael@0 | 137 | eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") ); |
michael@0 | 138 | |
michael@0 | 139 | new TestCase( SECTION, |
michael@0 | 140 | "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", |
michael@0 | 141 | "[object Array]", |
michael@0 | 142 | eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); |
michael@0 | 143 | |
michael@0 | 144 | new TestCase( SECTION, |
michael@0 | 145 | "var obj = Math; obj.split = String.prototype.split; obj.split().length", |
michael@0 | 146 | 1, |
michael@0 | 147 | eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") ); |
michael@0 | 148 | |
michael@0 | 149 | new TestCase( SECTION, |
michael@0 | 150 | "var obj = Math; obj.split = String.prototype.split; obj.split()[0]", |
michael@0 | 151 | "[object Math]", |
michael@0 | 152 | eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") ); |
michael@0 | 153 | |
michael@0 | 154 | // this is an array object |
michael@0 | 155 | new TestCase( SECTION, |
michael@0 | 156 | "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()", |
michael@0 | 157 | "object", |
michael@0 | 158 | eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") ); |
michael@0 | 159 | |
michael@0 | 160 | new TestCase( SECTION, |
michael@0 | 161 | "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", |
michael@0 | 162 | "[object Array]", |
michael@0 | 163 | eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); |
michael@0 | 164 | |
michael@0 | 165 | new TestCase( SECTION, |
michael@0 | 166 | "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length", |
michael@0 | 167 | 1, |
michael@0 | 168 | eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") ); |
michael@0 | 169 | |
michael@0 | 170 | new TestCase( SECTION, |
michael@0 | 171 | "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]", |
michael@0 | 172 | "1,2,3,4,5", |
michael@0 | 173 | eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") ); |
michael@0 | 174 | |
michael@0 | 175 | // this is a Boolean object |
michael@0 | 176 | |
michael@0 | 177 | new TestCase( SECTION, |
michael@0 | 178 | "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()", |
michael@0 | 179 | "object", |
michael@0 | 180 | eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") ); |
michael@0 | 181 | |
michael@0 | 182 | new TestCase( SECTION, |
michael@0 | 183 | "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", |
michael@0 | 184 | "[object Array]", |
michael@0 | 185 | eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); |
michael@0 | 186 | |
michael@0 | 187 | new TestCase( SECTION, |
michael@0 | 188 | "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length", |
michael@0 | 189 | 1, |
michael@0 | 190 | eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") ); |
michael@0 | 191 | |
michael@0 | 192 | new TestCase( SECTION, |
michael@0 | 193 | "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]", |
michael@0 | 194 | "false", |
michael@0 | 195 | eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") ); |
michael@0 | 196 | |
michael@0 | 197 | |
michael@0 | 198 | test(); |