summaryrefslogtreecommitdiff
path: root/test/psych/test_scalar_scanner.rb
diff options
context:
space:
mode:
authorTomer Brisker <tbrisker@gmail.com>2020-08-08 14:46:05 +0300
committerTomer Brisker <tbrisker@gmail.com>2020-08-08 14:46:05 +0300
commit6e0e7a1e9f83b85615f82d26c5bf1a7d66844a3b (patch)
treee82f82788b17d3e7fca1dcf62369abd652ac9982 /test/psych/test_scalar_scanner.rb
parent181a727c90cb1d320db5821bc16dc0bc34757935 (diff)
downloadpsych-6e0e7a1e9f83b85615f82d26c5bf1a7d66844a3b.tar.gz
Improve float scalar scanner
Previously, `+.inf` was not handled correctly. Additionally, the regexp was checking for inf and NaN, even though these cases are handled earlier in the condition. Added a few tests to ensure handling some missing cases.
Diffstat (limited to 'test/psych/test_scalar_scanner.rb')
-rw-r--r--test/psych/test_scalar_scanner.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index 1bd6488..ec67a33 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -66,6 +66,10 @@ module Psych
assert_equal(1 / 0.0, ss.tokenize('.inf'))
end
+ def test_scan_plus_inf
+ assert_equal(1 / 0.0, ss.tokenize('+.inf'))
+ end
+
def test_scan_minus_inf
assert_equal(-1 / 0.0, ss.tokenize('-.inf'))
end
@@ -133,5 +137,13 @@ module Psych
assert_equal 0x123456789abcdef, ss.tokenize('0x_12_,34,_56,_789abcdef')
assert_equal 0x123456789abcdef, ss.tokenize('0x12_,34,_56,_789abcdef__')
end
+
+ def test_scan_dot
+ assert_equal '.', ss.tokenize('.')
+ end
+
+ def test_scan_plus_dot
+ assert_equal '+.', ss.tokenize('+.')
+ end
end
end