MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1// Test exponentiation operator
2console.log('Exponentiation tests:');
3console.log('2 ** 3 =', 2 ** 3); // Should be 8
4console.log('5 ** 2 =', 5 ** 2); // Should be 25
5console.log('10 ** 0 =', 10 ** 0); // Should be 1
6console.log('2 ** 10 =', 2 ** 10); // Should be 1024
7console.log('3 ** 3 =', 3 ** 3); // Should be 27
8
9// Test bit shift operators
10console.log('\nBit shift tests:');
11console.log('8 << 2 =', 8 << 2); // Should be 32 (8 * 4)
12console.log('32 >> 2 =', 32 >> 2); // Should be 8 (32 / 4)
13console.log('1 << 5 =', 1 << 5); // Should be 32
14console.log('64 >> 3 =', 64 >> 3); // Should be 8
15
16// Test bitwise operators
17console.log('\nBitwise tests:');
18console.log('12 & 10 =', 12 & 10); // Should be 8 (binary: 1100 & 1010 = 1000)
19console.log('12 | 10 =', 12 | 10); // Should be 14 (binary: 1100 | 1010 = 1110)
20console.log('12 ^ 10 =', 12 ^ 10); // Should be 6 (binary: 1100 ^ 1010 = 0110)
21console.log('~5 =', ~5); // Should be -6
22
23// Test combined operations
24console.log('\nCombined operations:');
25console.log('2 ** 3 + 4 =', 2 ** 3 + 4); // Should be 12
26console.log('(2 + 3) ** 2 =', (2 + 3) ** 2); // Should be 25
27console.log('2 << 3 >> 1 =', 2 << 3 >> 1); // Should be 8
28
29// Test with negative numbers
30console.log('\nNegative number tests:');
31console.log('(-2) ** 3 =', (-2) ** 3); // Should be -8
32console.log('-8 >> 1 =', -8 >> 1); // Should be -4