diff --git a/lib/languages/red.txt b/lib/languages/red.txt new file mode 100644 index 0000000..5801b5e --- /dev/null +++ b/lib/languages/red.txt @@ -0,0 +1,8 @@ +!e +;\p +Red [\pj-->>]\pj +Red +[\pj-->>]\pj +comment [\pj-->>]\pj +comment +[\pj-->>]\pj +comment {\pj-->>}\pj +comment +{\pj-->>}\pj diff --git a/test/languages/red_test.rb b/test/languages/red_test.rb new file mode 100644 index 0000000..a19c50d --- /dev/null +++ b/test/languages/red_test.rb @@ -0,0 +1,49 @@ +require "test_helper" + +module SnippetExtractor + module Languages + class RedTest < Minitest::Test + def test_full_example + code = <<~CODE + Red [a-header] ; a comment + + ; single line comment + x: 1 ; line comment 1 + y: 11 + x: 2 ;-- line comment 2 + x: 3 ;@@ line comment 3 + + comment ['this + 'is 'multiline + 'comment] + + print "no comments!" + + comment {and this + as well} + + function add100 [x [integer!]] [ + " this should not count as comment " + { and neither + this } + ] + CODE + + expected = <<~CODE + x: 1 + y: 11 + x: 2 + x: 3 + + print "no comments!" + + function add100 [x [integer!]] [ + " this should not count as comment " + { and neither + CODE + + assert_equal expected, ExtractSnippet.(code, :red) + end + end + end +end