asciimath2unitsml 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.rubocop.yml +1 -1
- data/README.adoc +19 -1
- data/asciimath2unitsml.gemspec +1 -1
- data/lib/asciimath2unitsml/conv.rb +26 -83
- data/lib/asciimath2unitsml/dimensions.rb +117 -0
- data/lib/asciimath2unitsml/parse.rb +79 -73
- data/lib/asciimath2unitsml/read.rb +42 -0
- data/lib/asciimath2unitsml/render.rb +29 -18
- data/lib/asciimath2unitsml/unit.rb +10 -8
- data/lib/asciimath2unitsml/validate.rb +18 -16
- data/lib/asciimath2unitsml/version.rb +1 -1
- data/lib/unitsdb/dimensions.yaml +65 -8
- data/lib/unitsdb_ruby/unitsdb.rb +83 -61
- data/spec/conv_spec.rb +1325 -1249
- metadata +5 -3
data/spec/conv_spec.rb
CHANGED
@@ -2,889 +2,917 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe Asciimath2UnitsML do
|
4
4
|
it "converts an AsciiMath string to MathML + UnitsML" do
|
5
|
-
|
5
|
+
input = <<~INPUT
|
6
6
|
1 "unitsml(mm*s^-2)"
|
7
7
|
INPUT
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
|
13
|
-
<
|
14
|
-
<
|
15
|
-
|
16
|
-
<
|
17
|
-
|
18
|
-
</mrow>
|
19
|
-
<mrow>
|
20
|
-
<mo>−</mo>
|
21
|
-
<mn>2</mn>
|
22
|
-
</mrow>
|
23
|
-
</msup>
|
24
|
-
</mrow>
|
25
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_mm.s-2' dimensionURL='#NISTd28'>
|
26
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
27
|
-
<UnitName xml:lang='en'>mm*s^-2</UnitName>
|
28
|
-
<UnitSymbol type='HTML'>
|
29
|
-
mm⋅s
|
30
|
-
<sup>−2</sup>
|
31
|
-
</UnitSymbol>
|
32
|
-
<UnitSymbol type='MathML'>
|
33
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
8
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
9
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
10
|
+
<?xml version='1.0'?>
|
11
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
12
|
+
<mn>1</mn>
|
13
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
14
|
+
<mrow xref='U_mm.s-2'>
|
15
|
+
<mi mathvariant='normal'>mm</mi>
|
16
|
+
<mo>⋅</mo>
|
17
|
+
<msup>
|
34
18
|
<mrow>
|
35
|
-
<mi mathvariant='normal'>
|
36
|
-
<mo>⋅</mo>
|
37
|
-
<msup>
|
38
|
-
<mrow>
|
39
|
-
<mi mathvariant='normal'>s</mi>
|
40
|
-
</mrow>
|
41
|
-
<mrow>
|
42
|
-
<mo>−</mo>
|
43
|
-
<mn>2</mn>
|
44
|
-
</mrow>
|
45
|
-
</msup>
|
19
|
+
<mi mathvariant='normal'>s</mi>
|
46
20
|
</mrow>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
</
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
21
|
+
<mrow>
|
22
|
+
<mo>−</mo>
|
23
|
+
<mn>2</mn>
|
24
|
+
</mrow>
|
25
|
+
</msup>
|
26
|
+
</mrow>
|
27
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_mm.s-2' dimensionURL='#NISTd28'>
|
28
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
29
|
+
<UnitName xml:lang='en'>mm*s^-2</UnitName>
|
30
|
+
<UnitSymbol type='HTML'>
|
31
|
+
mm⋅s
|
32
|
+
<sup>−2</sup>
|
33
|
+
</UnitSymbol>
|
34
|
+
<UnitSymbol type='MathML'>
|
35
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
36
|
+
<mrow>
|
37
|
+
<mi mathvariant='normal'>mm</mi>
|
38
|
+
<mo>⋅</mo>
|
39
|
+
<msup>
|
40
|
+
<mrow>
|
41
|
+
<mi mathvariant='normal'>s</mi>
|
42
|
+
</mrow>
|
43
|
+
<mrow>
|
44
|
+
<mo>−</mo>
|
45
|
+
<mn>2</mn>
|
46
|
+
</mrow>
|
47
|
+
</msup>
|
48
|
+
</mrow>
|
49
|
+
</math>
|
50
|
+
</UnitSymbol>
|
51
|
+
<RootUnits>
|
52
|
+
<EnumeratedRootUnit unit='meter' prefix='m'/>
|
53
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
54
|
+
</RootUnits>
|
55
|
+
</Unit>
|
56
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
|
57
|
+
<PrefixName xml:lang='en'>milli</PrefixName>
|
58
|
+
<PrefixSymbol type='ASCII'>m</PrefixSymbol>
|
59
|
+
<PrefixSymbol type='unicode'>m</PrefixSymbol>
|
60
|
+
<PrefixSymbol type='LaTeX'>m</PrefixSymbol>
|
61
|
+
<PrefixSymbol type='HTML'>m</PrefixSymbol>
|
62
|
+
</Prefix>
|
63
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
64
|
+
<Length symbol='L' powerNumerator='1'/>
|
65
|
+
<Time symbol='T' powerNumerator='-2'/>
|
66
|
+
</Dimension>
|
67
|
+
</math>
|
68
|
+
OUTPUT
|
67
69
|
end
|
68
70
|
|
69
71
|
it "deals with non-Ascii units and prefixes" do
|
70
|
-
|
72
|
+
input = <<~INPUT
|
71
73
|
1 "unitsml(um)"
|
72
74
|
INPUT
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
77
|
-
<mrow xref='U_um'>
|
78
|
-
<mi mathvariant='normal'>µm</mi>
|
79
|
-
</mrow>
|
80
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_um' dimensionURL='#NISTd1'>
|
81
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
82
|
-
<UnitName xml:lang='en'>um</UnitName>
|
83
|
-
<UnitSymbol type='HTML'>um</UnitSymbol>
|
84
|
-
<UnitSymbol type='MathML'>
|
75
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
76
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
77
|
+
<?xml version='1.0'?>
|
85
78
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
</
|
90
|
-
</
|
91
|
-
<
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
<
|
104
|
-
</
|
105
|
-
|
106
|
-
|
79
|
+
<mn>1</mn>
|
80
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
81
|
+
<mrow xref='U_um'>
|
82
|
+
<mi mathvariant='normal'>µm</mi>
|
83
|
+
</mrow>
|
84
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_um' dimensionURL='#NISTd1'>
|
85
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
86
|
+
<UnitName xml:lang='en'>um</UnitName>
|
87
|
+
<UnitSymbol type='HTML'>um</UnitSymbol>
|
88
|
+
<UnitSymbol type='MathML'>
|
89
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
90
|
+
<mrow>
|
91
|
+
<mi mathvariant='normal'>µm</mi>
|
92
|
+
</mrow>
|
93
|
+
</math>
|
94
|
+
</UnitSymbol>
|
95
|
+
<RootUnits>
|
96
|
+
<EnumeratedRootUnit unit='meter' prefix='u'/>
|
97
|
+
</RootUnits>
|
98
|
+
</Unit>
|
99
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-6' xml:id='NISTp10_-6'>
|
100
|
+
<PrefixName xml:lang='en'>micro</PrefixName>
|
101
|
+
<PrefixSymbol type='ASCII'>u</PrefixSymbol>
|
102
|
+
<PrefixSymbol type='unicode'>μ</PrefixSymbol>
|
103
|
+
<PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
|
104
|
+
<PrefixSymbol type='HTML'>µ</PrefixSymbol>
|
105
|
+
</Prefix>
|
106
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
107
|
+
<Length symbol='L' powerNumerator='1'/>
|
108
|
+
</Dimension>
|
109
|
+
</math>
|
110
|
+
OUTPUT
|
107
111
|
end
|
108
112
|
|
109
113
|
it "does not insert space before non-alphabetic units" do
|
110
|
-
|
114
|
+
input = <<~INPUT
|
111
115
|
1 "unitsml(degK)" + 1 "unitsml(prime)" + ii(theta) = s//r "unitsml(rad)" + 10^(12) "unitsml(Hz)"
|
112
116
|
INPUT
|
113
|
-
|
114
|
-
|
115
|
-
<
|
116
|
-
|
117
|
-
<
|
118
|
-
|
119
|
-
|
120
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
121
|
-
<UnitName xml:lang='en'>kelvin</UnitName>
|
122
|
-
<UnitSymbol type='HTML'>K</UnitSymbol>
|
123
|
-
<UnitSymbol type='MathML'>
|
124
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
125
|
-
<mrow>
|
126
|
-
<mi mathvariant='normal'>K</mi>
|
127
|
-
</mrow>
|
128
|
-
</math>
|
129
|
-
</UnitSymbol>
|
130
|
-
</Unit>
|
131
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd5'>
|
132
|
-
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
133
|
-
</Dimension>
|
134
|
-
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq5' dimensionURL='#NISTd5' quantityType='base'>
|
135
|
-
<QuantityName xml:lang='en-US'>thermodynamic temperature</QuantityName>
|
136
|
-
</Quantity>
|
137
|
-
<mo>+</mo>
|
138
|
-
<mn>1</mn>
|
139
|
-
<mo>⁢</mo>
|
140
|
-
<mrow xref='U_NISTu147'>
|
141
|
-
<mi mathvariant='normal'>′</mi>
|
142
|
-
</mrow>
|
143
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu147'>
|
144
|
-
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
145
|
-
<UnitName xml:lang='en'>minute (minute of arc)</UnitName>
|
146
|
-
<UnitSymbol type='HTML'>′</UnitSymbol>
|
147
|
-
<UnitSymbol type='MathML'>
|
148
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
149
|
-
<mrow>
|
150
|
-
<mi mathvariant='normal'>′</mi>
|
151
|
-
</mrow>
|
152
|
-
</math>
|
153
|
-
</UnitSymbol>
|
154
|
-
</Unit>
|
155
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd9'>
|
156
|
-
<PlaneAngle symbol='Phi' powerNumerator='1'/>
|
157
|
-
</Dimension>
|
158
|
-
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq9' dimensionURL='#NISTd9' quantityType='base'>
|
159
|
-
<QuantityName xml:lang='en-US'>plane angle</QuantityName>
|
160
|
-
<QuantityName xml:lang='en-US'>angle</QuantityName>
|
161
|
-
</Quantity>
|
162
|
-
<mo>+</mo>
|
163
|
-
<mstyle mathvariant='italic'>
|
164
|
-
<mi>θ</mi>
|
165
|
-
</mstyle>
|
166
|
-
<mo>=</mo>
|
167
|
-
<mi>s</mi>
|
168
|
-
<mo>/</mo>
|
169
|
-
<mi>r</mi>
|
170
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
171
|
-
<mrow xref='U_NISTu9'>
|
172
|
-
<mi mathvariant='normal'>rad</mi>
|
173
|
-
</mrow>
|
174
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu9' dimensionURL='#D_L0'>
|
175
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
176
|
-
<UnitName xml:lang='en'>radian</UnitName>
|
177
|
-
<UnitSymbol type='HTML'>rad</UnitSymbol>
|
178
|
-
<UnitSymbol type='MathML'>
|
179
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
180
|
-
<mrow>
|
181
|
-
<mi mathvariant='normal'>rad</mi>
|
182
|
-
</mrow>
|
183
|
-
</math>
|
184
|
-
</UnitSymbol>
|
185
|
-
</Unit>
|
186
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L0'>
|
187
|
-
<Length symbol='L' powerNumerator='0'/>
|
188
|
-
</Dimension>
|
189
|
-
<mo>+</mo>
|
190
|
-
<msup>
|
191
|
-
<mrow>
|
192
|
-
<mn>10</mn>
|
117
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
118
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
119
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
120
|
+
<mn>1</mn>
|
121
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
122
|
+
<mrow xref='U_NISTu5'>
|
123
|
+
<mi mathvariant='normal'>°K</mi>
|
193
124
|
</mrow>
|
194
|
-
<
|
195
|
-
<
|
125
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu5' dimensionURL='#NISTd5'>
|
126
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
127
|
+
<UnitName xml:lang='en'>kelvin</UnitName>
|
128
|
+
<UnitSymbol type='HTML'>K</UnitSymbol>
|
129
|
+
<UnitSymbol type='MathML'>
|
130
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
131
|
+
<mrow>
|
132
|
+
<mi mathvariant='normal'>K</mi>
|
133
|
+
</mrow>
|
134
|
+
</math>
|
135
|
+
</UnitSymbol>
|
136
|
+
</Unit>
|
137
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd5'>
|
138
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
139
|
+
</Dimension>
|
140
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq5' dimensionURL='#NISTd5' quantityType='base'>
|
141
|
+
<QuantityName xml:lang='en-US'>thermodynamic temperature</QuantityName>
|
142
|
+
</Quantity>
|
143
|
+
<mo>+</mo>
|
144
|
+
<mn>1</mn>
|
145
|
+
<mo>⁢</mo>
|
146
|
+
<mrow xref='U_NISTu147'>
|
147
|
+
<mi mathvariant='normal'>′</mi>
|
196
148
|
</mrow>
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
149
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu147'>
|
150
|
+
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
151
|
+
<UnitName xml:lang='en'>minute (minute of arc)</UnitName>
|
152
|
+
<UnitSymbol type='HTML'>′</UnitSymbol>
|
153
|
+
<UnitSymbol type='MathML'>
|
154
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
155
|
+
<mrow>
|
156
|
+
<mi mathvariant='normal'>′</mi>
|
157
|
+
</mrow>
|
158
|
+
</math>
|
159
|
+
</UnitSymbol>
|
160
|
+
</Unit>
|
161
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd9'>
|
162
|
+
<PlaneAngle symbol='phi' powerNumerator='1'/>
|
163
|
+
</Dimension>
|
164
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq9' dimensionURL='#NISTd9' quantityType='base'>
|
165
|
+
<QuantityName xml:lang='en-US'>plane angle</QuantityName>
|
166
|
+
<QuantityName xml:lang='en-US'>angle</QuantityName>
|
167
|
+
</Quantity>
|
168
|
+
<mo>+</mo>
|
169
|
+
<mstyle mathvariant='italic'>
|
170
|
+
<mi>θ</mi>
|
171
|
+
</mstyle>
|
172
|
+
<mo>=</mo>
|
173
|
+
<mi>s</mi>
|
174
|
+
<mo>/</mo>
|
175
|
+
<mi>r</mi>
|
176
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
177
|
+
<mrow xref='U_NISTu9'>
|
178
|
+
<mi mathvariant='normal'>rad</mi>
|
179
|
+
</mrow>
|
180
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu9' dimensionURL='#D_L0'>
|
181
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
182
|
+
<UnitName xml:lang='en'>radian</UnitName>
|
183
|
+
<UnitSymbol type='HTML'>rad</UnitSymbol>
|
184
|
+
<UnitSymbol type='MathML'>
|
185
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
186
|
+
<mrow>
|
187
|
+
<mi mathvariant='normal'>rad</mi>
|
188
|
+
</mrow>
|
189
|
+
</math>
|
190
|
+
</UnitSymbol>
|
191
|
+
</Unit>
|
192
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L0'>
|
193
|
+
<Length symbol='L' powerNumerator='0'/>
|
194
|
+
</Dimension>
|
195
|
+
<mo>+</mo>
|
196
|
+
<msup>
|
197
|
+
<mrow>
|
198
|
+
<mn>10</mn>
|
199
|
+
</mrow>
|
200
|
+
<mrow>
|
201
|
+
<mn>12</mn>
|
202
|
+
</mrow>
|
203
|
+
</msup>
|
204
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
205
|
+
<mrow xref='U_NISTu31'>
|
206
|
+
<mi mathvariant='normal'>Hz</mi>
|
207
|
+
</mrow>
|
208
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu31' dimensionURL='#NISTd24'>
|
209
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
210
|
+
<UnitName xml:lang='en'>hertz</UnitName>
|
211
|
+
<UnitSymbol type='HTML'>Hz</UnitSymbol>
|
212
|
+
<UnitSymbol type='MathML'>
|
213
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
214
|
+
<mrow>
|
215
|
+
<mi mathvariant='normal'>Hz</mi>
|
216
|
+
</mrow>
|
217
|
+
</math>
|
218
|
+
</UnitSymbol>
|
219
|
+
</Unit>
|
220
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd24'>
|
221
|
+
<Time symbol='T' powerNumerator='-1'/>
|
222
|
+
</Dimension>
|
223
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq45' dimensionURL='#NISTd24' quantityType='base'>
|
224
|
+
<QuantityName xml:lang='en-US'>frequency</QuantityName>
|
225
|
+
</Quantity>
|
226
|
+
</math>
|
227
|
+
OUTPUT
|
222
228
|
end
|
223
229
|
|
224
230
|
it "does not insert space before operators" do
|
225
|
-
|
231
|
+
input = <<~INPUT
|
226
232
|
8 "unitsml(kg)" cdot "unitsml(m)"
|
227
233
|
INPUT
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
<
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
<
|
237
|
-
|
238
|
-
|
239
|
-
<
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
<
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
<
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
<
|
269
|
-
|
270
|
-
|
271
|
-
<
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
234
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
235
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
236
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
237
|
+
<mn>8</mn>
|
238
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
239
|
+
<mrow xref='U_NISTu2'>
|
240
|
+
<mi mathvariant='normal'>kg</mi>
|
241
|
+
</mrow>
|
242
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu2' dimensionURL='#NISTd2'>
|
243
|
+
<UnitSystem name='SI' type='SI_base' xml:lang='en-US'/>
|
244
|
+
<UnitName xml:lang='en'>kilogram</UnitName>
|
245
|
+
<UnitSymbol type='HTML'>kg</UnitSymbol>
|
246
|
+
<UnitSymbol type='MathML'>
|
247
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
248
|
+
<mrow>
|
249
|
+
<mi mathvariant='normal'>kg</mi>
|
250
|
+
</mrow>
|
251
|
+
</math>
|
252
|
+
</UnitSymbol>
|
253
|
+
<RootUnits>
|
254
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
255
|
+
</RootUnits>
|
256
|
+
</Unit>
|
257
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
258
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
259
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
260
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
261
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
262
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
263
|
+
</Prefix>
|
264
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd2'>
|
265
|
+
<Mass symbol='M' powerNumerator='1'/>
|
266
|
+
</Dimension>
|
267
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
|
268
|
+
<QuantityName xml:lang='en-US'>mass</QuantityName>
|
269
|
+
</Quantity>
|
270
|
+
<mo>⋅</mo>
|
271
|
+
<mrow xref='U_NISTu1'>
|
272
|
+
<mi mathvariant='normal'>m</mi>
|
273
|
+
</mrow>
|
274
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
275
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
276
|
+
<UnitName xml:lang='en'>meter</UnitName>
|
277
|
+
<UnitSymbol type='HTML'>m</UnitSymbol>
|
278
|
+
<UnitSymbol type='MathML'>
|
279
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
280
|
+
<mrow>
|
281
|
+
<mi mathvariant='normal'>m</mi>
|
282
|
+
</mrow>
|
283
|
+
</math>
|
284
|
+
</UnitSymbol>
|
285
|
+
</Unit>
|
286
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
287
|
+
<Length symbol='L' powerNumerator='1'/>
|
288
|
+
</Dimension>
|
289
|
+
</math>
|
290
|
+
OUTPUT
|
283
291
|
end
|
284
292
|
|
285
293
|
it "deals with sqrt units" do
|
286
|
-
|
294
|
+
input = <<~INPUT
|
287
295
|
1 "unitsml(sqrt(Hz))"
|
288
296
|
INPUT
|
289
|
-
|
290
|
-
|
291
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
292
|
-
<mrow xref='U_sqrtHz'>
|
293
|
-
<msqrt>
|
294
|
-
<mi mathvariant='normal'>Hz</mi>
|
295
|
-
</msqrt>
|
296
|
-
</mrow>
|
297
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_Hz0.5' dimensionURL='#D_T-0.5'>
|
298
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
299
|
-
<UnitName xml:lang='en'>Hz^0.5</UnitName>
|
300
|
-
<UnitSymbol type='HTML'>√Hz</UnitSymbol>
|
301
|
-
<UnitSymbol type='MathML'>
|
297
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
298
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
302
299
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
</
|
308
|
-
</
|
309
|
-
</
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
300
|
+
<mn>1</mn>
|
301
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
302
|
+
<mrow xref='U_sqrtHz'>
|
303
|
+
<msqrt>
|
304
|
+
<mi mathvariant='normal'>Hz</mi>
|
305
|
+
</msqrt>
|
306
|
+
</mrow>
|
307
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_Hz0.5' dimensionURL='#D_T-0.5'>
|
308
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
309
|
+
<UnitName xml:lang='en'>Hz^0.5</UnitName>
|
310
|
+
<UnitSymbol type='HTML'>√Hz</UnitSymbol>
|
311
|
+
<UnitSymbol type='MathML'>
|
312
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
313
|
+
<mrow>
|
314
|
+
<msqrt>
|
315
|
+
<mi mathvariant='normal'>Hz</mi>
|
316
|
+
</msqrt>
|
317
|
+
</mrow>
|
318
|
+
</math>
|
319
|
+
</UnitSymbol>
|
320
|
+
</Unit>
|
321
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_T-0.5'>
|
322
|
+
<Time symbol='T' powerNumerator='-0.5'/>
|
323
|
+
</Dimension>
|
324
|
+
</math>
|
325
|
+
OUTPUT
|
316
326
|
end
|
317
327
|
|
318
328
|
it "deals with kg and g" do
|
319
|
-
|
329
|
+
input = <<~INPUT
|
320
330
|
1 "unitsml(kg)" + 1 "unitsml(g)"
|
321
331
|
INPUT
|
322
|
-
|
323
|
-
|
324
|
-
<
|
325
|
-
|
326
|
-
<
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
<
|
331
|
-
|
332
|
-
|
333
|
-
<
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
<
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
<
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
<
|
365
|
-
|
366
|
-
|
367
|
-
<
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
332
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
333
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
334
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
335
|
+
<mn>1</mn>
|
336
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
337
|
+
<mrow xref='U_NISTu2'>
|
338
|
+
<mi mathvariant='normal'>kg</mi>
|
339
|
+
</mrow>
|
340
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu2' dimensionURL='#NISTd2'>
|
341
|
+
<UnitSystem name='SI' type='SI_base' xml:lang='en-US'/>
|
342
|
+
<UnitName xml:lang='en'>kilogram</UnitName>
|
343
|
+
<UnitSymbol type='HTML'>kg</UnitSymbol>
|
344
|
+
<UnitSymbol type='MathML'>
|
345
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
346
|
+
<mrow>
|
347
|
+
<mi mathvariant='normal'>kg</mi>
|
348
|
+
</mrow>
|
349
|
+
</math>
|
350
|
+
</UnitSymbol>
|
351
|
+
<RootUnits>
|
352
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
353
|
+
</RootUnits>
|
354
|
+
</Unit>
|
355
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
356
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
357
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
358
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
359
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
360
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
361
|
+
</Prefix>
|
362
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd2'>
|
363
|
+
<Mass symbol='M' powerNumerator='1'/>
|
364
|
+
</Dimension>
|
365
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
|
366
|
+
<QuantityName xml:lang='en-US'>mass</QuantityName>
|
367
|
+
</Quantity>
|
368
|
+
<mo>+</mo>
|
369
|
+
<mn>1</mn>
|
370
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
371
|
+
<mrow xref='U_NISTu27'>
|
372
|
+
<mi mathvariant='normal'>g</mi>
|
373
|
+
</mrow>
|
374
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu27' dimensionURL='#NISTd2'>
|
375
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
376
|
+
<UnitName xml:lang='en'>gram</UnitName>
|
377
|
+
<UnitSymbol type='HTML'>g</UnitSymbol>
|
378
|
+
<UnitSymbol type='MathML'>
|
379
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
380
|
+
<mrow>
|
381
|
+
<mi mathvariant='normal'>g</mi>
|
382
|
+
</mrow>
|
383
|
+
</math>
|
384
|
+
</UnitSymbol>
|
385
|
+
</Unit>
|
386
|
+
</math>
|
387
|
+
OUTPUT
|
376
388
|
end
|
377
389
|
|
378
390
|
it "deals with non-metric" do
|
379
|
-
|
391
|
+
input = <<~INPUT
|
380
392
|
1 "unitsml(hp)"
|
381
393
|
INPUT
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
<
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
<
|
391
|
-
|
392
|
-
|
393
|
-
<
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
394
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
395
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
396
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
397
|
+
<mn>1</mn>
|
398
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
399
|
+
<mrow xref='U_NISTu284'>
|
400
|
+
<mi mathvariant='normal'>hp</mi>
|
401
|
+
</mrow>
|
402
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu284'>
|
403
|
+
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
404
|
+
<UnitName xml:lang='en'>horsepower</UnitName>
|
405
|
+
<UnitSymbol type='HTML'>hp</UnitSymbol>
|
406
|
+
<UnitSymbol type='MathML'>
|
407
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
408
|
+
<mrow>
|
409
|
+
<mi mathvariant='normal'>hp</mi>
|
410
|
+
</mrow>
|
411
|
+
</math>
|
412
|
+
</UnitSymbol>
|
413
|
+
</Unit>
|
414
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd16'>
|
415
|
+
<Length symbol='L' powerNumerator='2'/>
|
416
|
+
<Mass symbol='M' powerNumerator='1'/>
|
417
|
+
<Time symbol='T' powerNumerator='-3'/>
|
418
|
+
</Dimension>
|
419
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq20' dimensionURL='#NISTd16' quantityType='base'>
|
420
|
+
<QuantityName xml:lang='en-US'>power</QuantityName>
|
421
|
+
</Quantity>
|
422
|
+
</math>
|
423
|
+
OUTPUT
|
410
424
|
end
|
411
425
|
|
412
426
|
it "deals with duplicate units" do
|
413
|
-
|
427
|
+
input = <<~INPUT
|
414
428
|
1 "unitsml(kg*s^-2)" xx 9 "unitsml(kg*s^-2)"
|
415
429
|
INPUT
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
<
|
421
|
-
<
|
422
|
-
|
423
|
-
<
|
424
|
-
|
425
|
-
</mrow>
|
426
|
-
<mrow>
|
427
|
-
<mo>−</mo>
|
428
|
-
<mn>2</mn>
|
429
|
-
</mrow>
|
430
|
-
</msup>
|
431
|
-
</mrow>
|
432
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
433
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
434
|
-
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
435
|
-
<UnitSymbol type='HTML'>
|
436
|
-
kg⋅s
|
437
|
-
<sup>−2</sup>
|
438
|
-
</UnitSymbol>
|
439
|
-
<UnitSymbol type='MathML'>
|
440
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
430
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
431
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
432
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
433
|
+
<mn>1</mn>
|
434
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
435
|
+
<mrow xref='U_kg.s-2'>
|
436
|
+
<mi mathvariant='normal'>kg</mi>
|
437
|
+
<mo>⋅</mo>
|
438
|
+
<msup>
|
441
439
|
<mrow>
|
442
|
-
<mi mathvariant='normal'>
|
443
|
-
<mo>⋅</mo>
|
444
|
-
<msup>
|
445
|
-
<mrow>
|
446
|
-
<mi mathvariant='normal'>s</mi>
|
447
|
-
</mrow>
|
448
|
-
<mrow>
|
449
|
-
<mo>−</mo>
|
450
|
-
<mn>2</mn>
|
451
|
-
</mrow>
|
452
|
-
</msup>
|
440
|
+
<mi mathvariant='normal'>s</mi>
|
453
441
|
</mrow>
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
</
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
442
|
+
<mrow>
|
443
|
+
<mo>−</mo>
|
444
|
+
<mn>2</mn>
|
445
|
+
</mrow>
|
446
|
+
</msup>
|
447
|
+
</mrow>
|
448
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
449
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
450
|
+
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
451
|
+
<UnitSymbol type='HTML'>
|
452
|
+
kg⋅s
|
453
|
+
<sup>−2</sup>
|
454
|
+
</UnitSymbol>
|
455
|
+
<UnitSymbol type='MathML'>
|
456
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
457
|
+
<mrow>
|
458
|
+
<mi mathvariant='normal'>kg</mi>
|
459
|
+
<mo>⋅</mo>
|
460
|
+
<msup>
|
461
|
+
<mrow>
|
462
|
+
<mi mathvariant='normal'>s</mi>
|
463
|
+
</mrow>
|
464
|
+
<mrow>
|
465
|
+
<mo>−</mo>
|
466
|
+
<mn>2</mn>
|
467
|
+
</mrow>
|
468
|
+
</msup>
|
469
|
+
</mrow>
|
470
|
+
</math>
|
471
|
+
</UnitSymbol>
|
472
|
+
<RootUnits>
|
473
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
474
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
475
|
+
</RootUnits>
|
476
|
+
</Unit>
|
477
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
478
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
479
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
480
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
481
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
482
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
483
|
+
</Prefix>
|
484
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
485
|
+
<Mass symbol='M' powerNumerator='1'/>
|
486
|
+
<Time symbol='T' powerNumerator='-2'/>
|
487
|
+
</Dimension>
|
488
|
+
<mo>×</mo>
|
489
|
+
<mn>9</mn>
|
490
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
491
|
+
<mrow xref='U_kg.s-2'>
|
492
|
+
<mi mathvariant='normal'>kg</mi>
|
493
|
+
<mo>⋅</mo>
|
494
|
+
<msup>
|
495
|
+
<mrow>
|
496
|
+
<mi mathvariant='normal'>s</mi>
|
497
|
+
</mrow>
|
498
|
+
<mrow>
|
499
|
+
<mo>−</mo>
|
500
|
+
<mn>2</mn>
|
501
|
+
</mrow>
|
502
|
+
</msup>
|
503
|
+
</mrow>
|
504
|
+
</math>
|
505
|
+
OUTPUT
|
490
506
|
end
|
491
507
|
|
492
508
|
it "deals with parentheses" do
|
493
|
-
|
509
|
+
input = <<~INPUT
|
494
510
|
10 "unitsml(K/(kg*m))"
|
495
511
|
INPUT
|
496
|
-
|
497
|
-
|
512
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
513
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
514
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
515
|
+
<mn>10</mn>
|
516
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
517
|
+
<mrow xref='U_K/kg.m'>
|
518
|
+
<mi mathvariant='normal'>K</mi>
|
519
|
+
<mo>/</mo>
|
520
|
+
<mi mathvariant='normal'>kg</mi>
|
521
|
+
<mo>⋅</mo>
|
522
|
+
<mi mathvariant='normal'>m</mi>
|
523
|
+
</mrow>
|
524
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_K.kg-1.m-1' dimensionURL='#D_L-1M-1Theta'>
|
525
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
526
|
+
<UnitName xml:lang='en'>K*kg^-1*m^-1</UnitName>
|
527
|
+
<UnitSymbol type='HTML'>
|
528
|
+
K⋅kg
|
529
|
+
<sup>−1</sup>
|
530
|
+
⋅m
|
531
|
+
<sup>−1</sup>
|
532
|
+
</UnitSymbol>
|
533
|
+
<UnitSymbol type='MathML'>
|
534
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
535
|
+
<mrow>
|
536
|
+
<mi mathvariant='normal'>K</mi>
|
537
|
+
<mo>⋅</mo>
|
538
|
+
<msup>
|
539
|
+
<mrow>
|
540
|
+
<mi mathvariant='normal'>kg</mi>
|
541
|
+
</mrow>
|
542
|
+
<mrow>
|
543
|
+
<mo>−</mo>
|
544
|
+
<mn>1</mn>
|
545
|
+
</mrow>
|
546
|
+
</msup>
|
547
|
+
<mo>⋅</mo>
|
548
|
+
<msup>
|
549
|
+
<mrow>
|
550
|
+
<mi mathvariant='normal'>m</mi>
|
551
|
+
</mrow>
|
552
|
+
<mrow>
|
553
|
+
<mo>−</mo>
|
554
|
+
<mn>1</mn>
|
555
|
+
</mrow>
|
556
|
+
</msup>
|
557
|
+
</mrow>
|
558
|
+
</math>
|
559
|
+
</UnitSymbol>
|
560
|
+
<RootUnits>
|
561
|
+
<EnumeratedRootUnit unit='kelvin'/>
|
562
|
+
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-1'/>
|
563
|
+
<EnumeratedRootUnit unit='meter' powerNumerator='-1'/>
|
564
|
+
</RootUnits>
|
565
|
+
</Unit>
|
566
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
567
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
568
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
569
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
570
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
571
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
572
|
+
</Prefix>
|
573
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L-1M-1Theta'>
|
574
|
+
<Length symbol='L' powerNumerator='-1'/>
|
575
|
+
<Mass symbol='M' powerNumerator='-1'/>
|
576
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
577
|
+
</Dimension>
|
578
|
+
</math>
|
579
|
+
OUTPUT
|
580
|
+
end
|
581
|
+
|
582
|
+
it "deals with notational variants" do
|
583
|
+
input = <<~INPUT
|
584
|
+
9 "unitsml(degK)" + 10 "unitsml(K)"
|
585
|
+
INPUT
|
586
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
587
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
588
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
589
|
+
<mn>9</mn>
|
498
590
|
<mo rspace='thickmathspace'>⁢</mo>
|
499
|
-
<mrow xref='
|
500
|
-
<mi mathvariant='normal'
|
501
|
-
<mo>/</mo>
|
502
|
-
<mi mathvariant='normal'>kg</mi>
|
503
|
-
<mo>⋅</mo>
|
504
|
-
<mi mathvariant='normal'>m</mi>
|
591
|
+
<mrow xref='U_NISTu5'>
|
592
|
+
<mi mathvariant='normal'>°K</mi>
|
505
593
|
</mrow>
|
506
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='
|
594
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu5' dimensionURL='#NISTd5'>
|
507
595
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
508
|
-
<UnitName xml:lang='en'>
|
509
|
-
<UnitSymbol type='HTML'>
|
510
|
-
K⋅kg
|
511
|
-
<sup>−1</sup>
|
512
|
-
⋅m
|
513
|
-
<sup>−1</sup>
|
514
|
-
</UnitSymbol>
|
596
|
+
<UnitName xml:lang='en'>kelvin</UnitName>
|
597
|
+
<UnitSymbol type='HTML'>K</UnitSymbol>
|
515
598
|
<UnitSymbol type='MathML'>
|
516
599
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
517
600
|
<mrow>
|
518
601
|
<mi mathvariant='normal'>K</mi>
|
519
|
-
<mo>⋅</mo>
|
520
|
-
<msup>
|
521
|
-
<mrow>
|
522
|
-
<mi mathvariant='normal'>kg</mi>
|
523
|
-
</mrow>
|
524
|
-
<mrow>
|
525
|
-
<mo>−</mo>
|
526
|
-
<mn>1</mn>
|
527
|
-
</mrow>
|
528
|
-
</msup>
|
529
|
-
<mo>⋅</mo>
|
530
|
-
<msup>
|
531
|
-
<mrow>
|
532
|
-
<mi mathvariant='normal'>m</mi>
|
533
|
-
</mrow>
|
534
|
-
<mrow>
|
535
|
-
<mo>−</mo>
|
536
|
-
<mn>1</mn>
|
537
|
-
</mrow>
|
538
|
-
</msup>
|
539
602
|
</mrow>
|
540
603
|
</math>
|
541
604
|
</UnitSymbol>
|
542
|
-
<RootUnits>
|
543
|
-
<EnumeratedRootUnit unit='kelvin'/>
|
544
|
-
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-1'/>
|
545
|
-
<EnumeratedRootUnit unit='meter' powerNumerator='-1'/>
|
546
|
-
</RootUnits>
|
547
605
|
</Unit>
|
548
|
-
<
|
549
|
-
<PrefixName xml:lang='en'>kilo</PrefixName>
|
550
|
-
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
551
|
-
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
552
|
-
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
553
|
-
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
554
|
-
</Prefix>
|
555
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L-1M-1Theta'>
|
556
|
-
<Length symbol='L' powerNumerator='-1'/>
|
557
|
-
<Mass symbol='M' powerNumerator='-1'/>
|
606
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd5'>
|
558
607
|
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
559
608
|
</Dimension>
|
609
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq5' dimensionURL='#NISTd5' quantityType='base'>
|
610
|
+
<QuantityName xml:lang='en-US'>thermodynamic temperature</QuantityName>
|
611
|
+
</Quantity>
|
612
|
+
<mo>+</mo>
|
613
|
+
<mn>10</mn>
|
614
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
615
|
+
<mrow xref='U_NISTu5'>
|
616
|
+
<mi mathvariant='normal'>K</mi>
|
617
|
+
</mrow>
|
560
618
|
</math>
|
561
|
-
|
562
|
-
end
|
563
|
-
|
564
|
-
it "deals with notational variants" do
|
565
|
-
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
566
|
-
9 "unitsml(degK)" + 10 "unitsml(K)"
|
567
|
-
INPUT
|
568
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
569
|
-
<mn>9</mn>
|
570
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
571
|
-
<mrow xref='U_NISTu5'>
|
572
|
-
<mi mathvariant='normal'>°K</mi>
|
573
|
-
</mrow>
|
574
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu5' dimensionURL='#NISTd5'>
|
575
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
576
|
-
<UnitName xml:lang='en'>kelvin</UnitName>
|
577
|
-
<UnitSymbol type='HTML'>K</UnitSymbol>
|
578
|
-
<UnitSymbol type='MathML'>
|
579
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
580
|
-
<mrow>
|
581
|
-
<mi mathvariant='normal'>K</mi>
|
582
|
-
</mrow>
|
583
|
-
</math>
|
584
|
-
</UnitSymbol>
|
585
|
-
</Unit>
|
586
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd5'>
|
587
|
-
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
588
|
-
</Dimension>
|
589
|
-
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq5' dimensionURL='#NISTd5' quantityType='base'>
|
590
|
-
<QuantityName xml:lang='en-US'>thermodynamic temperature</QuantityName>
|
591
|
-
</Quantity>
|
592
|
-
<mo>+</mo>
|
593
|
-
<mn>10</mn>
|
594
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
595
|
-
<mrow xref='U_NISTu5'>
|
596
|
-
<mi mathvariant='normal'>K</mi>
|
597
|
-
</mrow>
|
598
|
-
</math>
|
599
|
-
OUTPUT
|
619
|
+
OUTPUT
|
600
620
|
end
|
601
621
|
|
602
622
|
it "deals with prefixed units" do
|
603
|
-
|
623
|
+
input = <<~INPUT
|
604
624
|
9 "unitsml(mbar)"
|
605
625
|
INPUT
|
606
|
-
|
607
|
-
|
608
|
-
<
|
609
|
-
|
610
|
-
<
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
<
|
615
|
-
|
616
|
-
|
617
|
-
<
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
<
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
626
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
627
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
628
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
629
|
+
<mn>9</mn>
|
630
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
631
|
+
<mrow xref='U_NISTu362'>
|
632
|
+
<mi mathvariant='normal'>mbar</mi>
|
633
|
+
</mrow>
|
634
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu362'>
|
635
|
+
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
636
|
+
<UnitName xml:lang='en'>millibar</UnitName>
|
637
|
+
<UnitSymbol type='HTML'>mbar</UnitSymbol>
|
638
|
+
<UnitSymbol type='MathML'>
|
639
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
640
|
+
<mrow>
|
641
|
+
<mi mathvariant='normal'>mbar</mi>
|
642
|
+
</mrow>
|
643
|
+
</math>
|
644
|
+
</UnitSymbol>
|
645
|
+
<RootUnits>
|
646
|
+
<EnumeratedRootUnit unit='bar' prefix='m'/>
|
647
|
+
</RootUnits>
|
648
|
+
</Unit>
|
649
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
|
650
|
+
<PrefixName xml:lang='en'>milli</PrefixName>
|
651
|
+
<PrefixSymbol type='ASCII'>m</PrefixSymbol>
|
652
|
+
<PrefixSymbol type='unicode'>m</PrefixSymbol>
|
653
|
+
<PrefixSymbol type='LaTeX'>m</PrefixSymbol>
|
654
|
+
<PrefixSymbol type='HTML'>m</PrefixSymbol>
|
655
|
+
</Prefix>
|
656
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd14'>
|
657
|
+
<Length symbol='L' powerNumerator='-1'/>
|
658
|
+
<Mass symbol='M' powerNumerator='1'/>
|
659
|
+
<Time symbol='T' powerNumerator='-2'/>
|
660
|
+
</Dimension>
|
661
|
+
</math>
|
662
|
+
OUTPUT
|
641
663
|
end
|
642
664
|
|
643
665
|
it "deals with standalone prefixes" do
|
644
|
-
|
666
|
+
input = <<~INPUT
|
645
667
|
"unitsml(p-)" "unitsml(da-)"
|
646
668
|
INPUT
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
<
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
<
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
669
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
670
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
671
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
672
|
+
<mrow xref='NISTp10_-12'>
|
673
|
+
<mi mathvariant='normal'>p</mi>
|
674
|
+
</mrow>
|
675
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-12' xml:id='NISTp10_-12'>
|
676
|
+
<PrefixName xml:lang='en'>pico</PrefixName>
|
677
|
+
<PrefixSymbol type='ASCII'>p</PrefixSymbol>
|
678
|
+
<PrefixSymbol type='unicode'>p</PrefixSymbol>
|
679
|
+
<PrefixSymbol type='LaTeX'>p</PrefixSymbol>
|
680
|
+
<PrefixSymbol type='HTML'>p</PrefixSymbol>
|
681
|
+
</Prefix>
|
682
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
683
|
+
<mrow xref='NISTp10_1'>
|
684
|
+
<mi mathvariant='normal'>da</mi>
|
685
|
+
</mrow>
|
686
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='1' xml:id='NISTp10_1'>
|
687
|
+
<PrefixName xml:lang='en'>deka</PrefixName>
|
688
|
+
<PrefixSymbol type='ASCII'>da</PrefixSymbol>
|
689
|
+
<PrefixSymbol type='unicode'>da</PrefixSymbol>
|
690
|
+
<PrefixSymbol type='LaTeX'>da</PrefixSymbol>
|
691
|
+
<PrefixSymbol type='HTML'>da</PrefixSymbol>
|
692
|
+
</Prefix>
|
693
|
+
</math>
|
694
|
+
OUTPUT
|
671
695
|
end
|
672
696
|
|
673
697
|
it "deals with HTML entities in UnitsDB" do
|
674
|
-
|
698
|
+
input = <<~INPUT
|
675
699
|
"unitsml(u-)" + "unitsml(um)"
|
676
700
|
INPUT
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
<
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
<
|
701
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
702
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
703
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
704
|
+
<mrow xref='NISTp10_-6'>
|
705
|
+
<mi mathvariant='normal'>µ</mi>
|
706
|
+
</mrow>
|
707
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-6' xml:id='NISTp10_-6'>
|
708
|
+
<PrefixName xml:lang='en'>micro</PrefixName>
|
709
|
+
<PrefixSymbol type='ASCII'>u</PrefixSymbol>
|
710
|
+
<PrefixSymbol type='unicode'>μ</PrefixSymbol>
|
711
|
+
<PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
|
712
|
+
<PrefixSymbol type='HTML'>µ</PrefixSymbol>
|
713
|
+
</Prefix>
|
714
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd2'>
|
715
|
+
<Mass symbol='M' powerNumerator='1'/>
|
716
|
+
</Dimension>
|
717
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
|
718
|
+
<QuantityName xml:lang='en-US'>mass</QuantityName>
|
719
|
+
</Quantity>
|
720
|
+
<mo>+</mo>
|
721
|
+
<mrow xref='U_um'>
|
722
|
+
<mi mathvariant='normal'>µm</mi>
|
723
|
+
</mrow>
|
724
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_um' dimensionURL='#NISTd1'>
|
725
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
726
|
+
<UnitName xml:lang='en'>um</UnitName>
|
727
|
+
<UnitSymbol type='HTML'>um</UnitSymbol>
|
728
|
+
<UnitSymbol type='MathML'>
|
729
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
730
|
+
<mrow>
|
731
|
+
<mi mathvariant='normal'>µm</mi>
|
732
|
+
</mrow>
|
733
|
+
</math>
|
734
|
+
</UnitSymbol>
|
735
|
+
<RootUnits>
|
736
|
+
<EnumeratedRootUnit unit='meter' prefix='u'/>
|
737
|
+
</RootUnits>
|
738
|
+
</Unit>
|
739
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
740
|
+
<Length symbol='L' powerNumerator='1'/>
|
741
|
+
</Dimension>
|
742
|
+
</math>
|
743
|
+
OUTPUT
|
744
|
+
end
|
745
|
+
|
746
|
+
it "deals with units division" do
|
747
|
+
input = <<~INPUT
|
748
|
+
9 "unitsml(A*C^3)" + 13 "unitsml(A/C^-3)" + 2 "unitsml(J/kg*K)"
|
749
|
+
INPUT
|
750
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
751
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
752
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
753
|
+
<mn>9</mn>
|
754
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
755
|
+
<mrow xref='U_A.C3'>
|
756
|
+
<mi mathvariant='normal'>A</mi>
|
757
|
+
<mo>⋅</mo>
|
758
|
+
<msup>
|
759
|
+
<mrow>
|
760
|
+
<mi mathvariant='normal'>C</mi>
|
761
|
+
</mrow>
|
762
|
+
<mrow>
|
763
|
+
<mn>3</mn>
|
764
|
+
</mrow>
|
765
|
+
</msup>
|
766
|
+
</mrow>
|
767
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_A.C3' dimensionURL='#D_M3I4'>
|
768
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
769
|
+
<UnitName xml:lang='en'>A*C^3</UnitName>
|
770
|
+
<UnitSymbol type='HTML'>
|
771
|
+
A⋅C
|
772
|
+
<sup>3</sup>
|
773
|
+
</UnitSymbol>
|
774
|
+
<UnitSymbol type='MathML'>
|
775
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
776
|
+
<mrow>
|
777
|
+
<mi mathvariant='normal'>A</mi>
|
778
|
+
<mo>⋅</mo>
|
779
|
+
<msup>
|
780
|
+
<mrow>
|
781
|
+
<mi mathvariant='normal'>C</mi>
|
782
|
+
</mrow>
|
783
|
+
<mrow>
|
784
|
+
<mn>3</mn>
|
785
|
+
</mrow>
|
786
|
+
</msup>
|
787
|
+
</mrow>
|
788
|
+
</math>
|
789
|
+
</UnitSymbol>
|
790
|
+
<RootUnits>
|
791
|
+
<EnumeratedRootUnit unit='ampere'/>
|
792
|
+
<EnumeratedRootUnit unit='coulomb' powerNumerator='3'/>
|
793
|
+
</RootUnits>
|
794
|
+
</Unit>
|
795
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_M3I4'>
|
796
|
+
<Mass symbol='M' powerNumerator='3'/>
|
797
|
+
<ElectricCurrent symbol='I' powerNumerator='4'/>
|
798
|
+
</Dimension>
|
799
|
+
<mo>+</mo>
|
800
|
+
<mn>13</mn>
|
801
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
802
|
+
<mrow xref='U_A/C-3'>
|
803
|
+
<mi mathvariant='normal'>A</mi>
|
804
|
+
<mo>/</mo>
|
805
|
+
<msup>
|
806
|
+
<mrow>
|
807
|
+
<mi mathvariant='normal'>C</mi>
|
808
|
+
</mrow>
|
809
|
+
<mrow>
|
810
|
+
<mo>−</mo>
|
811
|
+
<mn>3</mn>
|
812
|
+
</mrow>
|
813
|
+
</msup>
|
814
|
+
</mrow>
|
815
|
+
<mo>+</mo>
|
816
|
+
<mn>2</mn>
|
817
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
818
|
+
<mrow xref='U_J/kg.K'>
|
819
|
+
<mi mathvariant='normal'>J</mi>
|
820
|
+
<mo>/</mo>
|
821
|
+
<mi mathvariant='normal'>kg</mi>
|
822
|
+
<mo>⋅</mo>
|
823
|
+
<mi mathvariant='normal'>K</mi>
|
697
824
|
</mrow>
|
698
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='
|
825
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu13.u27p10_3e-1/1.u5e-1/1' dimensionURL='#D_L2M0T-2Theta-1'>
|
699
826
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
700
|
-
<UnitName xml:lang='en'>
|
701
|
-
<UnitSymbol type='HTML'>
|
827
|
+
<UnitName xml:lang='en'>joule per kilogram kelvin</UnitName>
|
828
|
+
<UnitSymbol type='HTML'>
|
829
|
+
J⋅kg
|
830
|
+
<sup>−1</sup>
|
831
|
+
⋅K
|
832
|
+
<sup>−1</sup>
|
833
|
+
</UnitSymbol>
|
702
834
|
<UnitSymbol type='MathML'>
|
703
835
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
704
836
|
<mrow>
|
705
|
-
<mi mathvariant='normal'
|
837
|
+
<mi mathvariant='normal'>J</mi>
|
838
|
+
<mo>⋅</mo>
|
839
|
+
<msup>
|
840
|
+
<mrow>
|
841
|
+
<mi mathvariant='normal'>kg</mi>
|
842
|
+
</mrow>
|
843
|
+
<mrow>
|
844
|
+
<mo>−</mo>
|
845
|
+
<mn>1</mn>
|
846
|
+
</mrow>
|
847
|
+
</msup>
|
848
|
+
<mo>⋅</mo>
|
849
|
+
<msup>
|
850
|
+
<mrow>
|
851
|
+
<mi mathvariant='normal'>K</mi>
|
852
|
+
</mrow>
|
853
|
+
<mrow>
|
854
|
+
<mo>−</mo>
|
855
|
+
<mn>1</mn>
|
856
|
+
</mrow>
|
857
|
+
</msup>
|
706
858
|
</mrow>
|
707
859
|
</math>
|
708
860
|
</UnitSymbol>
|
709
861
|
<RootUnits>
|
710
|
-
<EnumeratedRootUnit unit='
|
862
|
+
<EnumeratedRootUnit unit='joule'/>
|
863
|
+
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-1'/>
|
864
|
+
<EnumeratedRootUnit unit='kelvin' powerNumerator='-1'/>
|
711
865
|
</RootUnits>
|
712
866
|
</Unit>
|
713
|
-
<
|
714
|
-
<
|
867
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
868
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
869
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
870
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
871
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
872
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
873
|
+
</Prefix>
|
874
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd40'>
|
875
|
+
<Length symbol='L' powerNumerator='2'/>
|
876
|
+
<Time symbol='T' powerNumerator='-2'/>
|
877
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='-1'/>
|
715
878
|
</Dimension>
|
716
|
-
|
717
|
-
|
879
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L2M0T-2Theta-1'>
|
880
|
+
<Length symbol='L' powerNumerator='2'/>
|
881
|
+
<Mass symbol='M' powerNumerator='0'/>
|
882
|
+
<Time symbol='T' powerNumerator='-2'/>
|
883
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='-1'/>
|
884
|
+
</Dimension>
|
885
|
+
</math>
|
886
|
+
OUTPUT
|
718
887
|
end
|
719
888
|
|
720
|
-
it "
|
721
|
-
|
722
|
-
|
889
|
+
it "converts MathML to MatML + UnitsML" do
|
890
|
+
input = <<~INPUT
|
891
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
892
|
+
<mn>32</mn>
|
893
|
+
<mo>+</mo>
|
894
|
+
<mn>5</mn>
|
895
|
+
<mo>×</mo>
|
896
|
+
<mn>7</mn>
|
897
|
+
<mtext>unitsml(kg^-2)</mtext>
|
898
|
+
</math>
|
723
899
|
INPUT
|
724
|
-
|
725
|
-
|
900
|
+
output = <<~OUTPUT
|
901
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
902
|
+
<mn>32</mn>
|
903
|
+
<mo>+</mo>
|
904
|
+
<mn>5</mn>
|
905
|
+
<mo>×</mo>
|
906
|
+
<mn>7</mn>
|
726
907
|
<mo rspace='thickmathspace'>⁢</mo>
|
727
|
-
<mrow xref='
|
728
|
-
<mi mathvariant='normal'>A</mi>
|
729
|
-
<mo>⋅</mo>
|
908
|
+
<mrow xref='U_kg-2'>
|
730
909
|
<msup>
|
731
910
|
<mrow>
|
732
|
-
<mi mathvariant='normal'>
|
911
|
+
<mi mathvariant='normal'>kg</mi>
|
733
912
|
</mrow>
|
734
913
|
<mrow>
|
735
|
-
<
|
736
|
-
|
737
|
-
</msup>
|
738
|
-
</mrow>
|
739
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_A.C3' dimensionURL='#D_M3I4'>
|
740
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
741
|
-
<UnitName xml:lang='en'>A*C^3</UnitName>
|
742
|
-
<UnitSymbol type='HTML'>
|
743
|
-
A⋅C
|
744
|
-
<sup>3</sup>
|
745
|
-
</UnitSymbol>
|
746
|
-
<UnitSymbol type='MathML'>
|
747
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
748
|
-
<mrow>
|
749
|
-
<mi mathvariant='normal'>A</mi>
|
750
|
-
<mo>⋅</mo>
|
751
|
-
<msup>
|
752
|
-
<mrow>
|
753
|
-
<mi mathvariant='normal'>C</mi>
|
754
|
-
</mrow>
|
755
|
-
<mrow>
|
756
|
-
<mn>3</mn>
|
757
|
-
</mrow>
|
758
|
-
</msup>
|
759
|
-
</mrow>
|
760
|
-
</math>
|
761
|
-
</UnitSymbol>
|
762
|
-
<RootUnits>
|
763
|
-
<EnumeratedRootUnit unit='ampere'/>
|
764
|
-
<EnumeratedRootUnit unit='coulomb' powerNumerator='3'/>
|
765
|
-
</RootUnits>
|
766
|
-
</Unit>
|
767
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_M3I4'>
|
768
|
-
<Mass symbol='M' powerNumerator='3'/>
|
769
|
-
<ElectricCurrent symbol='I' powerNumerator='4'/>
|
770
|
-
</Dimension>
|
771
|
-
<mo>+</mo>
|
772
|
-
<mn>13</mn>
|
773
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
774
|
-
<mrow xref='U_A/C-3'>
|
775
|
-
<mi mathvariant='normal'>A</mi>
|
776
|
-
<mo>/</mo>
|
777
|
-
<msup>
|
778
|
-
<mrow>
|
779
|
-
<mi mathvariant='normal'>C</mi>
|
780
|
-
</mrow>
|
781
|
-
<mrow>
|
782
|
-
<mo>−</mo>
|
783
|
-
<mn>3</mn>
|
784
|
-
</mrow>
|
785
|
-
</msup>
|
786
|
-
</mrow>
|
787
|
-
<mo>+</mo>
|
788
|
-
<mn>2</mn>
|
789
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
790
|
-
<mrow xref='U_J/kg.K'>
|
791
|
-
<mi mathvariant='normal'>J</mi>
|
792
|
-
<mo>/</mo>
|
793
|
-
<mi mathvariant='normal'>kg</mi>
|
794
|
-
<mo>⋅</mo>
|
795
|
-
<mi mathvariant='normal'>K</mi>
|
796
|
-
</mrow>
|
797
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu13.u27p10_3e-1/1.u5e-1/1' dimensionURL='#D_L2M0T-2Theta-1'>
|
798
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
799
|
-
<UnitName xml:lang='en'>joule per kilogram kelvin</UnitName>
|
800
|
-
<UnitSymbol type='HTML'>
|
801
|
-
J⋅kg
|
802
|
-
<sup>−1</sup>
|
803
|
-
⋅K
|
804
|
-
<sup>−1</sup>
|
805
|
-
</UnitSymbol>
|
806
|
-
<UnitSymbol type='MathML'>
|
807
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
808
|
-
<mrow>
|
809
|
-
<mi mathvariant='normal'>J</mi>
|
810
|
-
<mo>⋅</mo>
|
811
|
-
<msup>
|
812
|
-
<mrow>
|
813
|
-
<mi mathvariant='normal'>kg</mi>
|
814
|
-
</mrow>
|
815
|
-
<mrow>
|
816
|
-
<mo>−</mo>
|
817
|
-
<mn>1</mn>
|
818
|
-
</mrow>
|
819
|
-
</msup>
|
820
|
-
<mo>⋅</mo>
|
821
|
-
<msup>
|
822
|
-
<mrow>
|
823
|
-
<mi mathvariant='normal'>K</mi>
|
824
|
-
</mrow>
|
825
|
-
<mrow>
|
826
|
-
<mo>−</mo>
|
827
|
-
<mn>1</mn>
|
828
|
-
</mrow>
|
829
|
-
</msup>
|
830
|
-
</mrow>
|
831
|
-
</math>
|
832
|
-
</UnitSymbol>
|
833
|
-
<RootUnits>
|
834
|
-
<EnumeratedRootUnit unit='joule'/>
|
835
|
-
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-1'/>
|
836
|
-
<EnumeratedRootUnit unit='kelvin' powerNumerator='-1'/>
|
837
|
-
</RootUnits>
|
838
|
-
</Unit>
|
839
|
-
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
840
|
-
<PrefixName xml:lang='en'>kilo</PrefixName>
|
841
|
-
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
842
|
-
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
843
|
-
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
844
|
-
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
845
|
-
</Prefix>
|
846
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd40'>
|
847
|
-
<Length symbol='L' powerNumerator='2'/>
|
848
|
-
<Time symbol='T' powerNumerator='-2'/>
|
849
|
-
<ThermodynamicTemperature symbol='Theta' powerNumerator='-1'/>
|
850
|
-
</Dimension>
|
851
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L2M0T-2Theta-1'>
|
852
|
-
<Length symbol='L' powerNumerator='2'/>
|
853
|
-
<Mass symbol='M' powerNumerator='0'/>
|
854
|
-
<Time symbol='T' powerNumerator='-2'/>
|
855
|
-
<ThermodynamicTemperature symbol='Theta' powerNumerator='-1'/>
|
856
|
-
</Dimension>
|
857
|
-
</math>
|
858
|
-
OUTPUT
|
859
|
-
end
|
860
|
-
|
861
|
-
it "converts MathML to MatML + UnitsML" do
|
862
|
-
input = <<~INPUT
|
863
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
864
|
-
<mn>32</mn>
|
865
|
-
<mo>+</mo>
|
866
|
-
<mn>5</mn>
|
867
|
-
<mo>×</mo>
|
868
|
-
<mn>7</mn>
|
869
|
-
<mtext>unitsml(kg^-2)</mtext>
|
870
|
-
</math>
|
871
|
-
INPUT
|
872
|
-
output = <<~OUTPUT
|
873
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
874
|
-
<mn>32</mn>
|
875
|
-
<mo>+</mo>
|
876
|
-
<mn>5</mn>
|
877
|
-
<mo>×</mo>
|
878
|
-
<mn>7</mn>
|
879
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
880
|
-
<mrow xref='U_kg-2'>
|
881
|
-
<msup>
|
882
|
-
<mrow>
|
883
|
-
<mi mathvariant='normal'>kg</mi>
|
884
|
-
</mrow>
|
885
|
-
<mrow>
|
886
|
-
<mo>−</mo>
|
887
|
-
<mn>2</mn>
|
914
|
+
<mo>−</mo>
|
915
|
+
<mn>2</mn>
|
888
916
|
</mrow>
|
889
917
|
</msup>
|
890
918
|
</mrow>
|
@@ -934,524 +962,572 @@ RSpec.describe Asciimath2UnitsML do
|
|
934
962
|
end
|
935
963
|
|
936
964
|
it "raises error for illegal unit" do
|
937
|
-
|
938
|
-
|
965
|
+
input = <<~INPUT
|
966
|
+
12 "unitsml(que?)"
|
939
967
|
INPUT
|
968
|
+
expect { xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)) }
|
969
|
+
.to raise_error(Rsec::SyntaxError)
|
940
970
|
end
|
941
971
|
|
942
972
|
it "initialises multiplier" do
|
943
|
-
|
973
|
+
input = <<~INPUT
|
944
974
|
1 "unitsml(kg*s^-2)"
|
945
975
|
INPUT
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
<mrow xref='U_kg.s-2'>
|
950
|
-
<mi mathvariant='normal'>kg</mi>
|
951
|
-
<mo>×</mo>
|
952
|
-
<msup>
|
953
|
-
<mrow>
|
954
|
-
<mi mathvariant='normal'>s</mi>
|
955
|
-
</mrow>
|
956
|
-
<mrow>
|
957
|
-
<mo>−</mo>
|
958
|
-
<mn>2</mn>
|
959
|
-
</mrow>
|
960
|
-
</msup>
|
961
|
-
</mrow>
|
962
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
963
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
964
|
-
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
965
|
-
<UnitSymbol type='HTML'>
|
966
|
-
kg×s
|
967
|
-
<sup>−2</sup>
|
968
|
-
</UnitSymbol>
|
969
|
-
<UnitSymbol type='MathML'>
|
976
|
+
expect(xmlpp(Asciimath2UnitsML::Conv
|
977
|
+
.new(multiplier: "\u00d7")
|
978
|
+
.Asciimath2UnitsML(input))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
970
979
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
980
|
+
<mn>1</mn>
|
981
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
982
|
+
<mrow xref='U_kg.s-2'>
|
983
|
+
<mi mathvariant='normal'>kg</mi>
|
984
|
+
<mo>×</mo>
|
985
|
+
<msup>
|
971
986
|
<mrow>
|
972
|
-
<mi mathvariant='normal'>
|
973
|
-
<mo>×</mo>
|
974
|
-
<msup>
|
975
|
-
<mrow>
|
976
|
-
<mi mathvariant='normal'>s</mi>
|
977
|
-
</mrow>
|
978
|
-
<mrow>
|
979
|
-
<mo>−</mo>
|
980
|
-
<mn>2</mn>
|
981
|
-
</mrow>
|
982
|
-
</msup>
|
987
|
+
<mi mathvariant='normal'>s</mi>
|
983
988
|
</mrow>
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
</
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
989
|
+
<mrow>
|
990
|
+
<mo>−</mo>
|
991
|
+
<mn>2</mn>
|
992
|
+
</mrow>
|
993
|
+
</msup>
|
994
|
+
</mrow>
|
995
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
996
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
997
|
+
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
998
|
+
<UnitSymbol type='HTML'>
|
999
|
+
kg×s
|
1000
|
+
<sup>−2</sup>
|
1001
|
+
</UnitSymbol>
|
1002
|
+
<UnitSymbol type='MathML'>
|
1003
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1004
|
+
<mrow>
|
1005
|
+
<mi mathvariant='normal'>kg</mi>
|
1006
|
+
<mo>×</mo>
|
1007
|
+
<msup>
|
1008
|
+
<mrow>
|
1009
|
+
<mi mathvariant='normal'>s</mi>
|
1010
|
+
</mrow>
|
1011
|
+
<mrow>
|
1012
|
+
<mo>−</mo>
|
1013
|
+
<mn>2</mn>
|
1014
|
+
</mrow>
|
1015
|
+
</msup>
|
1016
|
+
</mrow>
|
1017
|
+
</math>
|
1018
|
+
</UnitSymbol>
|
1019
|
+
<RootUnits>
|
1020
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
1021
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1022
|
+
</RootUnits>
|
1023
|
+
</Unit>
|
1024
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
1025
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
1026
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
1027
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
1028
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
1029
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
1030
|
+
</Prefix>
|
1031
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
1032
|
+
<Mass symbol='M' powerNumerator='1'/>
|
1033
|
+
<Time symbol='T' powerNumerator='-2'/>
|
1034
|
+
</Dimension>
|
1035
|
+
</math>
|
1036
|
+
OUTPUT
|
1037
|
+
input = <<~INPUT
|
1005
1038
|
1 "unitsml(kg*s^-2)"
|
1006
1039
|
INPUT
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
<
|
1040
|
+
expect(xmlpp(Asciimath2UnitsML::Conv
|
1041
|
+
.new(multiplier: :space)
|
1042
|
+
.Asciimath2UnitsML(input))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
1043
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1044
|
+
<mn>1</mn>
|
1012
1045
|
<mo rspace='thickmathspace'>⁢</mo>
|
1013
|
-
<
|
1014
|
-
<
|
1015
|
-
|
1016
|
-
|
1017
|
-
<mrow>
|
1018
|
-
<mo>−</mo>
|
1019
|
-
<mn>2</mn>
|
1020
|
-
</mrow>
|
1021
|
-
</msup>
|
1022
|
-
</mrow>
|
1023
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
1024
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1025
|
-
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
1026
|
-
<UnitSymbol type='HTML'>
|
1027
|
-
kg s
|
1028
|
-
<sup>−2</sup>
|
1029
|
-
</UnitSymbol>
|
1030
|
-
<UnitSymbol type='MathML'>
|
1031
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1046
|
+
<mrow xref='U_kg.s-2'>
|
1047
|
+
<mi mathvariant='normal'>kg</mi>
|
1048
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1049
|
+
<msup>
|
1032
1050
|
<mrow>
|
1033
|
-
<mi mathvariant='normal'>
|
1034
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
1035
|
-
<msup>
|
1036
|
-
<mrow>
|
1037
|
-
<mi mathvariant='normal'>s</mi>
|
1038
|
-
</mrow>
|
1039
|
-
<mrow>
|
1040
|
-
<mo>−</mo>
|
1041
|
-
<mn>2</mn>
|
1042
|
-
</mrow>
|
1043
|
-
</msup>
|
1051
|
+
<mi mathvariant='normal'>s</mi>
|
1044
1052
|
</mrow>
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
</
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1053
|
+
<mrow>
|
1054
|
+
<mo>−</mo>
|
1055
|
+
<mn>2</mn>
|
1056
|
+
</mrow>
|
1057
|
+
</msup>
|
1058
|
+
</mrow>
|
1059
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
1060
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1061
|
+
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
1062
|
+
<UnitSymbol type='HTML'>
|
1063
|
+
kg s
|
1064
|
+
<sup>−2</sup>
|
1065
|
+
</UnitSymbol>
|
1066
|
+
<UnitSymbol type='MathML'>
|
1067
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1068
|
+
<mrow>
|
1069
|
+
<mi mathvariant='normal'>kg</mi>
|
1070
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1071
|
+
<msup>
|
1072
|
+
<mrow>
|
1073
|
+
<mi mathvariant='normal'>s</mi>
|
1074
|
+
</mrow>
|
1075
|
+
<mrow>
|
1076
|
+
<mo>−</mo>
|
1077
|
+
<mn>2</mn>
|
1078
|
+
</mrow>
|
1079
|
+
</msup>
|
1080
|
+
</mrow>
|
1081
|
+
</math>
|
1082
|
+
</UnitSymbol>
|
1083
|
+
<RootUnits>
|
1084
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
1085
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1086
|
+
</RootUnits>
|
1087
|
+
</Unit>
|
1088
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
1089
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
1090
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
1091
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
1092
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
1093
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
1094
|
+
</Prefix>
|
1095
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
1096
|
+
<Mass symbol='M' powerNumerator='1'/>
|
1097
|
+
<Time symbol='T' powerNumerator='-2'/>
|
1098
|
+
</Dimension>
|
1099
|
+
</math>
|
1100
|
+
OUTPUT
|
1101
|
+
input = <<~INPUT
|
1066
1102
|
1 "unitsml(kg*s^-2)"
|
1067
1103
|
INPUT
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
<mrow xref='U_kg.s-2'>
|
1072
|
-
<mi mathvariant='normal'>kg</mi>
|
1073
|
-
<mo>⁢</mo>
|
1074
|
-
<msup>
|
1075
|
-
<mrow>
|
1076
|
-
<mi mathvariant='normal'>s</mi>
|
1077
|
-
</mrow>
|
1078
|
-
<mrow>
|
1079
|
-
<mo>−</mo>
|
1080
|
-
<mn>2</mn>
|
1081
|
-
</mrow>
|
1082
|
-
</msup>
|
1083
|
-
</mrow>
|
1084
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
1085
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1086
|
-
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
1087
|
-
<UnitSymbol type='HTML'>
|
1088
|
-
kgs
|
1089
|
-
<sup>−2</sup>
|
1090
|
-
</UnitSymbol>
|
1091
|
-
<UnitSymbol type='MathML'>
|
1104
|
+
expect(xmlpp(Asciimath2UnitsML::Conv
|
1105
|
+
.new(multiplier: :nospace)
|
1106
|
+
.Asciimath2UnitsML(input))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
1092
1107
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1108
|
+
<mn>1</mn>
|
1109
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1110
|
+
<mrow xref='U_kg.s-2'>
|
1111
|
+
<mi mathvariant='normal'>kg</mi>
|
1112
|
+
<mo>⁢</mo>
|
1113
|
+
<msup>
|
1093
1114
|
<mrow>
|
1094
|
-
<mi mathvariant='normal'>
|
1095
|
-
<mo>⁢</mo>
|
1096
|
-
<msup>
|
1097
|
-
<mrow>
|
1098
|
-
<mi mathvariant='normal'>s</mi>
|
1099
|
-
</mrow>
|
1100
|
-
<mrow>
|
1101
|
-
<mo>−</mo>
|
1102
|
-
<mn>2</mn>
|
1103
|
-
</mrow>
|
1104
|
-
</msup>
|
1115
|
+
<mi mathvariant='normal'>s</mi>
|
1105
1116
|
</mrow>
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
</
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1117
|
+
<mrow>
|
1118
|
+
<mo>−</mo>
|
1119
|
+
<mn>2</mn>
|
1120
|
+
</mrow>
|
1121
|
+
</msup>
|
1122
|
+
</mrow>
|
1123
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
1124
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1125
|
+
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
1126
|
+
<UnitSymbol type='HTML'>
|
1127
|
+
kgs
|
1128
|
+
<sup>−2</sup>
|
1129
|
+
</UnitSymbol>
|
1130
|
+
<UnitSymbol type='MathML'>
|
1131
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1132
|
+
<mrow>
|
1133
|
+
<mi mathvariant='normal'>kg</mi>
|
1134
|
+
<mo>⁢</mo>
|
1135
|
+
<msup>
|
1136
|
+
<mrow>
|
1137
|
+
<mi mathvariant='normal'>s</mi>
|
1138
|
+
</mrow>
|
1139
|
+
<mrow>
|
1140
|
+
<mo>−</mo>
|
1141
|
+
<mn>2</mn>
|
1142
|
+
</mrow>
|
1143
|
+
</msup>
|
1144
|
+
</mrow>
|
1145
|
+
</math>
|
1146
|
+
</UnitSymbol>
|
1147
|
+
<RootUnits>
|
1148
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
1149
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1150
|
+
</RootUnits>
|
1151
|
+
</Unit>
|
1152
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
1153
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
1154
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
1155
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
1156
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
1157
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
1158
|
+
</Prefix>
|
1159
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
1160
|
+
<Mass symbol='M' powerNumerator='1'/>
|
1161
|
+
<Time symbol='T' powerNumerator='-2'/>
|
1162
|
+
</Dimension>
|
1163
|
+
</math>
|
1164
|
+
OUTPUT
|
1126
1165
|
end
|
1127
1166
|
|
1128
1167
|
it "deals with dimension decomposition with like units" do
|
1129
|
-
|
1168
|
+
input = <<~INPUT
|
1130
1169
|
9 "unitsml(mW*cm^(-2))"
|
1131
1170
|
INPUT
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
<
|
1137
|
-
<
|
1138
|
-
|
1139
|
-
<
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
<mn>2</mn>
|
1145
|
-
</mrow>
|
1146
|
-
</msup>
|
1147
|
-
</mrow>
|
1148
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_mW.cm-2'>
|
1149
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1150
|
-
<UnitName xml:lang='en'>mW*cm^-2</UnitName>
|
1151
|
-
<UnitSymbol type='HTML'>
|
1152
|
-
mW⋅cm
|
1153
|
-
<sup>−2</sup>
|
1154
|
-
</UnitSymbol>
|
1155
|
-
<UnitSymbol type='MathML'>
|
1156
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1171
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
1172
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
1173
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1174
|
+
<mn>9</mn>
|
1175
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1176
|
+
<mrow xref='U_mW.cm-2'>
|
1177
|
+
<mi mathvariant='normal'>mW</mi>
|
1178
|
+
<mo>⋅</mo>
|
1179
|
+
<msup>
|
1180
|
+
<mrow>
|
1181
|
+
<mi mathvariant='normal'>cm</mi>
|
1182
|
+
</mrow>
|
1157
1183
|
<mrow>
|
1158
|
-
<
|
1159
|
-
<
|
1160
|
-
<msup>
|
1161
|
-
<mrow>
|
1162
|
-
<mi mathvariant='normal'>cm</mi>
|
1163
|
-
</mrow>
|
1164
|
-
<mrow>
|
1165
|
-
<mo>−</mo>
|
1166
|
-
<mn>2</mn>
|
1167
|
-
</mrow>
|
1168
|
-
</msup>
|
1184
|
+
<mo>−</mo>
|
1185
|
+
<mn>2</mn>
|
1169
1186
|
</mrow>
|
1170
|
-
</
|
1171
|
-
</
|
1172
|
-
<
|
1173
|
-
<
|
1174
|
-
<
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1187
|
+
</msup>
|
1188
|
+
</mrow>
|
1189
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_mW.cm-2'>
|
1190
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1191
|
+
<UnitName xml:lang='en'>mW*cm^-2</UnitName>
|
1192
|
+
<UnitSymbol type='HTML'>
|
1193
|
+
mW⋅cm
|
1194
|
+
<sup>−2</sup>
|
1195
|
+
</UnitSymbol>
|
1196
|
+
<UnitSymbol type='MathML'>
|
1197
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1198
|
+
<mrow>
|
1199
|
+
<mi mathvariant='normal'>mW</mi>
|
1200
|
+
<mo>⋅</mo>
|
1201
|
+
<msup>
|
1202
|
+
<mrow>
|
1203
|
+
<mi mathvariant='normal'>cm</mi>
|
1204
|
+
</mrow>
|
1205
|
+
<mrow>
|
1206
|
+
<mo>−</mo>
|
1207
|
+
<mn>2</mn>
|
1208
|
+
</mrow>
|
1209
|
+
</msup>
|
1210
|
+
</mrow>
|
1211
|
+
</math>
|
1212
|
+
</UnitSymbol>
|
1213
|
+
<RootUnits>
|
1214
|
+
<EnumeratedRootUnit unit='watt' prefix='m'/>
|
1215
|
+
<EnumeratedRootUnit unit='meter' prefix='c' powerNumerator='-2'/>
|
1216
|
+
</RootUnits>
|
1217
|
+
</Unit>
|
1218
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
|
1219
|
+
<PrefixName xml:lang='en'>milli</PrefixName>
|
1220
|
+
<PrefixSymbol type='ASCII'>m</PrefixSymbol>
|
1221
|
+
<PrefixSymbol type='unicode'>m</PrefixSymbol>
|
1222
|
+
<PrefixSymbol type='LaTeX'>m</PrefixSymbol>
|
1223
|
+
<PrefixSymbol type='HTML'>m</PrefixSymbol>
|
1224
|
+
</Prefix>
|
1225
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1226
|
+
<PrefixName xml:lang='en'>centi</PrefixName>
|
1227
|
+
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1228
|
+
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1229
|
+
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1230
|
+
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1231
|
+
</Prefix>
|
1232
|
+
</math>
|
1233
|
+
OUTPUT
|
1193
1234
|
end
|
1194
1235
|
|
1195
1236
|
it "deals with quantity input" do
|
1196
|
-
|
1237
|
+
input = <<~INPUT
|
1197
1238
|
9 "unitsml(m, quantity: NISTq103)"
|
1198
1239
|
INPUT
|
1199
|
-
|
1200
|
-
|
1201
|
-
<
|
1202
|
-
|
1203
|
-
<
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
<
|
1208
|
-
|
1209
|
-
|
1210
|
-
<
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1240
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
1241
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
1242
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1243
|
+
<mn>9</mn>
|
1244
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1245
|
+
<mrow xref='U_NISTu1'>
|
1246
|
+
<mi mathvariant='normal'>m</mi>
|
1247
|
+
</mrow>
|
1248
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
1249
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1250
|
+
<UnitName xml:lang='en'>meter</UnitName>
|
1251
|
+
<UnitSymbol type='HTML'>m</UnitSymbol>
|
1252
|
+
<UnitSymbol type='MathML'>
|
1253
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1254
|
+
<mrow>
|
1255
|
+
<mi mathvariant='normal'>m</mi>
|
1256
|
+
</mrow>
|
1257
|
+
</math>
|
1258
|
+
</UnitSymbol>
|
1259
|
+
</Unit>
|
1260
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
1261
|
+
<Length symbol='L' powerNumerator='1'/>
|
1262
|
+
</Dimension>
|
1263
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq103' dimensionURL='#NISTd1' quantityType='base'>
|
1264
|
+
<QuantityName xml:lang='en-US'>position vector</QuantityName>
|
1265
|
+
</Quantity>
|
1266
|
+
</math>
|
1267
|
+
OUTPUT
|
1225
1268
|
end
|
1226
1269
|
|
1227
1270
|
it "deals with name input" do
|
1228
|
-
|
1271
|
+
input = <<~INPUT
|
1229
1272
|
9 "unitsml(cal_th/cm^2, name: langley)"
|
1230
1273
|
INPUT
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
<
|
1236
|
-
|
1237
|
-
|
1238
|
-
</mrow>
|
1239
|
-
<mrow>
|
1240
|
-
<mi mathvariant='normal'>th</mi>
|
1241
|
-
</mrow>
|
1242
|
-
</msub>
|
1243
|
-
<mo>/</mo>
|
1244
|
-
<msup>
|
1245
|
-
<mrow>
|
1246
|
-
<mi mathvariant='normal'>cm</mi>
|
1247
|
-
</mrow>
|
1248
|
-
<mrow>
|
1249
|
-
<mn>2</mn>
|
1250
|
-
</mrow>
|
1251
|
-
</msup>
|
1252
|
-
</mrow>
|
1253
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cal_th.cm-2'>
|
1254
|
-
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
1255
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1256
|
-
<UnitName xml:lang='en'>langley</UnitName>
|
1257
|
-
<UnitSymbol type='HTML'>
|
1258
|
-
cal
|
1259
|
-
<sub>th</sub>
|
1260
|
-
⋅cm
|
1261
|
-
<sup>−2</sup>
|
1262
|
-
</UnitSymbol>
|
1263
|
-
<UnitSymbol type='MathML'>
|
1264
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1274
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
1275
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
1276
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1277
|
+
<mn>9</mn>
|
1278
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1279
|
+
<mrow xref='U_cal_th/cm2'>
|
1280
|
+
<msub>
|
1265
1281
|
<mrow>
|
1266
|
-
<
|
1267
|
-
<mrow>
|
1268
|
-
<mi mathvariant='normal'>cal</mi>
|
1269
|
-
</mrow>
|
1270
|
-
<mrow>
|
1271
|
-
<mi mathvariant='normal'>th</mi>
|
1272
|
-
</mrow>
|
1273
|
-
</msub>
|
1274
|
-
<mo>⋅</mo>
|
1275
|
-
<msup>
|
1276
|
-
<mrow>
|
1277
|
-
<mi mathvariant='normal'>cm</mi>
|
1278
|
-
</mrow>
|
1279
|
-
<mrow>
|
1280
|
-
<mo>−</mo>
|
1281
|
-
<mn>2</mn>
|
1282
|
-
</mrow>
|
1283
|
-
</msup>
|
1282
|
+
<mi mathvariant='normal'>cal</mi>
|
1284
1283
|
</mrow>
|
1285
|
-
</math>
|
1286
|
-
</UnitSymbol>
|
1287
|
-
<RootUnits>
|
1288
|
-
<EnumeratedRootUnit unit='thermochemical calorie'/>
|
1289
|
-
<EnumeratedRootUnit unit='meter' prefix='c' powerNumerator='-2'/>
|
1290
|
-
</RootUnits>
|
1291
|
-
</Unit>
|
1292
|
-
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1293
|
-
<PrefixName xml:lang='en'>centi</PrefixName>
|
1294
|
-
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1295
|
-
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1296
|
-
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1297
|
-
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1298
|
-
</Prefix>
|
1299
|
-
</math>
|
1300
|
-
OUTPUT
|
1301
|
-
end
|
1302
|
-
|
1303
|
-
it "deals with symbol input" do
|
1304
|
-
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
1305
|
-
9 "unitsml(m, symbol: La)" + 10 "unitsml(cm*s^-2, symbol: cm cdot s^-2)"
|
1306
|
-
INPUT
|
1307
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1308
|
-
<mn>9</mn>
|
1309
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
1310
|
-
<mrow xref='U_NISTu1'>
|
1311
|
-
<math>
|
1312
|
-
<mi mathvariant='normal'>L</mi>
|
1313
|
-
<mi mathvariant='normal'>a</mi>
|
1314
|
-
</math>
|
1315
|
-
</mrow>
|
1316
|
-
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
1317
|
-
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1318
|
-
<UnitName xml:lang='en'>meter</UnitName>
|
1319
|
-
<UnitSymbol type='HTML'>m</UnitSymbol>
|
1320
|
-
<UnitSymbol type='MathML'>
|
1321
|
-
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1322
1284
|
<mrow>
|
1323
|
-
<mi mathvariant='normal'>
|
1285
|
+
<mi mathvariant='normal'>th</mi>
|
1324
1286
|
</mrow>
|
1325
|
-
</
|
1326
|
-
|
1327
|
-
</Unit>
|
1328
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
1329
|
-
<Length symbol='L' powerNumerator='1'/>
|
1330
|
-
</Dimension>
|
1331
|
-
<mo>+</mo>
|
1332
|
-
<mn>10</mn>
|
1333
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
1334
|
-
<mrow xref='U_cm.s-2'>
|
1335
|
-
<math>
|
1336
|
-
<mi mathvariant='normal'>c</mi>
|
1337
|
-
<mi mathvariant='normal'>m</mi>
|
1338
|
-
<mo>⋅</mo>
|
1287
|
+
</msub>
|
1288
|
+
<mo>/</mo>
|
1339
1289
|
<msup>
|
1340
1290
|
<mrow>
|
1341
|
-
<mi mathvariant='normal'>
|
1291
|
+
<mi mathvariant='normal'>cm</mi>
|
1342
1292
|
</mrow>
|
1343
1293
|
<mrow>
|
1344
|
-
<
|
1294
|
+
<mn>2</mn>
|
1345
1295
|
</mrow>
|
1346
1296
|
</msup>
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
<
|
1359
|
-
<
|
1360
|
-
<
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
<
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1297
|
+
</mrow>
|
1298
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cal_th.cm-2'>
|
1299
|
+
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
1300
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1301
|
+
<UnitName xml:lang='en'>langley</UnitName>
|
1302
|
+
<UnitSymbol type='HTML'>
|
1303
|
+
cal
|
1304
|
+
<sub>th</sub>
|
1305
|
+
⋅cm
|
1306
|
+
<sup>−2</sup>
|
1307
|
+
</UnitSymbol>
|
1308
|
+
<UnitSymbol type='MathML'>
|
1309
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1310
|
+
<mrow>
|
1311
|
+
<msub>
|
1312
|
+
<mrow>
|
1313
|
+
<mi mathvariant='normal'>cal</mi>
|
1314
|
+
</mrow>
|
1315
|
+
<mrow>
|
1316
|
+
<mi mathvariant='normal'>th</mi>
|
1317
|
+
</mrow>
|
1318
|
+
</msub>
|
1319
|
+
<mo>⋅</mo>
|
1320
|
+
<msup>
|
1321
|
+
<mrow>
|
1322
|
+
<mi mathvariant='normal'>cm</mi>
|
1323
|
+
</mrow>
|
1324
|
+
<mrow>
|
1325
|
+
<mo>−</mo>
|
1326
|
+
<mn>2</mn>
|
1327
|
+
</mrow>
|
1328
|
+
</msup>
|
1329
|
+
</mrow>
|
1330
|
+
</math>
|
1331
|
+
</UnitSymbol>
|
1332
|
+
<RootUnits>
|
1333
|
+
<EnumeratedRootUnit unit='thermochemical calorie'/>
|
1334
|
+
<EnumeratedRootUnit unit='meter' prefix='c' powerNumerator='-2'/>
|
1335
|
+
</RootUnits>
|
1336
|
+
</Unit>
|
1337
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1338
|
+
<PrefixName xml:lang='en'>centi</PrefixName>
|
1339
|
+
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1340
|
+
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1341
|
+
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1342
|
+
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1343
|
+
</Prefix>
|
1344
|
+
</math>
|
1345
|
+
OUTPUT
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
it "deals with symbol input" do
|
1349
|
+
input = <<~INPUT
|
1350
|
+
9 "unitsml(m, symbol: La)" + 10 "unitsml(cm*s^-2, symbol: cm cdot s^-2)"
|
1351
|
+
INPUT
|
1352
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
1353
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
1354
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1355
|
+
<mn>9</mn>
|
1356
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1357
|
+
<mrow xref='U_NISTu1'>
|
1358
|
+
<math>
|
1359
|
+
<mi mathvariant='normal'>L</mi>
|
1360
|
+
<mi mathvariant='normal'>a</mi>
|
1361
|
+
</math>
|
1362
|
+
</mrow>
|
1363
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
1364
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1365
|
+
<UnitName xml:lang='en'>meter</UnitName>
|
1366
|
+
<UnitSymbol type='HTML'>m</UnitSymbol>
|
1367
|
+
<UnitSymbol type='MathML'>
|
1368
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1369
|
+
<mrow>
|
1370
|
+
<mi mathvariant='normal'>m</mi>
|
1371
|
+
</mrow>
|
1372
|
+
</math>
|
1373
|
+
</UnitSymbol>
|
1374
|
+
</Unit>
|
1375
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
1376
|
+
<Length symbol='L' powerNumerator='1'/>
|
1377
|
+
</Dimension>
|
1378
|
+
<mo>+</mo>
|
1379
|
+
<mn>10</mn>
|
1380
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1381
|
+
<mrow xref='U_cm.s-2'>
|
1382
|
+
<math>
|
1383
|
+
<mi mathvariant='normal'>c</mi>
|
1384
|
+
<mi mathvariant='normal'>m</mi>
|
1385
|
+
<mo>⋅</mo>
|
1386
|
+
<msup>
|
1387
|
+
<mrow>
|
1388
|
+
<mi mathvariant='normal'>s</mi>
|
1389
|
+
</mrow>
|
1390
|
+
<mrow>
|
1391
|
+
<mo>−</mo>
|
1392
|
+
</mrow>
|
1393
|
+
</msup>
|
1394
|
+
<mn>2</mn>
|
1395
|
+
</math>
|
1396
|
+
</mrow>
|
1397
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cm.s-2' dimensionURL='#NISTd28'>
|
1398
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1399
|
+
<UnitName xml:lang='en'>cm*s^-2</UnitName>
|
1400
|
+
<UnitSymbol type='HTML'>
|
1401
|
+
cm⋅s
|
1402
|
+
<sup>−2</sup>
|
1403
|
+
</UnitSymbol>
|
1404
|
+
<UnitSymbol type='MathML'>
|
1405
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1406
|
+
<mrow>
|
1407
|
+
<mi mathvariant='normal'>cm</mi>
|
1408
|
+
<mo>⋅</mo>
|
1409
|
+
<msup>
|
1410
|
+
<mrow>
|
1411
|
+
<mi mathvariant='normal'>s</mi>
|
1412
|
+
</mrow>
|
1413
|
+
<mrow>
|
1414
|
+
<mo>−</mo>
|
1415
|
+
<mn>2</mn>
|
1416
|
+
</mrow>
|
1417
|
+
</msup>
|
1418
|
+
</mrow>
|
1419
|
+
</math>
|
1420
|
+
</UnitSymbol>
|
1421
|
+
<RootUnits>
|
1422
|
+
<EnumeratedRootUnit unit='meter' prefix='c'/>
|
1423
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1424
|
+
</RootUnits>
|
1425
|
+
</Unit>
|
1426
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1427
|
+
<PrefixName xml:lang='en'>centi</PrefixName>
|
1428
|
+
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1429
|
+
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1430
|
+
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1431
|
+
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1432
|
+
</Prefix>
|
1433
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
1434
|
+
<Length symbol='L' powerNumerator='1'/>
|
1435
|
+
<Time symbol='T' powerNumerator='-2'/>
|
1436
|
+
</Dimension>
|
1437
|
+
</math>
|
1438
|
+
OUTPUT
|
1392
1439
|
end
|
1393
1440
|
|
1394
1441
|
it "deals with multiplier input" do
|
1395
|
-
|
1442
|
+
input = <<~INPUT
|
1396
1443
|
10 "unitsml(cm*s^-2, multiplier: xx)"
|
1397
1444
|
INPUT
|
1398
|
-
|
1399
|
-
|
1400
|
-
<
|
1401
|
-
|
1402
|
-
<
|
1403
|
-
<
|
1404
|
-
|
1405
|
-
<
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
<
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
<
|
1417
|
-
|
1418
|
-
cm
|
1419
|
-
<
|
1420
|
-
|
1421
|
-
|
1445
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
1446
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
1447
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1448
|
+
<mn>10</mn>
|
1449
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1450
|
+
<mrow xref='U_cm.s-2'>
|
1451
|
+
<mi mathvariant='normal'>cm</mi>
|
1452
|
+
<mo>xx</mo>
|
1453
|
+
<msup>
|
1454
|
+
<mrow>
|
1455
|
+
<mi mathvariant='normal'>s</mi>
|
1456
|
+
</mrow>
|
1457
|
+
<mrow>
|
1458
|
+
<mo>−</mo>
|
1459
|
+
<mn>2</mn>
|
1460
|
+
</mrow>
|
1461
|
+
</msup>
|
1462
|
+
</mrow>
|
1463
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cm.s-2' dimensionURL='#NISTd28'>
|
1464
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1465
|
+
<UnitName xml:lang='en'>cm*s^-2</UnitName>
|
1466
|
+
<UnitSymbol type='HTML'>
|
1467
|
+
cm⋅s
|
1468
|
+
<sup>−2</sup>
|
1469
|
+
</UnitSymbol>
|
1470
|
+
<UnitSymbol type='MathML'>
|
1471
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1472
|
+
<mrow>
|
1473
|
+
<mi mathvariant='normal'>cm</mi>
|
1474
|
+
<mo>⋅</mo>
|
1475
|
+
<msup>
|
1476
|
+
<mrow>
|
1477
|
+
<mi mathvariant='normal'>s</mi>
|
1478
|
+
</mrow>
|
1479
|
+
<mrow>
|
1480
|
+
<mo>−</mo>
|
1481
|
+
<mn>2</mn>
|
1482
|
+
</mrow>
|
1483
|
+
</msup>
|
1484
|
+
</mrow>
|
1485
|
+
</math>
|
1486
|
+
</UnitSymbol>
|
1487
|
+
<RootUnits>
|
1488
|
+
<EnumeratedRootUnit unit='meter' prefix='c'/>
|
1489
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1490
|
+
</RootUnits>
|
1491
|
+
</Unit>
|
1492
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1493
|
+
<PrefixName xml:lang='en'>centi</PrefixName>
|
1494
|
+
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1495
|
+
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1496
|
+
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1497
|
+
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1498
|
+
</Prefix>
|
1499
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
1500
|
+
<Length symbol='L' powerNumerator='1'/>
|
1501
|
+
<Time symbol='T' powerNumerator='-2'/>
|
1502
|
+
</Dimension>
|
1503
|
+
</math>
|
1504
|
+
OUTPUT
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
it "deals with dimensions" do
|
1508
|
+
input = <<~INPUT
|
1509
|
+
"unitsml(dim_Theta*dim_L^2)"
|
1510
|
+
INPUT
|
1511
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new.Asciimath2UnitsML(input)))
|
1512
|
+
.to be_equivalent_to xmlpp(<<~OUTPUT)
|
1422
1513
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1514
|
+
<mrow xref='U_dim_Theta.dim_L2'>
|
1515
|
+
<mi mathvariant='sans-serif'>Θ</mi>
|
1516
|
+
<mo>⋅</mo>
|
1517
|
+
<msup>
|
1423
1518
|
<mrow>
|
1424
|
-
<mi mathvariant='
|
1425
|
-
<mo>⋅</mo>
|
1426
|
-
<msup>
|
1427
|
-
<mrow>
|
1428
|
-
<mi mathvariant='normal'>s</mi>
|
1429
|
-
</mrow>
|
1430
|
-
<mrow>
|
1431
|
-
<mo>−</mo>
|
1432
|
-
<mn>2</mn>
|
1433
|
-
</mrow>
|
1434
|
-
</msup>
|
1519
|
+
<mi mathvariant='sans-serif'>L</mi>
|
1435
1520
|
</mrow>
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1448
|
-
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1449
|
-
</Prefix>
|
1450
|
-
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
1451
|
-
<Length symbol='L' powerNumerator='1'/>
|
1452
|
-
<Time symbol='T' powerNumerator='-2'/>
|
1453
|
-
</Dimension>
|
1454
|
-
</math>
|
1455
|
-
OUTPUT
|
1521
|
+
<mrow>
|
1522
|
+
<mn>2</mn>
|
1523
|
+
</mrow>
|
1524
|
+
</msup>
|
1525
|
+
</mrow>
|
1526
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L2Theta'>
|
1527
|
+
<Length symbol='L' powerNumerator='2'/>
|
1528
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
1529
|
+
</Dimension>
|
1530
|
+
</math>
|
1531
|
+
OUTPUT
|
1456
1532
|
end
|
1457
1533
|
end
|