Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: test/mjsunit/new-string-add.js

Issue 551363002: Allow some runtime functions to accept Int32s instead of Smis. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/runtime-gen/apply.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Flags: --new-string-add
29
30 assertEquals("ab", "a" + "b", "ll");
31
32 assertEquals("12", "1" + "2", "dd");
33 assertEquals("123", "1" + "2" + "3", "ddd");
34 assertEquals("123", 1 + "2" + "3", "ndd");
35 assertEquals("123", "1" + 2 + "3", "dnd");
36 assertEquals("123", "1" + "2" + 3, "ddn");
37
38 assertEquals("123", "1" + 2 + 3, "dnn");
39 assertEquals("123", 1 + "2" + 3, "ndn");
40 assertEquals("33", 1 + 2 + "3", "nnd");
41
42 var x = "1";
43 assertEquals("12", x + 2, "vn");
44 assertEquals("12", x + "2", "vd");
45 assertEquals("21", 2 + x, "nv");
46 assertEquals("21", "2" + x, "dv");
47
48 var y = "2";
49 assertEquals("12", x + y, "vdvd");
50
51 x = 1;
52 assertEquals("12", x + y, "vnvd");
53
54 y = 2;
55 assertEquals(3, x + y, "vnvn");
56
57 x = "1";
58 assertEquals("12", x + y, "vdvn");
59
60 y = "2";
61 assertEquals("12", x + y, "vdvd2");
62
63 (function(x, y) {
64 var z = "3";
65 var w = "4";
66
67 assertEquals("11", x + x, "xx");
68 assertEquals("12", x + y, "xy");
69 assertEquals("13", x + z, "xz");
70 assertEquals("14", x + w, "xw");
71
72 assertEquals("21", y + x, "yx");
73 assertEquals("22", y + y, "yy");
74 assertEquals("23", y + z, "yz");
75 assertEquals("24", y + w, "yw");
76
77 assertEquals("31", z + x, "zx");
78 assertEquals("32", z + y, "zy");
79 assertEquals("33", z + z, "zz");
80 assertEquals("34", z + w, "zw");
81
82 assertEquals("41", w + x, "wx");
83 assertEquals("42", w + y, "wy");
84 assertEquals("43", w + z, "wz");
85 assertEquals("44", w + w, "ww");
86
87 (function(){x = 1; z = 3;})();
88
89 assertEquals(2, x + x, "x'x");
90 assertEquals("12", x + y, "x'y");
91 assertEquals(4, x + z, "x'z'");
92 assertEquals("14", x + w, "x'w");
93
94 assertEquals("21", y + x, "yx'");
95 assertEquals("22", y + y, "yy");
96 assertEquals("23", y + z, "yz'");
97 assertEquals("24", y + w, "yw");
98
99 assertEquals(4, z + x, "z'x'");
100 assertEquals("32", z + y, "z'y");
101 assertEquals(6, z + z, "z'z'");
102 assertEquals("34", z + w, "z'w");
103
104 assertEquals("41", w + x, "wx'");
105 assertEquals("42", w + y, "wy");
106 assertEquals("43", w + z, "wz'");
107 assertEquals("44", w + w, "ww");
108 })("1", "2");
109
110 assertEquals("142", "1" + new Number(42), "sN");
111 assertEquals("421", new Number(42) + "1", "Ns");
112 assertEquals(84, new Number(42) + new Number(42), "NN");
113
114 assertEquals("142", "1" + new String("42"), "sS");
115 assertEquals("421", new String("42") + "1", "Ss");
116 assertEquals("142", "1" + new String("42"), "sS");
117 assertEquals("4242", new String("42") + new String("42"), "SS");
118
119 assertEquals("1true", "1" + true, "sb");
120 assertEquals("true1", true + "1", "bs");
121 assertEquals(2, true + true, "bs");
122
123 assertEquals("1true", "1" + new Boolean(true), "sB");
124 assertEquals("true1", new Boolean(true) + "1", "Bs");
125 assertEquals(2, new Boolean(true) + new Boolean(true), "Bs");
126
127 assertEquals("1undefined", "1" + void 0, "sv");
128 assertEquals("undefined1", (void 0) + "1", "vs");
129 assertTrue(isNaN(void 0 + void 0), "vv");
130
131 assertEquals("1null", "1" + null, "su");
132 assertEquals("null1", null + "1", "us");
133 assertEquals(0, null + null, "uu");
134
135 (function (i) {
136 // Check that incoming frames are merged correctly.
137 var x;
138 var y;
139 var z;
140 var w;
141 switch (i) {
142 case 1: x = 42; y = "stry"; z = "strz"; w = 42; break;
143 default: x = "strx", y = 42; z = "strz"; w = 42; break;
144 }
145 var resxx = x + x;
146 var resxy = x + y;
147 var resxz = x + z;
148 var resxw = x + w;
149 var resyx = y + x;
150 var resyy = y + y;
151 var resyz = y + z;
152 var resyw = y + w;
153 var reszx = z + x;
154 var reszy = z + y;
155 var reszz = z + z;
156 var reszw = z + w;
157 var reswx = w + x;
158 var reswy = w + y;
159 var reswz = w + z;
160 var resww = w + w;
161 assertEquals(84, resxx, "swxx");
162 assertEquals("42stry", resxy, "swxy");
163 assertEquals("42strz", resxz, "swxz");
164 assertEquals(84, resxw, "swxw");
165 assertEquals("stry42", resyx, "swyx");
166 assertEquals("strystry", resyy, "swyy");
167 assertEquals("strystrz", resyz, "swyz");
168 assertEquals("stry42", resyw, "swyw");
169 assertEquals("strz42", reszx, "swzx");
170 assertEquals("strzstry", reszy, "swzy");
171 assertEquals("strzstrz", reszz, "swzz");
172 assertEquals("strz42", reszw, "swzw");
173 assertEquals(84, reswx, "swwx");
174 assertEquals("42stry", reswy, "swwy");
175 assertEquals("42strz", reswz, "swwz");
176 assertEquals(84, resww, "swww");
177 })(1);
178
179 // Generate ascii and non ascii strings from length 0 to 20.
180 var ascii = 'aaaaaaaaaaaaaaaaaaaa';
181 var non_ascii = '\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1 234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234';
182 assertEquals(20, ascii.length);
183 assertEquals(20, non_ascii.length);
184 var a = Array(21);
185 var b = Array(21);
186 for (var i = 0; i <= 20; i++) {
187 a[i] = ascii.substring(0, i);
188 b[i] = non_ascii.substring(0, i);
189 }
190
191 // Add ascii and non-ascii strings generating strings with length from 0 to 20.
192 for (var i = 0; i <= 20; i++) {
193 for (var j = 0; j < i; j++) {
194 assertEquals(a[i], a[j] + a[i - j])
195 assertEquals(b[i], b[j] + b[i - j])
196 }
197 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/runtime-gen/apply.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698