diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-09-21 09:14:51 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-09-22 18:29:25 +0200 |
commit | 0e7ddbd3d7e9439c67573b854c49cf82c398ae82 (patch) | |
tree | 2afe372acde921cb57ddb3444ff00c5adef8848c /deps/v8/test/torque | |
parent | 13245dc50da4cb7443c39ef6c68d419d5e6336d4 (diff) | |
download | node-new-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.gz |
deps: update V8 to 7.0.276.20
PR-URL: https://github.com/nodejs/node/pull/22754
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/torque')
-rw-r--r-- | deps/v8/test/torque/test-torque.tq | 171 |
1 files changed, 164 insertions, 7 deletions
diff --git a/deps/v8/test/torque/test-torque.tq b/deps/v8/test/torque/test-torque.tq index 1ed8e986b6..3c258607fc 100644 --- a/deps/v8/test/torque/test-torque.tq +++ b/deps/v8/test/torque/test-torque.tq @@ -98,10 +98,11 @@ module test { } macro LabelTestHelper4(flag: constexpr bool): never labels Label4, Label5 { - if - constexpr(flag) goto Label4; - else + if constexpr(flag) { + goto Label4; + } else { goto Label5; + } } macro CallLabelTestHelper4(flag: constexpr bool): bool { @@ -120,10 +121,11 @@ module test { let r1: bool = CallLabelTestHelper4(true); let r2: bool = CallLabelTestHelper4(false); - if (r1 && !r2) + if (r1 && !r2) { return True; - else + } else { return False; + } } macro GenericMacroTest<T : type>(param: T): Object { @@ -242,8 +244,17 @@ module test { } macro TestLocalConstBindings() { - const kSmi: Smi = 3; - check(kSmi == 3); + const x : constexpr int31 = 3; + const x_smi : Smi = x; + { + const x : Smi = x + from_constexpr<Smi>(1); + check(x == x_smi + 1); + const x_smi : Smi = x; + check(x == x_smi); + check(x == 4); + } + check(x_smi == 3); + check(x == x_smi); } struct TestStructA { @@ -289,4 +300,150 @@ module test { macro TestStruct4(): TestStructC { return TestStructC{TestStruct2(), TestStruct2()}; } + + // This macro tests different versions of the for-loop where some parts + // are (not) present. + macro TestForLoop() { + let sum: Smi = 0; + for (let i: Smi = 0; i < 5; ++i) sum += i; + check(sum == 10); + + sum = 0; + let j: Smi = 0; + for (; j < 5; ++j) sum += j; + check(sum == 10); + + sum = 0; + j = 0; + for (; j < 5;) sum += j++; + check(sum == 10); + + // Check that break works. No test expression. + sum = 0; + for (let i: Smi = 0;; ++i) { + if (i == 5) break; + sum += i; + } + check(sum == 10); + + sum = 0; + j = 0; + for (;;) { + if (j == 5) break; + sum += j; + j++; + } + check(sum == 10); + + // The following tests are the same as above, but use continue to skip + // index 3. + sum = 0; + for (let i: Smi = 0; i < 5; ++i) { + if (i == 3) continue; + sum += i; + } + check(sum == 7); + + sum = 0; + j = 0; + for (; j < 5; ++j) { + if (j == 3) continue; + sum += j; + } + check(sum == 7); + + sum = 0; + j = 0; + for (; j < 5;) { + if (j == 3) { + j++; + continue; + } + sum += j; + j++; + } + check(sum == 7); + + sum = 0; + for (let i: Smi = 0;; ++i) { + if (i == 3) continue; + if (i == 5) break; + sum += i; + } + check(sum == 7); + + sum = 0; + j = 0; + for (;;) { + if (j == 3) { + j++; + continue; + } + + if (j == 5) break; + sum += j; + j++; + } + check(sum == 7); + } + + macro TestSubtyping(x : Smi) { + const foo : Object = x; + } + + macro IncrementIfSmi<A : type>(x : A) : A { + typeswitch (x) { + case (x : Smi) { + return x + 1; + } case (o : A) { + return o; + } + } + } + + macro TypeswitchExample(x : Number | FixedArray) : int32 { + let result : int32 = 0; + typeswitch (IncrementIfSmi<(Number|FixedArray)>(x)) { + case (x : FixedArray) { + result = result + 1; + } case (Number) { + result = result + 2; + } + } + + result = result * 10; + + typeswitch (IncrementIfSmi<(Number|FixedArray)>(x)) { + case (x : Smi) { + result = result + convert<int32>(x); + } case (a : FixedArray) { + result = result + convert<int32>(a.length); + } case (x : HeapNumber) { + result = result + 7; + } + } + + return result; + } + + macro TestTypeswitch() { + check(TypeswitchExample(from_constexpr<Smi>(5)) == 26); + const a : FixedArray = AllocateZeroedFixedArray(3); + check(TypeswitchExample(a) == 13); + check(TypeswitchExample(from_constexpr<Number>(0.5)) == 27); + } + + macro ExampleGenericOverload<A: type>(o : Object) : A { + return o; + } + macro ExampleGenericOverload<A: type>(o : Smi) : A { + return o + 1; + } + + macro TestGenericOverload() { + const x_smi : Smi = 5; + const x_object : Object = x_smi; + check(ExampleGenericOverload<Smi>(x_smi) == 6); + check(unsafe_cast<Smi>(ExampleGenericOverload<Object>(x_object)) == 5); + } } |