fortio-namelist 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NOTE.md +29 -0
- data/README.md +105 -23
- data/fortio-namelist.gemspec +2 -2
- data/lib/fortio-namelist/fortran_namelist.rb +41 -30
- data/lib/fortio-namelist/fortran_namelist.tab.rb +229 -217
- data/lib/fortio-namelist/fortran_namelist.y +87 -60
- data/spec/array_spec.rb +160 -0
- data/spec/empty_spec.rb +65 -0
- data/spec/identifier_spec.rb +81 -0
- data/spec/scalar_spec.rb +196 -0
- data/spec/structure_spec.rb +138 -0
- metadata +10 -4
data/spec/scalar_spec.rb
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
require "fortio-namelist"
|
2
|
+
require "rspec-power_assert"
|
3
|
+
|
4
|
+
describe FortIO::Namelist do
|
5
|
+
|
6
|
+
example "integer" do
|
7
|
+
input = %{
|
8
|
+
&example
|
9
|
+
v1 = 1
|
10
|
+
v2 = -1
|
11
|
+
v3 = 01
|
12
|
+
v4 = -01
|
13
|
+
/
|
14
|
+
}
|
15
|
+
nml = FortIO::Namelist.read(input)
|
16
|
+
is_asserted_by { nml.has_key? "example" }
|
17
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
18
|
+
is_asserted_by { nml["example"]["v1"] == 1 }
|
19
|
+
is_asserted_by { nml["example"]["v2"] == -1 }
|
20
|
+
is_asserted_by { nml["example"]["v3"] == 1 }
|
21
|
+
is_asserted_by { nml["example"]["v4"] == -1 }
|
22
|
+
end
|
23
|
+
|
24
|
+
example "float positive" do
|
25
|
+
input = %{
|
26
|
+
&example
|
27
|
+
v1 = 1.0
|
28
|
+
v2 = 2.
|
29
|
+
v3 = 3.0d0
|
30
|
+
v4 = 4.d0
|
31
|
+
v5 = 5d0
|
32
|
+
v6 = 6.0d+0
|
33
|
+
v7 = 7.0d+00
|
34
|
+
v8 = 80.0d-1
|
35
|
+
v9 = 90.0d-01
|
36
|
+
/
|
37
|
+
}
|
38
|
+
nml = FortIO::Namelist.read(input)
|
39
|
+
is_asserted_by { nml.has_key? "example" }
|
40
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
41
|
+
is_asserted_by { nml["example"]["v1"] == 1.0 }
|
42
|
+
is_asserted_by { nml["example"]["v2"] == 2.0 }
|
43
|
+
is_asserted_by { nml["example"]["v3"] == 3.0 }
|
44
|
+
is_asserted_by { nml["example"]["v4"] == 4.0 }
|
45
|
+
is_asserted_by { nml["example"]["v5"] == 5.0 }
|
46
|
+
is_asserted_by { nml["example"]["v6"] == 6.0 }
|
47
|
+
is_asserted_by { nml["example"]["v7"] == 7.0 }
|
48
|
+
is_asserted_by { nml["example"]["v8"] == 8.0 }
|
49
|
+
is_asserted_by { nml["example"]["v9"] == 9.0 }
|
50
|
+
end
|
51
|
+
|
52
|
+
example "float negative" do
|
53
|
+
input = %{
|
54
|
+
&example
|
55
|
+
v1 = -1.0
|
56
|
+
v2 = -2.
|
57
|
+
v3 = -3.0d0
|
58
|
+
v4 = -4.d0
|
59
|
+
v5 = -5d0
|
60
|
+
v6 = -6.0d+0
|
61
|
+
v7 = -7.0d+00
|
62
|
+
v8 = -80.0d-1
|
63
|
+
v9 = -90.0d-01
|
64
|
+
/
|
65
|
+
}
|
66
|
+
nml = FortIO::Namelist.read(input)
|
67
|
+
is_asserted_by { nml.has_key? "example" }
|
68
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
69
|
+
is_asserted_by { nml["example"]["v1"] == -1.0 }
|
70
|
+
is_asserted_by { nml["example"]["v2"] == -2.0 }
|
71
|
+
is_asserted_by { nml["example"]["v3"] == -3.0 }
|
72
|
+
is_asserted_by { nml["example"]["v4"] == -4.0 }
|
73
|
+
is_asserted_by { nml["example"]["v5"] == -5.0 }
|
74
|
+
is_asserted_by { nml["example"]["v6"] == -6.0 }
|
75
|
+
is_asserted_by { nml["example"]["v7"] == -7.0 }
|
76
|
+
is_asserted_by { nml["example"]["v8"] == -8.0 }
|
77
|
+
is_asserted_by { nml["example"]["v9"] == -9.0 }
|
78
|
+
end
|
79
|
+
|
80
|
+
example "float 0 start" do
|
81
|
+
input = %{
|
82
|
+
&example
|
83
|
+
v1 = 01.0
|
84
|
+
/
|
85
|
+
}
|
86
|
+
nml = FortIO::Namelist.read(input)
|
87
|
+
is_asserted_by { nml.has_key? "example" }
|
88
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
89
|
+
is_asserted_by { nml["example"]["v1"] == 1.0 }
|
90
|
+
end
|
91
|
+
|
92
|
+
example "string" do
|
93
|
+
input = %{
|
94
|
+
&example
|
95
|
+
v1 = 'string'
|
96
|
+
v2 = "string"
|
97
|
+
v3 = string
|
98
|
+
/
|
99
|
+
}
|
100
|
+
nml = FortIO::Namelist.read(input)
|
101
|
+
is_asserted_by { nml.has_key? "example" }
|
102
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
103
|
+
is_asserted_by { nml["example"]["v1"] == "string" }
|
104
|
+
is_asserted_by { nml["example"]["v2"] == "string" }
|
105
|
+
is_asserted_by { nml["example"]["v3"] == "string" }
|
106
|
+
end
|
107
|
+
|
108
|
+
example "without quotation mark" do
|
109
|
+
input = %{
|
110
|
+
&example
|
111
|
+
v1 = string
|
112
|
+
v2 = _string
|
113
|
+
v3 = 0_string
|
114
|
+
/
|
115
|
+
}
|
116
|
+
nml = FortIO::Namelist.read(input)
|
117
|
+
is_asserted_by { nml.has_key? "example" }
|
118
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
119
|
+
is_asserted_by { nml["example"]["v1"] == "string" }
|
120
|
+
is_asserted_by { nml["example"]["v2"] == "_string" }
|
121
|
+
is_asserted_by { nml["example"]["v3"] == "0_string" }
|
122
|
+
end
|
123
|
+
|
124
|
+
example "logical true" do
|
125
|
+
input = %{
|
126
|
+
&example
|
127
|
+
v1 = .true.
|
128
|
+
v2 = .TRUE.
|
129
|
+
v3 = .t.
|
130
|
+
v4 = .taaa.
|
131
|
+
v5 = t
|
132
|
+
v6 = T
|
133
|
+
/
|
134
|
+
}
|
135
|
+
nml = FortIO::Namelist.read(input)
|
136
|
+
is_asserted_by { nml.has_key? "example" }
|
137
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
138
|
+
is_asserted_by { nml["example"]["v1"] == true }
|
139
|
+
is_asserted_by { nml["example"]["v2"] == true }
|
140
|
+
is_asserted_by { nml["example"]["v3"] == true }
|
141
|
+
is_asserted_by { nml["example"]["v4"] == true }
|
142
|
+
is_asserted_by { nml["example"]["v5"] == true }
|
143
|
+
is_asserted_by { nml["example"]["v6"] == true }
|
144
|
+
end
|
145
|
+
|
146
|
+
example "logical false" do
|
147
|
+
input = %{
|
148
|
+
&example
|
149
|
+
v1 = .false.
|
150
|
+
v2 = .FALSE.
|
151
|
+
v3 = .f.
|
152
|
+
v4 = .faaa.
|
153
|
+
v5 = f
|
154
|
+
v6 = F
|
155
|
+
/
|
156
|
+
}
|
157
|
+
nml = FortIO::Namelist.read(input)
|
158
|
+
is_asserted_by { nml.has_key? "example" }
|
159
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
160
|
+
is_asserted_by { nml["example"]["v1"] == false }
|
161
|
+
is_asserted_by { nml["example"]["v2"] == false }
|
162
|
+
is_asserted_by { nml["example"]["v3"] == false }
|
163
|
+
is_asserted_by { nml["example"]["v4"] == false }
|
164
|
+
is_asserted_by { nml["example"]["v5"] == false }
|
165
|
+
is_asserted_by { nml["example"]["v6"] == false }
|
166
|
+
end
|
167
|
+
|
168
|
+
example "complex" do
|
169
|
+
input = %{
|
170
|
+
&example
|
171
|
+
v1 = (1,1)
|
172
|
+
v2 = (1d0,1d0)
|
173
|
+
/
|
174
|
+
}
|
175
|
+
nml = FortIO::Namelist.read(input)
|
176
|
+
is_asserted_by { nml.has_key? "example" }
|
177
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
178
|
+
is_asserted_by { nml["example"]["v1"] == 1+1i }
|
179
|
+
is_asserted_by { nml["example"]["v2"] == 1+1i }
|
180
|
+
end
|
181
|
+
|
182
|
+
example "nil asign" do
|
183
|
+
input = %{
|
184
|
+
&example
|
185
|
+
v1 = ,
|
186
|
+
v2 = ,
|
187
|
+
/
|
188
|
+
}
|
189
|
+
nml = FortIO::Namelist.read(input)
|
190
|
+
is_asserted_by { nml.has_key? "example" }
|
191
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
192
|
+
is_asserted_by { nml["example"]["v1"] == "" }
|
193
|
+
is_asserted_by { nml["example"]["v2"] == "" }
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require "fortio-namelist"
|
2
|
+
require "rspec-power_assert"
|
3
|
+
|
4
|
+
describe FortIO::Namelist do
|
5
|
+
|
6
|
+
example "newline enumeration" do
|
7
|
+
input = %{
|
8
|
+
&example
|
9
|
+
a = 1
|
10
|
+
ab = 2
|
11
|
+
abc = 3
|
12
|
+
/
|
13
|
+
}
|
14
|
+
nml = FortIO::Namelist.read(input)
|
15
|
+
is_asserted_by { nml.has_key? "example" }
|
16
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
17
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
18
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
19
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
20
|
+
end
|
21
|
+
|
22
|
+
example "space enumeration" do
|
23
|
+
input = %{
|
24
|
+
&example a = 1 ab = 2 abc = 3 /
|
25
|
+
}
|
26
|
+
nml = FortIO::Namelist.read(input)
|
27
|
+
is_asserted_by { nml.has_key? "example" }
|
28
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
29
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
30
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
31
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
32
|
+
end
|
33
|
+
|
34
|
+
example "space enumeration 2" do
|
35
|
+
input = %{
|
36
|
+
&example
|
37
|
+
a = 1 ab = 2 abc = 3
|
38
|
+
/
|
39
|
+
}
|
40
|
+
nml = FortIO::Namelist.read(input)
|
41
|
+
is_asserted_by { nml.has_key? "example" }
|
42
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
43
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
44
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
45
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
46
|
+
end
|
47
|
+
|
48
|
+
example "comma enumeration" do
|
49
|
+
input = %{
|
50
|
+
&example a = 1, ab = 2, abc = 3 /
|
51
|
+
}
|
52
|
+
nml = FortIO::Namelist.read(input)
|
53
|
+
is_asserted_by { nml.has_key? "example" }
|
54
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
55
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
56
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
57
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
58
|
+
end
|
59
|
+
|
60
|
+
example "comma enumeration 2" do
|
61
|
+
input = %{
|
62
|
+
&example
|
63
|
+
a = 1, ab = 2, abc = 3
|
64
|
+
/
|
65
|
+
}
|
66
|
+
nml = FortIO::Namelist.read(input)
|
67
|
+
is_asserted_by { nml.has_key? "example" }
|
68
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
69
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
70
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
71
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
72
|
+
end
|
73
|
+
|
74
|
+
example "comma newline enumeration" do
|
75
|
+
input = %{
|
76
|
+
&example
|
77
|
+
a = 1,
|
78
|
+
ab = 2,
|
79
|
+
abc = 3
|
80
|
+
/
|
81
|
+
}
|
82
|
+
nml = FortIO::Namelist.read(input)
|
83
|
+
is_asserted_by { nml.has_key? "example" }
|
84
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
85
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
86
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
87
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
88
|
+
end
|
89
|
+
|
90
|
+
example "last comma is permitted" do
|
91
|
+
input = %{
|
92
|
+
&example
|
93
|
+
a = 1,
|
94
|
+
ab = 2,
|
95
|
+
abc = 3,
|
96
|
+
/
|
97
|
+
}
|
98
|
+
nml = FortIO::Namelist.read(input)
|
99
|
+
is_asserted_by { nml.has_key? "example" }
|
100
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
101
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
102
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
103
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
104
|
+
end
|
105
|
+
|
106
|
+
example "comma space hybrid" do
|
107
|
+
input = %{
|
108
|
+
&example
|
109
|
+
a = 1 ab = 2,
|
110
|
+
abc = 3
|
111
|
+
/
|
112
|
+
}
|
113
|
+
nml = FortIO::Namelist.read(input)
|
114
|
+
is_asserted_by { nml.has_key? "example" }
|
115
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
116
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
117
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
118
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
119
|
+
end
|
120
|
+
|
121
|
+
example "space before and after equal symbol" do
|
122
|
+
input = %{
|
123
|
+
&example
|
124
|
+
a = 1
|
125
|
+
ab= 2
|
126
|
+
abc =3
|
127
|
+
/
|
128
|
+
}
|
129
|
+
nml = FortIO::Namelist.read(input)
|
130
|
+
is_asserted_by { nml.has_key? "example" }
|
131
|
+
is_asserted_by { nml["example"].is_a? Hash }
|
132
|
+
is_asserted_by { nml["example"].keys.size == 3 }
|
133
|
+
is_asserted_by { nml["example"].keys == ["a","ab","abc"] }
|
134
|
+
is_asserted_by { nml["example"].values == [1,2,3] }
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortio-namelist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroki Motoyoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " A library for reading/writing fortran namelist file\n"
|
14
14
|
email: ''
|
@@ -16,6 +16,7 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- NOTE.md
|
19
20
|
- README.md
|
20
21
|
- Rakefile
|
21
22
|
- fortio-namelist.gemspec
|
@@ -23,6 +24,11 @@ files:
|
|
23
24
|
- lib/fortio-namelist/fortran_namelist.rb
|
24
25
|
- lib/fortio-namelist/fortran_namelist.tab.rb
|
25
26
|
- lib/fortio-namelist/fortran_namelist.y
|
27
|
+
- spec/array_spec.rb
|
28
|
+
- spec/empty_spec.rb
|
29
|
+
- spec/identifier_spec.rb
|
30
|
+
- spec/scalar_spec.rb
|
31
|
+
- spec/structure_spec.rb
|
26
32
|
homepage: https://github.com/himotoyoshi/fortio-namelist
|
27
33
|
licenses:
|
28
34
|
- MIT
|
@@ -35,14 +41,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
41
|
requirements:
|
36
42
|
- - ">="
|
37
43
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
44
|
+
version: 2.4.0
|
39
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
46
|
requirements:
|
41
47
|
- - ">="
|
42
48
|
- !ruby/object:Gem::Version
|
43
49
|
version: '0'
|
44
50
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
51
|
+
rubygems_version: 3.0.3
|
46
52
|
signing_key:
|
47
53
|
specification_version: 4
|
48
54
|
summary: A library for reading/writing fortran namelist file
|