Skip to content

Commit 941a858

Browse files
author
Meghana Gupta
committed
Add tests
1 parent 91d82e1 commit 941a858

File tree

4 files changed

+118
-2
lines changed

4 files changed

+118
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
5
2+
5
3+
Done iterator1
4+
5+
5
6+
getter
7+
8+
getter
9+
10+
Done iterator2
11+
12+
5
13+
getter
14+
15+
getter
16+
17+
Done iterator3
18+
19+
obj1.prop1 getter
20+
obj1.prop1 getter
21+
obj1.prop1 getter
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
function next1(arr, len) {
7+
var obj = {done:true, value:undefined};
8+
if (len > 5) {
9+
// cannot fold, because obj not defined in localValueTable
10+
return obj;
11+
}
12+
return {done:false, value:arr[len]};
13+
}
14+
15+
function iterator1(x) {
16+
var arr = [0,1,2,3,4,5,6,7,8,9,10];
17+
var res = next1(arr, x);
18+
if (!res.done) {
19+
print(res.value);
20+
}
21+
}
22+
23+
iterator1(5);
24+
iterator1(100);
25+
iterator1(5);
26+
print("Done iterator1\n");
27+
28+
function next2(arr, len) {
29+
if (len > 5) {
30+
var obj = {done:true, value:undefined};
31+
Object.defineProperty(obj, "done", {get : function() {print("getter\n"); return true;}});
32+
return obj;
33+
}
34+
return {done:false, value:arr[len]};
35+
}
36+
37+
function iterator2(x) {
38+
var arr = [0,1,2,3,4,5,6,7,8,9,10];
39+
var res = next2(arr, x);
40+
if (!res.done) {
41+
print(res.value);
42+
}
43+
}
44+
45+
iterator2(5);
46+
iterator2(100);
47+
iterator2(200);
48+
print("Done iterator2\n");
49+
50+
function next3(arr, len) {
51+
if (len > 5) {
52+
return {get done() { print("getter\n"); return true;}, value:undefined};
53+
}
54+
return {done:false, value:arr[len]};
55+
}
56+
57+
function iterator3(x) {
58+
var arr = [0,1,2,3,4,5,6,7,8,9,10];
59+
var res = next3(arr, x);
60+
if (!res.done) {
61+
print(res.value);
62+
}
63+
}
64+
65+
iterator3(5);
66+
iterator3(100);
67+
iterator3(200);
68+
print("Done iterator3\n");
69+
70+
function test0() {
71+
var obj1 = {};
72+
var arrObj0 = {};
73+
var func0 = function (x) {
74+
with (arrObj0) {
75+
if (x > 100) {
76+
obj1.prop1 = (Object.defineProperty(obj1, 'prop1', { get: function () { WScript.Echo('obj1.prop1 getter'); return 3; }, configurable: true }));
77+
}
78+
else {
79+
obj1.prop1 = 3;
80+
}
81+
true ? obj1.prop1 : obj1.prop1;
82+
}
83+
};
84+
func0(200);
85+
func0(200);
86+
func0(100);
87+
}
88+
test0();

test/Optimizer/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,4 +1526,11 @@
15261526
<compile-flags> -loopinterpretcount:1 -bgjit- -maxsimplejitruncount:1 -maxinterpretcount:1 -oopjit-</compile-flags>
15271527
</default>
15281528
</test>
1529+
<test>
1530+
<default>
1531+
<files>bugsimplepathbrfoldgetter.js</files>
1532+
<baseline>bugsimplepathbrfoldgetter.baseline</baseline>
1533+
<tags>exclude_dynapogo,exclude_nonative</tags>
1534+
</default>
1535+
</test>
15291536
</regress-exe>

test/Optimizer/testsimplepathbrfold.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
100
22
TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 1 from Block 2 to Block 4 in func foo
3-
TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 2 from Block 4 to Block 3 in func foo
43
100
54
Done foo
65

@@ -10,6 +9,8 @@ TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 2 from B
109
Done bar
1110

1211
100
12+
TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 1 from Block 3 to Block 4 in func baz
13+
TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 2 from Block 3 to Block 5 in func baz
1314
100
1415
Done baz
1516

@@ -62,7 +63,6 @@ Done iterator
6263

6364
5
6465
TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 1 from Block 3 to Block 5 in func iterator2
65-
TRACE PathDependentBranchFolding: Can prove retarget of branch in Block 3 from Block 5 to Block 4 in func iterator2
6666
5
6767
Done iterator2
6868

0 commit comments

Comments
 (0)