Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions spec/std/match_data_spec.cr
Original file line number Diff line number Diff line change
@@ -49,8 +49,7 @@ describe "Regex::MatchData" do
end

it "captures duplicated named group" do
# TODO: replace with regexp literal after next version release
re = Regex.new "(?:(?<g1>foo)|(?<g1>bar))*"
re = /(?:(?<g1>foo)|(?<g1>bar))*/

("foo" =~ re).should eq(0)
$~["g1"].should eq("foo")
@@ -116,8 +115,7 @@ describe "Regex::MatchData" do
end

it "captures duplicated named group" do
# TODO: replace with regexp literal after next version release
re = Regex.new "(?:(?<g1>foo)|(?<g1>bar))*"
re = /(?:(?<g1>foo)|(?<g1>bar))*/

("foo" =~ re).should eq(0)
$~["g1"]?.should eq("foo")
@@ -203,8 +201,7 @@ describe "Regex::MatchData" do
end

it "gets a hash of named captures with duplicated name" do
# TODO: replace with regexp literal after next version release
"Crystal".match(Regex.new "(?<name>Cr)y(?<name>s)").not_nil!.named_captures.should eq({"name" => "s"})
"Crystal".match(/(?<name>Cr)y(?<name>s)/).not_nil!.named_captures.should eq({"name" => "s"})
end
end

@@ -252,8 +249,7 @@ describe "Regex::MatchData" do
end

it "converts into a hash with duplicated names" do
# TODO: replace with regexp literal after next version release
"Crystal".match(Regex.new "(Cr)(?<name>s)?(yst)?(?<name>al)?").not_nil!.to_h.should eq({
"Crystal".match(/(Cr)(?<name>s)?(yst)?(?<name>al)?/).not_nil!.to_h.should eq({
0 => "Crystal",
1 => "Cr",
"name" => "al",

0 comments on commit fd55e8d

Please sign in to comment.