MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix else if

+68 -2
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.0.8.26') 77 + version_conf.set('ANT_VERSION', '0.0.8.27') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+9 -1
src/ant.c
··· 5626 5626 5627 5627 static jsval_t js_block_or_stmt(struct js *js) { 5628 5628 if (next(js) == TOK_LBRACE) return js_block(js, !(js->flags & F_NOEXEC)); 5629 + uint8_t stmt_tok = js->tok; 5629 5630 jsval_t res = resolveprop(js, js_stmt(js)); 5630 - js->consumed = 0; 5631 + bool is_block_stmt = ( 5632 + stmt_tok == TOK_FUNC || stmt_tok == TOK_CLASS || 5633 + stmt_tok == TOK_IF || stmt_tok == TOK_WHILE || 5634 + stmt_tok == TOK_DO || stmt_tok == TOK_FOR || 5635 + stmt_tok == TOK_SWITCH || stmt_tok == TOK_TRY || 5636 + stmt_tok == TOK_LBRACE || stmt_tok == TOK_ASYNC 5637 + ); 5638 + if (!is_block_stmt) js->consumed = 0; 5631 5639 return res; 5632 5640 } 5633 5641
+58
tests/test_numeric_separators.cjs
··· 1 + console.log('=== Numeric Separator Tests ===\n'); 2 + 3 + // Test 1: Decimal separators 4 + console.log('Test 1: Decimal separators'); 5 + console.log('1_000:', 1_000); 6 + console.log('1_000_000:', 1_000_000); 7 + console.log('86_400_000:', 86_400_000); 8 + console.log('1_000 === 1000:', 1_000 === 1000 ? 'PASS' : 'FAIL'); 9 + console.log('1_000_000 === 1000000:', 1_000_000 === 1000000 ? 'PASS' : 'FAIL'); 10 + console.log('86_400_000 === 86400000:', 86_400_000 === 86400000 ? 'PASS' : 'FAIL'); 11 + 12 + // Test 2: Hexadecimal separators 13 + console.log('\nTest 2: Hexadecimal separators'); 14 + console.log('0xFF_FF:', 0xFF_FF); 15 + console.log('0xDE_AD_BE_EF:', 0xDE_AD_BE_EF); 16 + console.log('0xFF_AA_BB:', 0xFF_AA_BB); 17 + console.log('0xFF_FF === 65535:', 0xFF_FF === 65535 ? 'PASS' : 'FAIL'); 18 + console.log('0xDE_AD_BE_EF === 3735928559:', 0xDE_AD_BE_EF === 3735928559 ? 'PASS' : 'FAIL'); 19 + 20 + // Test 3: Binary separators 21 + console.log('\nTest 3: Binary separators'); 22 + console.log('0b1010_1010:', 0b1010_1010); 23 + console.log('0b1111_0000_1111_0000:', 0b1111_0000_1111_0000); 24 + console.log('0b1010_1010 === 170:', 0b1010_1010 === 170 ? 'PASS' : 'FAIL'); 25 + console.log('0b1111_0000_1111_0000 === 61680:', 0b1111_0000_1111_0000 === 61680 ? 'PASS' : 'FAIL'); 26 + 27 + // Test 4: Octal separators 28 + console.log('\nTest 4: Octal separators'); 29 + console.log('0o77_00:', 0o77_00); 30 + console.log('0o123_456:', 0o123_456); 31 + console.log('0o77_00 === 4032:', 0o77_00 === 4032 ? 'PASS' : 'FAIL'); 32 + console.log('0o123_456 === 42798:', 0o123_456 === 42798 ? 'PASS' : 'FAIL'); 33 + 34 + // Test 5: Floating point separators 35 + console.log('\nTest 5: Floating point separators'); 36 + console.log('1_000.5:', 1_000.5); 37 + console.log('1_000.123_456:', 1_000.123_456); 38 + console.log('1_000.5 === 1000.5:', 1_000.5 === 1000.5 ? 'PASS' : 'FAIL'); 39 + console.log('1_000.123_456 === 1000.123456:', 1_000.123_456 === 1000.123456 ? 'PASS' : 'FAIL'); 40 + 41 + // Test 6: Mixed expressions 42 + console.log('\nTest 6: Mixed expressions'); 43 + const sum = 1_000 + 2_000 + 3_000; 44 + console.log('1_000 + 2_000 + 3_000 =', sum); 45 + console.log('Sum === 6000:', sum === 6000 ? 'PASS' : 'FAIL'); 46 + 47 + const product = 10_00 * 10_0; 48 + console.log('10_00 * 10_0 =', product); 49 + console.log('Product === 100000:', product === 100000 ? 'PASS' : 'FAIL'); 50 + 51 + // Test 7: Comparison with regular literals 52 + console.log('\nTest 7: Comparison with regular literals'); 53 + console.log('1_2_3_4_5 === 12345:', 1_2_3_4_5 === 12345 ? 'PASS' : 'FAIL'); 54 + console.log('0xA_B_C === 0xABC:', 0xA_B_C === 0xABC ? 'PASS' : 'FAIL'); 55 + console.log('0b1_0_1_0 === 0b1010:', 0b1_0_1_0 === 0b1010 ? 'PASS' : 'FAIL'); 56 + console.log('0o7_7_7 === 0o777:', 0o7_7_7 === 0o777 ? 'PASS' : 'FAIL'); 57 + 58 + console.log('\n=== All numeric separator tests completed ===');