Actions
Bug #18449
closedBug in 3.1 regexp literals with \c
Description
This file passes on 2.7, 3.0, and fails (if you remove the skip
line) on 3.1:
#!/usr/bin/env ruby -w
require "minitest/autorun"
class TestRegexpCreation < Minitest::Test
R31 = RUBY_VERSION > "3.1"
def test_literal_equivalence
if R31 then
assert_equal(/\x03/, /\cC/) # wrong! (note the assert)
else
refute_equal(/\x03/, /\cC/)
end
end
def test_from_literal
re = /\cC/
assert_equal(/\cC/, re)
if R31 then
assert_equal "\\x03", re.source # wrong?
else
assert_equal "\\cC", re.source
end
end
def test_from_source
re = Regexp.new "\\cC"
assert_equal "\\cC", re.source
if R31 then # wrong!
skip
assert_equal(/\cC/, re) # can't be written to pass
assert_equal(/\x03/, re) # can't be written to pass
else
assert_equal(/\cC/, re)
end
end
end
# on 3.1:
#
# if written as:
#
# assert_equal(/\x03/, re)
#
# it fails with:
#
# 1) Failure:
# TestRegexpCreation#test_source [regexp31.rb:32]:
# Expected: /\x03/
# Actual: /\cC/
#
# but if written as:
#
# assert_equal(/\cC/, re)
#
# it ALSO fails with:
#
# 1) Failure:
# TestRegexpCreation#test_source [regexp31.rb:32]:
# Expected: /\x03/
# Actual: /\cC/
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0