OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-expression-visitor.h" | 8 #include "src/ast/ast-expression-visitor.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser.h" | 10 #include "src/parsing/parser.h" |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 "function bar() { var x = fround(1.0); return (x % x)|0; }\n" | 1131 "function bar() { var x = fround(1.0); return (x % x)|0; }\n" |
1132 "function foo() { bar(); }", | 1132 "function foo() { bar(); }", |
1133 "asm: line 1: ill-typed arithmetic operation\n"); | 1133 "asm: line 1: ill-typed arithmetic operation\n"); |
1134 } | 1134 } |
1135 | 1135 |
1136 | 1136 |
1137 TEST(TernaryMismatchInt32Float64) { | 1137 TEST(TernaryMismatchInt32Float64) { |
1138 CHECK_FUNC_ERROR( | 1138 CHECK_FUNC_ERROR( |
1139 "function bar() { var x = 1; var y = 0.0; return (1 ? x : y)|0; }\n" | 1139 "function bar() { var x = 1; var y = 0.0; return (1 ? x : y)|0; }\n" |
1140 "function foo() { bar(); }", | 1140 "function foo() { bar(); }", |
1141 "asm: line 1: then and else expressions in ? must have the same type\n"); | 1141 "asm: line 1: then and else expressions in ? must have the same type " |
| 1142 "and be int, float, or double\n"); |
1142 } | 1143 } |
1143 | 1144 |
1144 | 1145 |
1145 TEST(TernaryMismatchIntish) { | 1146 TEST(TernaryMismatchIntish) { |
1146 CHECK_FUNC_ERROR( | 1147 CHECK_FUNC_ERROR( |
1147 "function bar() { var x = 1; var y = 0; return (1 ? x + x : y)|0; }\n" | 1148 "function bar() { var x = 1; var y = 0; return (1 ? x + x : y)|0; }\n" |
1148 "function foo() { bar(); }", | 1149 "function foo() { bar(); }", |
1149 "asm: line 1: invalid type in ? then expression\n"); | 1150 "asm: line 1: then and else expressions in ? must have the same type " |
| 1151 "and be int, float, or double\n"); |
1150 } | 1152 } |
1151 | 1153 |
1152 | 1154 |
1153 TEST(TernaryMismatchInt32Float32) { | 1155 TEST(TernaryMismatchInt32Float32) { |
1154 CHECK_FUNC_ERROR( | 1156 CHECK_FUNC_ERROR( |
1155 "function bar() { var x = 1; var y = 2.0; return (x?fround(y):x)|0; }\n" | 1157 "function bar() { var x = 1; var y = 2.0; return (x?fround(y):x)|0; }\n" |
1156 "function foo() { bar(); }", | 1158 "function foo() { bar(); }", |
1157 "asm: line 1: then and else expressions in ? must have the same type\n"); | 1159 "asm: line 1: then and else expressions in ? must have the same type " |
| 1160 "and be int, float, or double\n"); |
1158 } | 1161 } |
1159 | 1162 |
1160 | 1163 |
1161 TEST(TernaryBadCondition) { | 1164 TEST(TernaryBadCondition) { |
1162 CHECK_FUNC_ERROR( | 1165 CHECK_FUNC_ERROR( |
1163 "function bar() { var x = 1; var y = 2.0; return (y?x:1)|0; }\n" | 1166 "function bar() { var x = 1; var y = 2.0; return (y?x:1)|0; }\n" |
1164 "function foo() { bar(); }", | 1167 "function foo() { bar(); }", |
1165 "asm: line 1: condition must be of type int\n"); | 1168 "asm: line 1: condition must be of type int\n"); |
1166 } | 1169 } |
1167 | 1170 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 "function foo() { bar(); }", | 1355 "function foo() { bar(); }", |
1353 "asm: line 1: left and right side of integer / or % " | 1356 "asm: line 1: left and right side of integer / or % " |
1354 "must match and be signed or unsigned\n"); | 1357 "must match and be signed or unsigned\n"); |
1355 } | 1358 } |
1356 | 1359 |
1357 | 1360 |
1358 TEST(CompareToStringLeft) { | 1361 TEST(CompareToStringLeft) { |
1359 CHECK_FUNC_ERROR( | 1362 CHECK_FUNC_ERROR( |
1360 "function bar() { var x = 1; return ('hi' > x)|0; }\n" | 1363 "function bar() { var x = 1; return ('hi' > x)|0; }\n" |
1361 "function foo() { bar(); }", | 1364 "function foo() { bar(); }", |
1362 "asm: line 1: bad type on left side of comparison\n"); | 1365 "asm: line 1: left and right side of comparison must match type " |
| 1366 "and be signed, unsigned, float, or double\n"); |
1363 } | 1367 } |
1364 | 1368 |
1365 | 1369 |
1366 TEST(CompareToStringRight) { | 1370 TEST(CompareToStringRight) { |
1367 CHECK_FUNC_ERROR( | 1371 CHECK_FUNC_ERROR( |
1368 "function bar() { var x = 1; return (x < 'hi')|0; }\n" | 1372 "function bar() { var x = 1; return (x < 'hi')|0; }\n" |
1369 "function foo() { bar(); }", | 1373 "function foo() { bar(); }", |
1370 "asm: line 1: bad type on right side of comparison\n"); | 1374 "asm: line 1: left and right side of comparison must match type " |
| 1375 "and be signed, unsigned, float, or double\n"); |
1371 } | 1376 } |
1372 | 1377 |
1373 | 1378 |
1374 TEST(CompareMismatchInt32Float64) { | 1379 TEST(CompareMismatchInt32Float64) { |
1375 CHECK_FUNC_ERROR( | 1380 CHECK_FUNC_ERROR( |
1376 "function bar() { var x = 1; var y = 2.0; return (x < y)|0; }\n" | 1381 "function bar() { var x = 1; var y = 2.0; return (x < y)|0; }\n" |
1377 "function foo() { bar(); }", | 1382 "function foo() { bar(); }", |
1378 "asm: line 1: left and right side of comparison must match\n"); | 1383 "asm: line 1: left and right side of comparison must match type " |
| 1384 "and be signed, unsigned, float, or double\n"); |
1379 } | 1385 } |
1380 | 1386 |
1381 | 1387 |
1382 TEST(CompareMismatchInt32Uint32) { | 1388 TEST(CompareMismatchInt32Uint32) { |
1383 CHECK_FUNC_ERROR( | 1389 CHECK_FUNC_ERROR( |
1384 "function bar() { var x = 1; var y = 2; return ((x|0) < (y>>>0))|0; }\n" | 1390 "function bar() { var x = 1; var y = 2; return ((x|0) < (y>>>0))|0; }\n" |
1385 "function foo() { bar(); }", | 1391 "function foo() { bar(); }", |
1386 "asm: line 1: left and right side of comparison must match\n"); | 1392 "asm: line 1: left and right side of comparison must match type " |
| 1393 "and be signed, unsigned, float, or double\n"); |
1387 } | 1394 } |
1388 | 1395 |
1389 | 1396 |
1390 TEST(CompareMismatchInt32Float32) { | 1397 TEST(CompareMismatchInt32Float32) { |
1391 CHECK_FUNC_ERROR( | 1398 CHECK_FUNC_ERROR( |
1392 "function bar() { var x = 1; var y = 2.0; return (x < fround(y))|0; }\n" | 1399 "function bar() { var x = 1; var y = 2.0; return (x < fround(y))|0; }\n" |
1393 "function foo() { bar(); }", | 1400 "function foo() { bar(); }", |
1394 "asm: line 1: left and right side of comparison must match\n"); | 1401 "asm: line 1: left and right side of comparison must match type " |
| 1402 "and be signed, unsigned, float, or double\n"); |
1395 } | 1403 } |
1396 | 1404 |
1397 TEST(FunctionRepeated) { | 1405 TEST(FunctionRepeated) { |
1398 CHECK_FUNC_ERROR( | 1406 CHECK_FUNC_ERROR( |
1399 "function foo() { return 0; }\n" | 1407 "function foo() { return 0; }\n" |
1400 "function foo() { return 0; }", | 1408 "function foo() { return 0; }", |
1401 "asm: line 2: function repeated in module\n"); | 1409 "asm: line 2: function repeated in module\n"); |
1402 } | 1410 } |
1403 | 1411 |
1404 TEST(Float64ToInt32) { | 1412 TEST(Float64ToInt32) { |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { | 2547 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
2540 CHECK_VAR(x, Bounds(cache.kAsmDouble)); | 2548 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
2541 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); | 2549 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
2542 } | 2550 } |
2543 } | 2551 } |
2544 } | 2552 } |
2545 CHECK_SKIP(); | 2553 CHECK_SKIP(); |
2546 } | 2554 } |
2547 CHECK_FUNC_TYPES_END | 2555 CHECK_FUNC_TYPES_END |
2548 } | 2556 } |
OLD | NEW |