comment_strip-ruby 0.1.2.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/comment_strip/language_families/c.rb +159 -137
- data/lib/comment_strip/language_families/hash_line.rb +211 -0
- data/lib/comment_strip/strip.rb +24 -12
- data/lib/comment_strip/version.rb +7 -8
- data/test/unit/{tc_strip.rb → tc_strip_c.rb} +262 -232
- data/test/unit/tc_strip_hash_line.rb +95 -0
- data/test/unit/ts_all.rb +1 -1
- metadata +5 -3
@@ -0,0 +1,95 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(__dir__, '../..', 'lib')
|
4
|
+
|
5
|
+
|
6
|
+
require 'comment_strip'
|
7
|
+
|
8
|
+
require 'xqsr3/extensions/test/unit'
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
class Test_HashLine_strip_1 < Test::Unit::TestCase
|
13
|
+
|
14
|
+
include ::CommentStrip
|
15
|
+
|
16
|
+
def test_nil
|
17
|
+
|
18
|
+
assert_nil strip(nil, :Hash_Line)
|
19
|
+
|
20
|
+
assert_nil ::CommentStrip.strip(nil, :Hash_Line)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_empty
|
24
|
+
|
25
|
+
assert_equal "", strip('', :Hash_Line)
|
26
|
+
assert_equal "", ::CommentStrip.strip('', :Hash_Line)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_code_with_single_line_no_comment
|
30
|
+
|
31
|
+
input = <<-EOF
|
32
|
+
x=1
|
33
|
+
EOF
|
34
|
+
expected = <<-EOF
|
35
|
+
x=1
|
36
|
+
EOF
|
37
|
+
|
38
|
+
actual = strip(input, :Hash_Line)
|
39
|
+
|
40
|
+
assert_equal expected, actual
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_code_with_multiple_lines_no_comments
|
44
|
+
|
45
|
+
input = <<-EOF
|
46
|
+
x=1
|
47
|
+
y="abc"
|
48
|
+
z=`pwd`
|
49
|
+
EOF
|
50
|
+
expected = <<-EOF
|
51
|
+
x=1
|
52
|
+
y="abc"
|
53
|
+
z=`pwd`
|
54
|
+
EOF
|
55
|
+
|
56
|
+
actual = strip(input, :Hash_Line)
|
57
|
+
|
58
|
+
assert_equal expected, actual
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_code_with_single_line_and_comment
|
62
|
+
|
63
|
+
input = <<-EOF
|
64
|
+
x=1 # x=1
|
65
|
+
EOF
|
66
|
+
expected = <<-EOF
|
67
|
+
x=1
|
68
|
+
EOF
|
69
|
+
|
70
|
+
actual = strip(input, :Hash_Line)
|
71
|
+
|
72
|
+
assert_equal expected, actual
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_code_with_multiple_lines_and_comments
|
76
|
+
|
77
|
+
input = <<-EOF
|
78
|
+
x=1#x=1
|
79
|
+
y="abc"
|
80
|
+
z=`pwd` # comment
|
81
|
+
EOF
|
82
|
+
expected = <<-EOF
|
83
|
+
x=1
|
84
|
+
y="abc"
|
85
|
+
z=`pwd`
|
86
|
+
EOF
|
87
|
+
|
88
|
+
actual = strip(input, :Hash_Line)
|
89
|
+
|
90
|
+
assert_equal expected, actual
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# ############################## end of file ############################# #
|
95
|
+
|
data/test/unit/ts_all.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comment_strip-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xqsr3
|
@@ -36,10 +36,12 @@ files:
|
|
36
36
|
- README.md
|
37
37
|
- lib/comment_strip.rb
|
38
38
|
- lib/comment_strip/language_families/c.rb
|
39
|
+
- lib/comment_strip/language_families/hash_line.rb
|
39
40
|
- lib/comment_strip/strip.rb
|
40
41
|
- lib/comment_strip/version.rb
|
41
42
|
- test/scratch/ex1.rb
|
42
|
-
- test/unit/
|
43
|
+
- test/unit/tc_strip_c.rb
|
44
|
+
- test/unit/tc_strip_hash_line.rb
|
43
45
|
- test/unit/tc_version.rb
|
44
46
|
- test/unit/ts_all.rb
|
45
47
|
homepage: https://github.com/synesissoftware/comment_strip.r
|