summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandr Opak <opak.alexandr@gmail.com>2021-01-29 14:10:04 +0100
committerAlexandr Opak <opak.alexandr@gmail.com>2021-01-29 14:10:04 +0100
commit8f71222bf3c73f910da467e75d4c7231005bc8b0 (patch)
treec47d86c50b80873d1ce9c587014ed07aaf5c40ea
parentebb0cbded12f12670a870998151fba3c099fc997 (diff)
downloadpsych-8f71222bf3c73f910da467e75d4c7231005bc8b0.tar.gz
add more tests
-rw-r--r--lib/psych/scalar_scanner.rb8
-rw-r--r--test/psych/test_scalar_scanner.rb8
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb
index 47f83b6..f9805a4 100644
--- a/lib/psych/scalar_scanner.rb
+++ b/lib/psych/scalar_scanner.rb
@@ -14,10 +14,10 @@ module Psych
|\.(nan|NaN|NAN)(?# not a number))$/x
# Taken from http://yaml.org/type/int.html
- INTEGER = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
- |[-+]?0[0-7_,]+ (?# base 8)
- |[-+]?(?:\d|[1-9][0-9_,]*[^_]) (?# base 10)
- |[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
+ INTEGER = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
+ |[-+]?0[0-7_,]+ (?# base 8)
+ |[-+]?(?:0|[1-9]([0-9]|,[0-9]|_[0-9])*) (?# base 10)
+ |[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
attr_reader :class_loader
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index c17fd17..2cd129e 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -111,11 +111,15 @@ module Psych
end
def test_scan_strings_starting_with_underscores
- assert_equal "_100", ss.tokenize('_100')
+ assert_equal '_100', ss.tokenize('_100')
+ end
+
+ def test_scan_strings_starting_with_number
+ assert_equal '450D', ss.tokenize('450D')
end
def test_scan_strings_ending_with_underscores
- assert_equal "100_", ss.tokenize('100_')
+ assert_equal '100_', ss.tokenize('100_')
end
def test_scan_int_commas_and_underscores