mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 14:30:27 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
40 lines
708 B
JavaScript
40 lines
708 B
JavaScript
function shouldBe(actual, expected)
|
|
{
|
|
if (actual !== expected)
|
|
throw new Error('bad value: ' + actual);
|
|
}
|
|
|
|
{
|
|
let i = 2;
|
|
let j = 3;
|
|
shouldBe(2 ** 3, 8);
|
|
shouldBe(i ** 3, 8);
|
|
shouldBe(2 ** j, 8);
|
|
shouldBe(i ** j, 8);
|
|
}
|
|
|
|
{
|
|
shouldBe(2 ** 3 ** 3, 134217728);
|
|
shouldBe(2 ** 3 + 3, 11);
|
|
shouldBe(2 ** 3 + 3 ** 3, 35);
|
|
shouldBe(2 ** 3 * 3, 24);
|
|
shouldBe(2 ** 3 * 3 ** 3, 216);
|
|
|
|
shouldBe(2 + 3 ** 3, 29);
|
|
shouldBe(2 * 3 ** 3, 54);
|
|
}
|
|
|
|
{
|
|
let i = 2;
|
|
i **= 4;
|
|
shouldBe(i, 16);
|
|
i **= 1 + 1;
|
|
shouldBe(i, 256);
|
|
}
|
|
|
|
for (let i = 0; i < 1e4; ++i) {
|
|
let a = Math.random();
|
|
let b = Math.random();
|
|
shouldBe(a ** b, Math.pow(a, b));
|
|
}
|