File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ !e stop_at_first_loc
2+ #\p
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments