Skip to content

Commit 95cc490

Browse files
committed
add Red language
1 parent 65b1f8b commit 95cc490

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

Diff for: lib/languages/red.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
!e
2+
;\p
3+
Red [\p-->>]\pj
4+
Red +[\p-->>]\pj
5+
comment [\p-->>]\pj
6+
comment +[\p-->>]\pj
7+
comment {\p-->>}\pj
8+
comment +{\p-->>}\pj

Diff for: test/languages/red_test.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require "test_helper"
2+
3+
module SnippetExtractor
4+
module Languages
5+
class RedTest < Minitest::Test
6+
def test_full_example
7+
code = <<~CODE
8+
Red [] ; 20 lines 10 code 6 comments 4 blanks
9+
10+
x: 1 ; line comment 1
11+
x: 2 ;-- line comment 2
12+
x: 3 ;@@ line comment 3
13+
14+
comment ['this
15+
'is 'multiline
16+
'comment]
17+
comment {and this
18+
as well}
19+
20+
function add100 [x [integer!]] [
21+
"; this should not count as comment "
22+
{ comment [and neither
23+
this] }
24+
]
25+
CODE
26+
27+
expected = <<~CODE
28+
x: 1
29+
x: 2
30+
x: 3
31+
function add100 [x [integer!]] [
32+
"; this should not count as comment "
33+
{ comment [and neither
34+
this] }
35+
]
36+
CODE
37+
38+
assert_equal expected, ExtractSnippet.(code, :red)
39+
end
40+
end
41+
end
42+
end

0 commit comments

Comments
 (0)