OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compilation-info.h" | 5 #include "src/compilation-info.h" |
6 #include "test/cctest/compiler/function-tester.h" | 6 #include "test/cctest/compiler/function-tester.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 TEST(StringCharCodeAt) { | 124 TEST(StringCharCodeAt) { |
125 FunctionTester T("(function(a,b) { return %_StringCharCodeAt(a,b); })", | 125 FunctionTester T("(function(a,b) { return %_StringCharCodeAt(a,b); })", |
126 flags); | 126 flags); |
127 | 127 |
128 T.CheckCall(T.Val('e'), T.Val("huge fan!"), T.Val(3)); | 128 T.CheckCall(T.Val('e'), T.Val("huge fan!"), T.Val(3)); |
129 T.CheckCall(T.Val('f'), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); | 129 T.CheckCall(T.Val('f'), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); |
130 T.CheckCall(T.nan(), T.Val("not a fan!"), T.Val(23)); | 130 T.CheckCall(T.nan(), T.Val("not a fan!"), T.Val(23)); |
131 } | 131 } |
132 | 132 |
133 | 133 |
134 TEST(StringCharFromCode) { | |
135 FunctionTester T("(function(a) { return %_StringCharFromCode(a); })", flags); | |
136 | |
137 T.CheckCall(T.Val("a"), T.Val(97)); | |
138 T.CheckCall(T.Val("\xE2\x9D\x8A"), T.Val(0x274A)); | |
139 T.CheckCall(T.Val(""), T.undefined()); | |
140 } | |
141 | |
142 | |
143 TEST(StringCompare) { | 134 TEST(StringCompare) { |
144 FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })", flags); | 135 FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })", flags); |
145 | 136 |
146 T.CheckCall(T.Val(-1), T.Val("aaa"), T.Val("bbb")); | 137 T.CheckCall(T.Val(-1), T.Val("aaa"), T.Val("bbb")); |
147 T.CheckCall(T.Val(0.0), T.Val("bbb"), T.Val("bbb")); | 138 T.CheckCall(T.Val(0.0), T.Val("bbb"), T.Val("bbb")); |
148 T.CheckCall(T.Val(+1), T.Val("ccc"), T.Val("bbb")); | 139 T.CheckCall(T.Val(+1), T.Val("ccc"), T.Val("bbb")); |
149 } | 140 } |
150 | 141 |
151 | 142 |
152 TEST(SubString) { | 143 TEST(SubString) { |
153 FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags); | 144 FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags); |
154 | 145 |
155 T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0)); | 146 T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0)); |
156 T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2)); | 147 T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2)); |
157 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0)); | 148 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0)); |
158 } | 149 } |
159 | 150 |
160 } // namespace compiler | 151 } // namespace compiler |
161 } // namespace internal | 152 } // namespace internal |
162 } // namespace v8 | 153 } // namespace v8 |
OLD | NEW |