Created
April 28, 2018 23:47
-
-
Save avit/d4235c646082983fbc64c8b3cd5c72a7 to your computer and use it in GitHub Desktop.
Testing javascript regular expressions using a ruby test suite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'therubyracer' | |
js = V8::Context.new | |
matches = (<<-___).split("\n---\n") | |
123 | |
--- | |
abc | |
___ | |
pattern = DATA.reduce("") { |str, line| | |
str << line.partition('#')[0].strip | |
} | |
puts "Testing: /#{pattern}/", "---" | |
matches.each do |match| | |
puts match, js.eval(<<-___) | |
/#{pattern}/.test(#{match.inspect}); | |
___ | |
end | |
__END__ | |
\d+ # example expression |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment