MCPcopy Create free account
hub / github.com/nodejs/node / ShiftTest

Function ShiftTest

deps/v8/test/mjsunit/constant-folding.js:190–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

188// Some tests of shifts that get into the corners in terms of coverage.
189// We generate different code for the case where the operand is a constant.
190function ShiftTest() {
191 var x = 123;
192 assertEquals(x, x >> 0);
193 assertEquals(x, x << 0);
194 assertEquals(x, x >>> 0);
195 assertEquals(61, x >> 1);
196 assertEquals(246, x << 1);
197 assertEquals(61, x >>> 1);
198 x = -123;
199 assertEquals(x, x >> 0);
200 assertEquals(x, x << 0);
201 assertEquals(0x10000 * 0x10000 + x, x >>> 0);
202 assertEquals(-62, x >> 1);
203 assertEquals(-246, x << 1);
204 assertEquals(0x10000 * 0x8000 - 62, x >>> 1);
205 // Answer is non-Smi so the subtraction is not folded in the code
206 // generator.
207 assertEquals(-0x40000001, -0x3fffffff - 2);
208
209 x = 123;
210 assertEquals(0, x & 0);
211
212 // Answer is non-smi and lhs of << is a temporary heap number that we can
213 // overwrite.
214 x = 123.0001;
215 assertEquals(1073741824, (x * x) << 30);
216 x = 123;
217 // Answer is non-smi and lhs of << is a temporary heap number that we think
218 // we can overwrite (but we can't because it's a Smi).
219 assertEquals(1073741824, (x * x) << 30);
220}
221
222
223test();

Callers 1

Calls 1

assertEqualsFunction · 0.50

Tested by

no test coverage detected