Skip to content

add Red language #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/languages/red.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!e
;\p
Red [\pj-->>]\pj
Red +[\pj-->>]\pj
comment [\pj-->>]\pj
comment +[\pj-->>]\pj
comment {\pj-->>}\pj
comment +{\pj-->>}\pj
49 changes: 49 additions & 0 deletions test/languages/red_test.rb
Original file line number Diff line number Diff line change
@@ -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