We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ irb -r psych
irb(main):001:0> Psych.load(Psych.dump(/\d/)) == /\d/ => true irb(main):002:0> Psych.load(Psych.dump(/\//)) == /\// => false
$ cat psych_regexp.rb
# frozen_string_literal: true require 'psych' require 'test/unit' class TestPyschRegexpDumpLoad < Test::Unit::TestCase def test_psych_version assert '3.1.0', Psych::VERSION end def test_dump_load_regexp_no_escape assert_equal "--- !ruby/regexp /^[0-9]+/\n", Psych.dump(/^[0-9]+/) assert_equal /^[0-9]+/, Psych.load(Psych.dump(/^[0-9]+/)) end def test_dump_load_regexp_with_slash assert_equal "--- !ruby/regexp /^\\//\n", Psych.dump(/^\//) assert_equal /^\//, Psych.load(Psych.dump(/^\//)) end end
$ ruby psych_regexp.rb
Loaded suite psych_regexp Started .F ===================================================================================================================================================================================== 15: 16: def test_dump_load_regexp_with_slash 17: assert_equal "--- !ruby/regexp /^\\//\n", Psych.dump(/^\//) => 18: assert_equal /^\//, Psych.load(Psych.dump(/^\//)) 19: end 20: end psych_regexp.rb:18:in `test_dump_load_regexp_with_slash' </^\//> expected but was </^\//> diff: /^\// Failure: test_dump_load_regexp_with_slash(TestPyschRegexpDumpLoad) ===================================================================================================================================================================================== . Finished in 0.006877 seconds. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3 tests, 5 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 66.6667% passed ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 436.24 tests/s, 727.06 assertions/s
Test passed
The text was updated successfully, but these errors were encountered:
They have different source ...
irb(main):020:0> /\//.source => "/" irb(main):021:0> Psych.load(Psych.dump(/\//)).source => "\\/"
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Problem
$ irb -r psych
STR
Run
Actual Result
Expected Result
Test passed
The text was updated successfully, but these errors were encountered: