Skip to content

Commit 1be0366

Browse files
authored
add jq language (#59)
add jq language
1 parent ebee2da commit 1be0366

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

lib/languages/jq.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!e stop_at_first_loc
2+
#\p

test/languages/jq_test.rb

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require "test_helper"
2+
3+
module SnippetExtractor
4+
module Languages
5+
class JqTest < Minitest::Test
6+
def test_no_comments
7+
code = <<~CODE
8+
{a: "foo", b: "bar"}
9+
CODE
10+
11+
expected = <<~CODE
12+
{a: "foo", b: "bar"}
13+
CODE
14+
15+
assert_equal expected, ExtractSnippet.(code, :ruby)
16+
end
17+
18+
def test_full_example
19+
code = <<~CODE
20+
# This is a file
21+
# With some comments in it
22+
23+
# And a blank line ⬆️
24+
25+
# And then eventually the code
26+
def afunc: 42 ;
27+
28+
afunc
29+
CODE
30+
31+
expected = <<~CODE
32+
def afunc: 42 ;
33+
34+
afunc
35+
CODE
36+
37+
assert_equal expected, ExtractSnippet.(code, :jq)
38+
end
39+
40+
def test_stop_at_first_loc
41+
code = <<~CODE
42+
# a comment should be removed
43+
{a: "foo", b: "bar"}
44+
# a comment should remain
45+
CODE
46+
47+
expected = <<~CODE
48+
{a: "foo", b: "bar"}
49+
# a comment should remain
50+
CODE
51+
52+
assert_equal expected, ExtractSnippet.(code, :ruby)
53+
end
54+
end
55+
end
56+
end

0 commit comments

Comments
 (0)