From 03cbea26f32419ed319b4db95b1dce41bcc7c052 Mon Sep 17 00:00:00 2001 From: Matt Monroe Date: Sat, 3 Oct 2020 02:09:24 -0400 Subject: [PATCH] Issue #1836 added underscore to binary number_pattern regex plus tests in s/src/javascript/tokenizer.js and test/data/javascript/tests.js modified: js/src/javascript/tokenizer.js modified: js/test/generated/beautify-javascript-tests.js modified: python/jsbeautifier/tests/generated/tests.py modified: test/data/javascript/tests.js --- js/src/javascript/tokenizer.js | 2 +- js/test/generated/beautify-javascript-tests.js | 2 ++ python/jsbeautifier/tests/generated/tests.py | 2 ++ test/data/javascript/tests.js | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js/src/javascript/tokenizer.js b/js/src/javascript/tokenizer.js index 6e346650..94662e1a 100644 --- a/js/src/javascript/tokenizer.js +++ b/js/src/javascript/tokenizer.js @@ -66,7 +66,7 @@ var TOKEN = { var directives_core = new Directives(/\/\*/, /\*\//); -var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/; +var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01_]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/; var digit = /[0-9]/; diff --git a/js/test/generated/beautify-javascript-tests.js b/js/test/generated/beautify-javascript-tests.js index 7bb597ba..c3c966bf 100644 --- a/js/test/generated/beautify-javascript-tests.js +++ b/js/test/generated/beautify-javascript-tests.js @@ -7170,6 +7170,8 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify, bt('a = 0b010011;'); bt('a = 0B010011;'); bt('a = 0b01001100001111;'); + bt('a = 0B010_0_11;'); + bt('a = 0b01_0011_0000_1111;'); bt('a=0b10e-5', 'a = 0b10 e - 5'); bt('a=0b10+4', 'a = 0b10 + 4'); bt('a=0B11+4', 'a = 0B11 + 4'); diff --git a/python/jsbeautifier/tests/generated/tests.py b/python/jsbeautifier/tests/generated/tests.py index 3ea33818..9aa51ded 100644 --- a/python/jsbeautifier/tests/generated/tests.py +++ b/python/jsbeautifier/tests/generated/tests.py @@ -6879,6 +6879,8 @@ class TestJSBeautifier(unittest.TestCase): bt('a = 0b010011;') bt('a = 0B010011;') bt('a = 0b01001100001111;') + bt('a = 0B010_0_11;') + bt('a = 0b01_0011_0000_1111;') bt('a=0b10e-5', 'a = 0b10 e - 5') bt('a=0b10+4', 'a = 0b10 + 4') bt('a=0B11+4', 'a = 0B11 + 4') diff --git a/test/data/javascript/tests.js b/test/data/javascript/tests.js index ad121549..5331e494 100644 --- a/test/data/javascript/tests.js +++ b/test/data/javascript/tests.js @@ -3981,6 +3981,8 @@ exports.test_data = { }, { unchanged: 'a = 0B010011;' }, { unchanged: 'a = 0b01001100001111;' }, + { unchanged: 'a = 0B010_0_11;' }, + { unchanged: 'a = 0b01_0011_0000_1111;' }, { input: 'a=0b10e-5', output: 'a = 0b10 e - 5' }, { input: 'a=0b10+4', output: 'a = 0b10 + 4' }, { input: 'a=0B11+4', output: 'a = 0B11 + 4' }, @@ -4803,7 +4805,7 @@ exports.test_data = { ] } ] - }, { + },{ // ======================================================= // New tests groups should be added above this line. // Everything below is a work in progress - converting