Add Type Infer Test Case

Description:
1.Add type infer test cases for bitwise_op, callfunctions, ldobjbyvalue and logic_op

Issue:
https://gitee.com/openharmony/ark_js_runtime/issues/I5B78L

Signed-off-by: huoqingyi <huoqingyi@huawei.com>
Change-Id: I486f6f91a32e1c7caa2446b12b8e6b33db8d47fe
This commit is contained in:
huoqingyi 2022-06-08 01:02:53 +08:00
parent 471bc0ba6e
commit 6a99d6002d
35 changed files with 653 additions and 18 deletions

View File

@ -2202,7 +2202,7 @@ void BytecodeCircuitBuilder::NewReturn(BytecodeRegion &bb, const uint8_t *pc, Ga
auto gate = circuit_.NewGate(OpCode(OpCode::RETURN), 0,
{ state, depend, Circuit::NullGate(),
Circuit::GetCircuitRoot(OpCode(OpCode::RETURN_LIST)) },
GateType::Empty());
GateType::AnyType());
jsgateToBytecode_[gate] = {bb.id, pc};
} else if (static_cast<EcmaOpcode>(bytecodeInfo.opcode) == EcmaOpcode::RETURNUNDEFINED_PREF) {
// handle returnundefined bytecode
@ -2213,7 +2213,7 @@ void BytecodeCircuitBuilder::NewReturn(BytecodeRegion &bb, const uint8_t *pc, Ga
auto gate = circuit_.NewGate(OpCode(OpCode::RETURN), 0,
{ state, depend, constant,
Circuit::GetCircuitRoot(OpCode(OpCode::RETURN_LIST)) },
GateType::Empty());
GateType::AnyType());
jsgateToBytecode_[gate] = {bb.id, pc};
}
}

View File

@ -24,4 +24,59 @@ bool Type::IsBitset() const
}
Type::~Type() {}
std::string GateType::GetTypeStr() const
{
GlobalTSTypeRef gt = GlobalTSTypeRef(GetType());
ASSERT(gt.GetFlag() == 0);
if (IsPrimitiveTypeKind()) {
auto primitive = static_cast<TSPrimitiveType>(gt.GetLocalId());
switch (primitive) {
case TSPrimitiveType::ANY:
return "any";
case TSPrimitiveType::NUMBER:
return "number";
case TSPrimitiveType::BOOLEAN:
return "boolean";
case TSPrimitiveType::VOID_TYPE:
return "void";
case TSPrimitiveType::STRING:
return "string";
case TSPrimitiveType::SYMBOL:
return "symbol";
case TSPrimitiveType::NULL_TYPE:
return "null";
case TSPrimitiveType::UNDEFINED:
return "undefined";
case TSPrimitiveType::INT:
return "int";
case TSPrimitiveType::BIG_INT:
return "big_int";
default:
break;
}
}
auto typeKind = static_cast<TSTypeKind>(gt.GetKind());
switch (typeKind) {
case TSTypeKind::CLASS:
return "class";
case TSTypeKind::CLASS_INSTANCE:
return "class_instance";
case TSTypeKind::FUNCTION:
return "function";
case TSTypeKind::UNION:
return "union";
case TSTypeKind::ARRAY:
return "array";
case TSTypeKind::OBJECT:
return "object";
case TSTypeKind::IMPORT:
return "import";
case TSTypeKind::INTERFACE_KIND:
return "interface";
default:
break;
}
return "gatetype:" + std::to_string(gt.GetType());
}
}; // namespace panda::ecmascript::kungfu

View File

@ -124,6 +124,13 @@ public:
return GateType(TSPrimitiveType::BIG_INT);
}
bool inline IsTSType() const
{
GlobalTSTypeRef gt = GlobalTSTypeRef(GetType());
// 0: TS type
return gt.GetFlag() == 0;
}
bool inline IsAnyType() const
{
return type_ == static_cast<uint32_t>(TSPrimitiveType::ANY);
@ -267,6 +274,8 @@ public:
return type_ >= other.type_;
}
std::string GetTypeStr() const;
private:
uint32_t type_ {0};
};

View File

@ -65,13 +65,15 @@ void TypeInfer::TypeInferPrint() const
const auto &gateList = circuit_->GetAllGates();
std::string log("TestInfer:");
for (const auto &gate : gateList) {
auto op = gateAccessor_.GetOpCode(gate);
if (op == OpCode::JS_BYTECODE) {
log += "&" + builder_->GetBytecodeStr(gate) + ":";
auto gateType = gateAccessor_.GetGateType(gate);
auto type = gateType.GetType() > GlobalTSTypeRef::TS_TYPE_RESERVED_COUNT ? "INF"
: std::to_string(gateType.GetType());
log += type;
auto type = gateAccessor_.GetGateType(gate);
if (ShouldInfer(gate) && type.IsTSType() && !type.IsAnyType()) {
auto op = gateAccessor_.GetOpCode(gate);
if (op == OpCode::VALUE_SELECTOR) {
log += "&" + op.Str() + ":";
} else {
log += "&" + builder_->GetBytecodeStr(gate) + ":";
}
log += type.GetTypeStr();
}
}
COMPILER_LOG(INFO) << std::dec << log;
@ -93,7 +95,7 @@ bool TypeInfer::UpdateType(GateRef gate, const GlobalTSTypeRef &typeRef)
return UpdateType(gate, type);
}
bool TypeInfer::ShouldInfer(const GateRef gate)
bool TypeInfer::ShouldInfer(const GateRef gate) const
{
auto op = gateAccessor_.GetOpCode(gate);
// handle phi gates
@ -104,9 +106,9 @@ bool TypeInfer::ShouldInfer(const GateRef gate)
op == OpCode::CONSTANT ||
op == OpCode::RETURN) {
auto gateToBytecode = builder_->GetGateToBytecode();
// handle gates generated by ecma.* bytecodes
// handle gates generated by ecma.* bytecodes (not including Jump)
if (gateToBytecode.find(gate) != gateToBytecode.end()) {
return true;
return !builder_->GetByteCodeInfo(gate).IsJump();
}
}
return false;

View File

@ -40,7 +40,7 @@ public:
private:
bool UpdateType(GateRef gate, const GateType type);
bool UpdateType(GateRef gate, const GlobalTSTypeRef &typeRef);
bool ShouldInfer(const GateRef gate);
bool ShouldInfer(const GateRef gate) const;
bool Infer(GateRef gate);
bool InferPhiGate(GateRef gate);
bool SetNumberType(GateRef gate);

View File

@ -113,7 +113,7 @@ def judge_output(args):
if "TestInfer:" in item:
err_list.append(item.split("&")[1:])
expect_output = expect_output.replace('\n', '')
expect_list = [elements.split(",") for elements in expect_output.split("[")]
expect_list = [elements.split(",") for elements in expect_output.split("----")]
for obj1, obj2 in zip(err_list, expect_list):
if not isSubSequence(obj1, obj2):
print(">>>>> Expect :", end = " ")

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -13,5 +13,16 @@
group("ark_typeinfer_test") {
testonly = true
deps = [ "ldobjbyname:ldobjbynameAotTypeInferAction" ]
deps = [
"bitwise_op:bitwise_opAotTypeInferAction",
"callarg0dyn:callarg0dynAotTypeInferAction",
"callarg1dyn:callarg1dynAotTypeInferAction",
"callargs2dyn:callargs2dynAotTypeInferAction",
"callargs3dyn:callargs3dynAotTypeInferAction",
"callirangedyn:callirangedynAotTypeInferAction",
"callithisrange:callithisrangeAotTypeInferAction",
"ldobjbyname:ldobjbynameAotTypeInferAction",
"ldobjbyvalue:ldobjbyvalueAotTypeInferAction",
"logic_op:logic_opAotTypeInferAction",
]
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("bitwise_op") {
deps = []
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
let x:number = 123;
let y:number = 2;
let andRes = x & y;
typeof(andRes);
let orRes = x | y;
typeof(orRes);
let xorRes = x ^ y;
typeof(xorRes);
let shlRes = x << y;
typeof(shlRes);
let ashrRes = x >> y;
typeof(ashrRes);
let shrRes = x >>> y;
typeof(shrRes);
let notRes = ~x;
typeof(notRes);
}

View File

@ -0,0 +1,19 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AND2DYN:number,
OR2DYN:number,
XOR2DYN:number,
SHL2DYN:number,
ASHR2DYN:number,
SHR2DYN:number

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("callarg0dyn") {
deps = []
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
function foo():string
{
return "pass";
}
typeof(foo());
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CALLARG0DYN:string

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("callarg1dyn") {
deps = []
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
function foo(v:number):number
{
return v + 1;
}
typeof(foo(0));
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CALLARG1DYN:number

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("callargs2dyn") {
deps = []
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
function foo(flag1:boolean, flag2:boolean):boolean
{
return flag1 && flag2;
}
typeof(foo(true, false));
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CALLARGS2DYN:boolean

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("callargs3dyn") {
deps = []
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
function foo(v1:number, v2:number, v3:number):number[]
{
let arr:number[] = [v1, v2, v3];
return arr;
}
typeof(foo(0, 1, 2));
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CALLARGS3DYN:array

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("callirangedyn") {
deps = []
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
class A {
v1:number;
v2:string;
v3:boolean;
v4:number;
constructor(v1:number, v2:string, v3:boolean, v4:number) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
}
}
function foo(v1:number, v2:string, v3:boolean, v4:number):A
{
let a = new A(v1, v2, v3, v4);
return a;
}
typeof(foo(0, "1", true, 3));
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CALLIRANGEDYN:class_instance

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("callithisrange") {
deps = []
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
class A {
v:number;
constructor(v:number) {
this.v = v;
}
fun(value:number):number {
return this.v + value;
}
fun1():void {
this.v += 1;
}
fun2():string {
return "hello";
}
fun3():boolean {
return true;
}
}
let a = new A(1);
typeof(a.fun(2));
typeof(a.fun1());
typeof(a.fun2());
typeof(a.fun3());
}

View File

@ -0,0 +1,17 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CALLITHISRANGEDYN:number,
CALLITHISRANGEDYN:void,
CALLITHISRANGEDYN:string,
CALLITHISRANGEDYN:boolean

View File

@ -11,5 +11,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
LDLEXENVDYN:0,LDA_STR:4,DEFINECLASSWITHBUFFER:INF,LDA_STR:4,LDOBJBYNAME:4,TYPEOFDYN:4
[LDLEXENVDYN:0
LDOBJBYNAME:string

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("ldobjbyvalue") {
deps = []
}

View File

@ -0,0 +1,16 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LDOBJBYVALUE:string,
LDOBJBYVALUE:number,
LDOBJBYVALUE:boolean

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
let arr1:string[] = ["a", "b", "c"];
let arr2:number[] = [1, 2, 3, 4];
let arr3:boolean[] = [true, false, false];
let t = 1;
typeof(arr1[t]);
typeof(arr2[t]);
typeof(arr3[t]);
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//ark/js_runtime/test/test_helper.gni")
host_typeinfer_test_action("logic_op") {
deps = []
}

View File

@ -0,0 +1,21 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GREATEREQDYN:boolean,
GREATERDYN:boolean,
LESSDYN:boolean,
LESSEQDYN:boolean,
EQDYN:boolean,
NOTEQDYN:boolean,
STRICTEQDYN:boolean,
STRICTNOTEQDYN:boolean

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
let num1:number = 1;
let num2:number = 2;
typeof(num1 >= num2);
typeof(num1 > num2);
typeof(num1 < num2);
typeof(num1 <= num2);
typeof(num1 == num2);
typeof(num1 != num2);
typeof(num1 === num2);
typeof(num1 !== num2);
}