Skip to content

Add test cases from sqlite/test/regexp1.test #5

Open
@fractaledmind

Description

@fractaledmind

I have extracted test cases from the SQLite test suite for the lexer. I originally wrote them using a basic helper method while I was building the lever. Now, they need to be converted into the MiniTest suite. Add a new describe block to the test/feather/test_lexer.rb file and file the code style already present. Here are the test cases:

# adapted from sqlite/test/regexp1.test
assert_tokenized_as(
  "SELECT 'xab' REGEXP 'a(b$|cd)'",
  [[:TK_SELECT, "SELECT"], [:TK_SPACE, " "], [:TK_STRING, "'xab'"], [:TK_SPACE, " "], [:TK_LIKE_KW, "REGEXP"], [:TK_SPACE, " "], [:TK_STRING, "'a(b$|cd)'"]]
)
assert_tokenized_as(
  "SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,30}$'",
  [[:TK_SELECT, "SELECT"], [:TK_SPACE, " "], [:TK_STRING, "'fooX'"], [:TK_SPACE, " "], [:TK_LIKE_KW, "REGEXP"], [:TK_SPACE, " "], [:TK_STRING, "'^[a-z][a-z0-9]{0,30}$'"]]
)
assert_tokenized_as(
  "SELECT 'foo' REGEXP '[a-z]'",
  [[:TK_SELECT, "SELECT"], [:TK_SPACE, " "], [:TK_STRING, "'foo'"], [:TK_SPACE, " "], [:TK_LIKE_KW, "REGEXP"], [:TK_SPACE, " "], [:TK_STRING, "'[a-z]'"]]
)
assert_tokenized_as(
  "SELECT char(0x61,0x7ff,0x62) REGEXP char(0x7ff)",
  [[:TK_SELECT, "SELECT"], [:TK_SPACE, " "], [:TK_ID, "char"], [:TK_LP, "("], [:TK_INTEGER, "0x61"], [:TK_COMMA, ","], [:TK_INTEGER, "0x7ff"], [:TK_COMMA, ","], [:TK_INTEGER, "0x62"], [:TK_RP, ")"], [:TK_SPACE, " "], [:TK_LIKE_KW, "REGEXP"], [:TK_SPACE, " "], [:TK_ID, "char"], [:TK_LP, "("], [:TK_INTEGER, "0x7ff"], [:TK_RP, ")"]]
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions