Skip to content

Bug with suffixes #1

@jrunning

Description

@jrunning

I think I've stumbled across a bug. I'm using RegexpTrie 0.2.0.

Take this example from the tests:

RegexpTrie.union("foo", "foobar", "foobaz")

I would expect this to produce a Regexp like, say, /foo(?:ba[rz])?/, but instead it produces /foo(?:)?/.

This is significant because I often use Regexp.union like this:

words = [ "foo", "foobar", "foobaz" ]
expr = /\b#{Regexp.union("foo", "foobar", "foobaz")}\b/ # => /\b(?-mix:foo|foobar|foobaz)\b/
assert(expr === "text foobar text")

But this doesn't work with RegexpTrie.union:

words = [ "foo", "foobar", "foobaz" ]
expr = /\b#{RegexpTrie.union("foo", "foobar", "foobaz")}\b/ # => /\b(?-mix:foo(?:)?)\b/
assert(expr === "text foobar text")
# => Test::Unit::AssertionFailedError: <false> is not true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions