Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 486560d

Browse files
committed
tweaks
1 parent 4019cc0 commit 486560d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

‎lib/regexp_trie.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def add(str)
2626
entry[c] ||= {}
2727
entry = entry[c]
2828
end
29-
entry[''] = true# terminator
29+
entry[:end] = true
3030
self
3131
end
3232

@@ -42,7 +42,7 @@ def to_regexp(option = nil)
4242
private
4343

4444
def build(entry)
45-
return nil if entry[''] && entry.size == 1
45+
return nil if entry[:end] && entry.size == 1
4646

4747
alt = []
4848
cc = []

‎test/regexp_trie_test.rb‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ def test_version_number
66
refute_nil ::RegexpTrie::VERSION
77
end
88

9-
def test_union
9+
def test_union_1
1010
re = RegexpTrie.union("foo", "bar", "baz")
1111
assert { re === "foo" }
1212
assert { re === "bar" }
1313
assert { re === "baz" }
1414
assert { !(re === "FOO") }
1515
end
1616

17+
def test_union_2
18+
re = RegexpTrie.union("foo", "foobar", "foobaz")
19+
assert { re === "foo" }
20+
assert { re === "foobar" }
21+
assert { re === "foobaz" }
22+
assert { !(re === "bar") }
23+
assert { !(re === "baz") }
24+
end
25+
1726
def test_union_ignorecase
1827
re = RegexpTrie.union("foo", "bar", "baz", option: Regexp::IGNORECASE)
1928
assert { re === 'foo' }

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /