v8/test/torque/test-torque.tq
peterwmwong e6238be3cb [torque]: Fix Labels with multiple parameters
Change-Id: I37ed9115c099f3d17f23a26348a1bbf5f773ee32
Reviewed-on: https://chromium-review.googlesource.com/1056668
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
Cr-Commit-Position: refs/heads/master@{#53136}
2018-05-13 17:07:25 +00:00

86 lines
1.9 KiB
Plaintext

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module test {
macro ElementsKindTestHelper1(kind: constexpr ElementsKind): bool {
if constexpr ((kind == UINT8_ELEMENTS) || (kind == UINT16_ELEMENTS)) {
return true;
} else {
return false;
}
}
macro ElementsKindTestHelper2(kind: constexpr ElementsKind): bool {
return ((kind == UINT8_ELEMENTS) || (kind == UINT16_ELEMENTS));
}
macro ElementsKindTestHelper3(kind: constexpr ElementsKind): constexpr bool {
return ((kind == UINT8_ELEMENTS) || (kind == UINT16_ELEMENTS));
}
macro LabelTestHelper1(): never
labels Label1 {
goto Label1;
}
macro LabelTestHelper2(): never
labels Label2(Smi) {
goto Label2(42);
}
macro LabelTestHelper3(): never
labels Label3(String, Smi) {
goto Label3('foo', 7);
}
macro TestConstexpr1() {
assert(convert<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
}
macro TestConstexprIf() {
assert(ElementsKindTestHelper1(UINT8_ELEMENTS));
assert(ElementsKindTestHelper1(UINT16_ELEMENTS));
assert(!ElementsKindTestHelper1(UINT32_ELEMENTS));
}
macro TestConstexprReturn() {
assert(convert<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
assert(convert<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
assert(!convert<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
assert(convert<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
}
macro TestGotoLabel(): Boolean {
try {
LabelTestHelper1() otherwise Label1;
}
label Label1 {
return True;
}
}
macro TestGotoLabelWithOneParameter(): Boolean {
try {
LabelTestHelper2() otherwise Label2;
}
label Label2(smi: Smi) {
assert(smi == 42);
return True;
}
}
macro TestGotoLabelWithTwoParameters(): Boolean {
try {
LabelTestHelper3() otherwise Label3;
}
label Label3(str: String, smi: Smi) {
assert(str == 'foo');
assert(smi == 7);
return True;
}
}
}