Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: LayoutTests/fast/js/script-tests/read-modify-eval.js

Issue 20867002: Remove old tests that have been migrated to the v8 repo. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove unused script-tests as well Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 description(
2 'Tests whether eval() works inside statements that read and modify a value.'
3 );
4
5 function multTest()
6 {
7 var x = 1;
8 x *= eval('2');
9 return x == 2;
10 }
11
12 function divTest()
13 {
14 var x = 2;
15 x /= eval('2');
16 return x == 1;
17 }
18
19 function addTest()
20 {
21 var x = 0;
22 x += eval('1');
23 return x == 1;
24 }
25
26 function subTest()
27 {
28 var x = 0;
29 x -= eval('1');
30 return x == -1;
31 }
32
33 function lshiftTest()
34 {
35 var x = 1;
36 x <<= eval('1');
37 return x == 2;
38 }
39
40 function rshiftTest()
41 {
42 var x = 1;
43 x >>= eval('1');
44 return x == 0;
45 }
46
47 function urshiftTest()
48 {
49 var x = 1;
50 x >>>= eval('1');
51 return x == 0;
52 }
53
54 function andTest()
55 {
56 var x = 1;
57 x &= eval('1');
58 return x == 1;
59 }
60
61 function xorTest()
62 {
63 var x = 0;
64 x ^= eval('1');
65 return x == 1;
66 }
67
68 function orTest()
69 {
70 var x = 0;
71 x |= eval('1');
72 return x == 1;
73 }
74
75 function modTest()
76 {
77 var x = 4;
78 x %= eval('3');
79 return x == 1;
80 }
81
82 function preIncTest()
83 {
84 var x = { value: 0 };
85 ++eval('x').value;
86 return x.value == 1;
87 }
88
89 function preDecTest()
90 {
91 var x = { value: 0 };
92 --eval('x').value;
93 return x.value == -1;
94 }
95
96 function postIncTest()
97 {
98 var x = { value: 0 };
99 eval('x').value++;
100 return x.value == 1;
101 }
102
103 function postDecTest()
104 {
105 var x = { value: 0 };
106 eval('x').value--;
107 return x.value == -1;
108 }
109
110 function primitiveThisTest()
111 {
112 // Test that conversion of this is persistant over multiple calls to eval,
113 // even where 'this' is not directly used within the function.
114 eval('this.value = "Seekrit message";');
115 return eval('this.value') === "Seekrit message";
116 }
117
118 function strictThisTest()
119 {
120 // In a strict mode function primitive this values are not converted, so
121 // the property access in the first eval is writing a value to a temporary
122 // object. This throws, per section 8.7.2.
123 "use strict";
124 eval('this.value = "Seekrit message";');
125 return eval('this.value') === undefined;
126 }
127
128 shouldBeTrue('multTest();');
129 shouldBeTrue('divTest();');
130 shouldBeTrue('addTest();');
131 shouldBeTrue('subTest();');
132 shouldBeTrue('lshiftTest();');
133 shouldBeTrue('rshiftTest();');
134 shouldBeTrue('urshiftTest();');
135 shouldBeTrue('andTest();');
136 shouldBeTrue('xorTest();');
137 shouldBeTrue('orTest();');
138 shouldBeTrue('modTest();');
139
140 shouldBeTrue('preIncTest();');
141 shouldBeTrue('preDecTest();');
142 shouldBeTrue('postIncTest();');
143 shouldBeTrue('postDecTest();');
144
145 shouldBeTrue('primitiveThisTest.call(1);');
146 shouldThrow('strictThisTest.call(1);');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698