ruby-changes:67497
From: Alexandr <ko1@a...>
Date: Tue, 31 Aug 2021 19:36:32 +0900 (JST)
Subject: [ruby-changes:67497] 44353d0dee (master): [ruby/psych] add more tests
https://git.ruby-lang.org/ruby.git/commit/?id=44353d0dee From 44353d0dee76a547629a6ab978fdaead9b5f79fb Mon Sep 17 00:00:00 2001 From: Alexandr Opak <opak.alexandr@g...> Date: Fri, 29 Jan 2021 14:10:04 +0100 Subject: [ruby/psych] add more tests https://github.com/ruby/psych/commit/8f71222bf3 --- ext/psych/lib/psych/scalar_scanner.rb | 8 ++++---- test/psych/test_scalar_scanner.rb | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index eecd46e..383a8ac 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -13,10 +13,10 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/scalar_scanner.rb#L13 FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10))$/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 f43d0f1..cac8b8f 100644 --- a/test/psych/test_scalar_scanner.rb +++ b/test/psych/test_scalar_scanner.rb @@ -115,11 +115,15 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_scalar_scanner.rb#L115 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/