asciimath2unitsml 0.2.0 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -135,6 +135,7 @@ module UnitsDB
135
135
  @root = hash[:root_units][:enumerated_root_units]
136
136
  hash[:quantity_reference] and @quantities = hash[:quantity_reference].map { |x| x[:url].sub(/^#/, "") }
137
137
  hash[:si_derived_bases] and @si_derived_bases = hash[:si_derived_bases]
138
+ @prefixed = (hash[:prefixed] == true)
138
139
  rescue
139
140
  raise StandardError.new "Parse fail on Unit #{id}: #{hash}"
140
141
  end
data/spec/conv_spec.rb CHANGED
@@ -66,7 +66,7 @@ RSpec.describe Asciimath2UnitsML do
66
66
  OUTPUT
67
67
  end
68
68
 
69
- it "deals with non-Ascii units and prefixes" do
69
+ it "deals with non-Ascii units and prefixes" do
70
70
  expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
71
71
  1 "unitsml(um)"
72
72
  INPUT
@@ -75,7 +75,7 @@ RSpec.describe Asciimath2UnitsML do
75
75
  <mn>1</mn>
76
76
  <mo rspace='thickmathspace'>&#x2062;</mo>
77
77
  <mrow xref='U_um'>
78
- <mi mathvariant='normal'>um</mi>
78
+ <mi mathvariant='normal'>&#xB5;m</mi>
79
79
  </mrow>
80
80
  <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_um' dimensionURL='#NISTd1'>
81
81
  <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
@@ -84,7 +84,7 @@ RSpec.describe Asciimath2UnitsML do
84
84
  <UnitSymbol type='MathML'>
85
85
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
86
86
  <mrow>
87
- <mi mathvariant='normal'>um</mi>
87
+ <mi mathvariant='normal'>&#xB5;m</mi>
88
88
  </mrow>
89
89
  </math>
90
90
  </UnitSymbol>
@@ -97,7 +97,7 @@ RSpec.describe Asciimath2UnitsML do
97
97
  <PrefixSymbol type='ASCII'>u</PrefixSymbol>
98
98
  <PrefixSymbol type='unicode'>&#x3BC;</PrefixSymbol>
99
99
  <PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
100
- <PrefixSymbol type='HTML'>&amp;micro;</PrefixSymbol>
100
+ <PrefixSymbol type='HTML'>&#xB5;</PrefixSymbol>
101
101
  </Prefix>
102
102
  <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd1'>
103
103
  <Length symbol='L' powerNumerator='1'/>
@@ -106,6 +106,215 @@ RSpec.describe Asciimath2UnitsML do
106
106
  OUTPUT
107
107
  end
108
108
 
109
+ it "does not insert space before non-alphabetic units" do
110
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
111
+ 1 "unitsml(degK)" + 1 "unitsml(prime)" + ii(theta) = s//r "unitsml(rad)" + 10^(12) "unitsml(Hz)"
112
+ INPUT
113
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
114
+ <mn>1</mn>
115
+ <mo rspace='thickmathspace'>&#x2062;</mo>
116
+ <mrow xref='U_NISTu5'>
117
+ <mi mathvariant='normal'>&#xB0;K</mi>
118
+ </mrow>
119
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_NISTu5' dimensionURL='#NISTd5'>
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='http://unitsml.nist.gov/2005' xml:id='NISTd5'>
132
+ <ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
133
+ </Dimension>
134
+ <Quantity xmlns='http://unitsml.nist.gov/2005' 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>&#x2062;</mo>
140
+ <mrow xref='U_NISTu147'>
141
+ <mi mathvariant='normal'>&#x2032;</mi>
142
+ </mrow>
143
+ <Unit xmlns='http://unitsml.nist.gov/2005' 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'>&#x2032;</UnitSymbol>
147
+ <UnitSymbol type='MathML'>
148
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
149
+ <mrow>
150
+ <mi mathvariant='normal'>&#x2032;</mi>
151
+ </mrow>
152
+ </math>
153
+ </UnitSymbol>
154
+ </Unit>
155
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd9'>
156
+ <PlaneAngle symbol='Phi' powerNumerator='1'/>
157
+ </Dimension>
158
+ <Quantity xmlns='http://unitsml.nist.gov/2005' 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>&#x3B8;</mi>
165
+ </mstyle>
166
+ <mo>=</mo>
167
+ <mi>s</mi>
168
+ <mo>/</mo>
169
+ <mi>r</mi>
170
+ <mo rspace='thickmathspace'>&#x2062;</mo>
171
+ <mrow xref='U_NISTu9'>
172
+ <mi mathvariant='normal'>rad</mi>
173
+ </mrow>
174
+ <Unit xmlns='http://unitsml.nist.gov/2005' 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='http://unitsml.nist.gov/2005' xml:id='D_L0'>
187
+ <Length symbol='L' powerNumerator='0'/>
188
+ </Dimension>
189
+ <mo>+</mo>
190
+ <msup>
191
+ <mrow>
192
+ <mn>10</mn>
193
+ </mrow>
194
+ <mrow>
195
+ <mn>12</mn>
196
+ </mrow>
197
+ </msup>
198
+ <mo rspace='thickmathspace'>&#x2062;</mo>
199
+ <mrow xref='U_NISTu31'>
200
+ <mi mathvariant='normal'>Hz</mi>
201
+ </mrow>
202
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_NISTu31' dimensionURL='#NISTd24'>
203
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
204
+ <UnitName xml:lang='en'>hertz</UnitName>
205
+ <UnitSymbol type='HTML'>Hz</UnitSymbol>
206
+ <UnitSymbol type='MathML'>
207
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
208
+ <mrow>
209
+ <mi mathvariant='normal'>Hz</mi>
210
+ </mrow>
211
+ </math>
212
+ </UnitSymbol>
213
+ </Unit>
214
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd24'>
215
+ <Time symbol='T' powerNumerator='-1'/>
216
+ </Dimension>
217
+ <Quantity xmlns='http://unitsml.nist.gov/2005' xml:id='NISTq45' dimensionURL='#NISTd24' quantityType='base'>
218
+ <QuantityName xml:lang='en-US'>frequency</QuantityName>
219
+ </Quantity>
220
+ </math>
221
+ OUTPUT
222
+ end
223
+
224
+ it "does not insert space before operators" do
225
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
226
+ 8 "unitsml(kg)" cdot "unitsml(m)"
227
+ INPUT
228
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
229
+ <mn>8</mn>
230
+ <mo rspace='thickmathspace'>&#x2062;</mo>
231
+ <mrow xref='U_NISTu2'>
232
+ <mi mathvariant='normal'>kg</mi>
233
+ </mrow>
234
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_NISTu2' dimensionURL='#NISTd2'>
235
+ <UnitSystem name='SI' type='SI_base' xml:lang='en-US'/>
236
+ <UnitName xml:lang='en'>kilogram</UnitName>
237
+ <UnitSymbol type='HTML'>kg</UnitSymbol>
238
+ <UnitSymbol type='MathML'>
239
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
240
+ <mrow>
241
+ <mi mathvariant='normal'>kg</mi>
242
+ </mrow>
243
+ </math>
244
+ </UnitSymbol>
245
+ <RootUnits>
246
+ <EnumeratedRootUnit unit='gram' prefix='k'/>
247
+ </RootUnits>
248
+ </Unit>
249
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
250
+ <PrefixName xml:lang='en'>kilo</PrefixName>
251
+ <PrefixSymbol type='ASCII'>k</PrefixSymbol>
252
+ <PrefixSymbol type='unicode'>k</PrefixSymbol>
253
+ <PrefixSymbol type='LaTeX'>k</PrefixSymbol>
254
+ <PrefixSymbol type='HTML'>k</PrefixSymbol>
255
+ </Prefix>
256
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd2'>
257
+ <Mass symbol='M' powerNumerator='1'/>
258
+ </Dimension>
259
+ <Quantity xmlns='http://unitsml.nist.gov/2005' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
260
+ <QuantityName xml:lang='en-US'>mass</QuantityName>
261
+ </Quantity>
262
+ <mo>&#x22C5;</mo>
263
+ <mrow xref='U_NISTu1'>
264
+ <mi mathvariant='normal'>m</mi>
265
+ </mrow>
266
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
267
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
268
+ <UnitName xml:lang='en'>meter</UnitName>
269
+ <UnitSymbol type='HTML'>m</UnitSymbol>
270
+ <UnitSymbol type='MathML'>
271
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
272
+ <mrow>
273
+ <mi mathvariant='normal'>m</mi>
274
+ </mrow>
275
+ </math>
276
+ </UnitSymbol>
277
+ </Unit>
278
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd1'>
279
+ <Length symbol='L' powerNumerator='1'/>
280
+ </Dimension>
281
+ </math>
282
+ OUTPUT
283
+ end
284
+
285
+ it "deals with sqrt units" do
286
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
287
+ 1 "unitsml(sqrt(Hz))"
288
+ INPUT
289
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
290
+ <mn>1</mn>
291
+ <mo rspace='thickmathspace'>&#x2062;</mo>
292
+ <mrow xref='U_sqrtHz'>
293
+ <msqrt>
294
+ <mi mathvariant='normal'>Hz</mi>
295
+ </msqrt>
296
+ </mrow>
297
+ <Unit xmlns='http://unitsml.nist.gov/2005' 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'>&#x221A;Hz</UnitSymbol>
301
+ <UnitSymbol type='MathML'>
302
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
303
+ <mrow>
304
+ <msqrt>
305
+ <mi mathvariant='normal'>Hz</mi>
306
+ </msqrt>
307
+ </mrow>
308
+ </math>
309
+ </UnitSymbol>
310
+ </Unit>
311
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='D_T-0.5'>
312
+ <Time symbol='T' powerNumerator='-0.5'/>
313
+ </Dimension>
314
+ </math>
315
+ OUTPUT
316
+ end
317
+
109
318
  it "deals with kg and g" do
110
319
  expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
111
320
  1 "unitsml(kg)" + 1 "unitsml(g)"
@@ -359,6 +568,82 @@ INPUT
359
568
  OUTPUT
360
569
  end
361
570
 
571
+ it "deals with standalone prefixes" do
572
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
573
+ "unitsml(p-)" "unitsml(da-)"
574
+ INPUT
575
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
576
+ <mrow xref='NISTp10_-12'>
577
+ <mi mathvariant='normal'>p</mi>
578
+ </mrow>
579
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-12' xml:id='NISTp10_-12'>
580
+ <PrefixName xml:lang='en'>pico</PrefixName>
581
+ <PrefixSymbol type='ASCII'>p</PrefixSymbol>
582
+ <PrefixSymbol type='unicode'>p</PrefixSymbol>
583
+ <PrefixSymbol type='LaTeX'>p</PrefixSymbol>
584
+ <PrefixSymbol type='HTML'>p</PrefixSymbol>
585
+ </Prefix>
586
+ <mo rspace='thickmathspace'>&#x2062;</mo>
587
+ <mrow xref='NISTp10_1'>
588
+ <mi mathvariant='normal'>da</mi>
589
+ </mrow>
590
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='1' xml:id='NISTp10_1'>
591
+ <PrefixName xml:lang='en'>deka</PrefixName>
592
+ <PrefixSymbol type='ASCII'>da</PrefixSymbol>
593
+ <PrefixSymbol type='unicode'>da</PrefixSymbol>
594
+ <PrefixSymbol type='LaTeX'>da</PrefixSymbol>
595
+ <PrefixSymbol type='HTML'>da</PrefixSymbol>
596
+ </Prefix>
597
+ </math>
598
+ OUTPUT
599
+ end
600
+
601
+ it "deals with HTML entities in UnitsDB" do
602
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
603
+ "unitsml(u-)" + "unitsml(um)"
604
+ INPUT
605
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
606
+ <mrow xref='NISTp10_-6'>
607
+ <mi mathvariant='normal'>&#xB5;</mi>
608
+ </mrow>
609
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-6' xml:id='NISTp10_-6'>
610
+ <PrefixName xml:lang='en'>micro</PrefixName>
611
+ <PrefixSymbol type='ASCII'>u</PrefixSymbol>
612
+ <PrefixSymbol type='unicode'>&#x3BC;</PrefixSymbol>
613
+ <PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
614
+ <PrefixSymbol type='HTML'>&#xB5;</PrefixSymbol>
615
+ </Prefix>
616
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd2'>
617
+ <Mass symbol='M' powerNumerator='1'/>
618
+ </Dimension>
619
+ <Quantity xmlns='http://unitsml.nist.gov/2005' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
620
+ <QuantityName xml:lang='en-US'>mass</QuantityName>
621
+ </Quantity>
622
+ <mo>+</mo>
623
+ <mrow xref='U_um'>
624
+ <mi mathvariant='normal'>&#xB5;m</mi>
625
+ </mrow>
626
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_um' dimensionURL='#NISTd1'>
627
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
628
+ <UnitName xml:lang='en'>um</UnitName>
629
+ <UnitSymbol type='HTML'>um</UnitSymbol>
630
+ <UnitSymbol type='MathML'>
631
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
632
+ <mrow>
633
+ <mi mathvariant='normal'>&#xB5;m</mi>
634
+ </mrow>
635
+ </math>
636
+ </UnitSymbol>
637
+ <RootUnits>
638
+ <EnumeratedRootUnit unit='meter' prefix='u'/>
639
+ </RootUnits>
640
+ </Unit>
641
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd1'>
642
+ <Length symbol='L' powerNumerator='1'/>
643
+ </Dimension>
644
+ </math>
645
+ OUTPUT
646
+ end
362
647
 
363
648
  it "deals with units division" do
364
649
  expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
@@ -695,6 +980,73 @@ OUTPUT
695
980
  OUTPUT
696
981
  end
697
982
 
983
+ it "deals with dimension decomposition with like units" do
984
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
985
+ 9 "unitsml(mW*cm^(-2))"
986
+ INPUT
987
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
988
+ <mn>9</mn>
989
+ <mo rspace='thickmathspace'>&#x2062;</mo>
990
+ <mrow xref='U_mW.cm-2'>
991
+ <mi mathvariant='normal'>mW</mi>
992
+ <mo>&#xB7;</mo>
993
+ <msup>
994
+ <mrow>
995
+ <mi mathvariant='normal'>cm</mi>
996
+ </mrow>
997
+ <mrow>
998
+ <mo>&#x2212;</mo>
999
+ <mn>2</mn>
1000
+ </mrow>
1001
+ </msup>
1002
+ </mrow>
1003
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_mW.cm-2'>
1004
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
1005
+ <UnitName xml:lang='en'>mW*cm^-2</UnitName>
1006
+ <UnitSymbol type='HTML'>
1007
+ mW&#xB7;cm
1008
+ <sup>&#x2212;2</sup>
1009
+ </UnitSymbol>
1010
+ <UnitSymbol type='MathML'>
1011
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1012
+ <mrow>
1013
+ <mi mathvariant='normal'>mW</mi>
1014
+ <mo>&#xB7;</mo>
1015
+ <msup>
1016
+ <mrow>
1017
+ <mi mathvariant='normal'>cm</mi>
1018
+ </mrow>
1019
+ <mrow>
1020
+ <mo>&#x2212;</mo>
1021
+ <mn>2</mn>
1022
+ </mrow>
1023
+ </msup>
1024
+ </mrow>
1025
+ </math>
1026
+ </UnitSymbol>
1027
+ <RootUnits>
1028
+ <EnumeratedRootUnit unit='watt' prefix='m'/>
1029
+ <EnumeratedRootUnit unit='meter' prefix='c' powerNumerator='-2'/>
1030
+ </RootUnits>
1031
+ </Unit>
1032
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
1033
+ <PrefixName xml:lang='en'>milli</PrefixName>
1034
+ <PrefixSymbol type='ASCII'>m</PrefixSymbol>
1035
+ <PrefixSymbol type='unicode'>m</PrefixSymbol>
1036
+ <PrefixSymbol type='LaTeX'>m</PrefixSymbol>
1037
+ <PrefixSymbol type='HTML'>m</PrefixSymbol>
1038
+ </Prefix>
1039
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
1040
+ <PrefixName xml:lang='en'>centi</PrefixName>
1041
+ <PrefixSymbol type='ASCII'>c</PrefixSymbol>
1042
+ <PrefixSymbol type='unicode'>c</PrefixSymbol>
1043
+ <PrefixSymbol type='LaTeX'>c</PrefixSymbol>
1044
+ <PrefixSymbol type='HTML'>c</PrefixSymbol>
1045
+ </Prefix>
1046
+ </math>
1047
+ OUTPUT
1048
+ end
1049
+
698
1050
  it "deals with quantity input" do
699
1051
  expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
700
1052
  9 "unitsml(m, quantity: NISTq103)"
@@ -803,5 +1155,159 @@ INPUT
803
1155
  OUTPUT
804
1156
  end
805
1157
 
1158
+ it "deals with symbol input" do
1159
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
1160
+ 9 "unitsml(m, symbol: La)" + 10 "unitsml(cm*s^-2, symbol: cm cdot s^-2)"
1161
+ INPUT
1162
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1163
+ <mn>9</mn>
1164
+ <mo rspace='thickmathspace'>&#x2062;</mo>
1165
+ <mrow xref='U_NISTu1'>
1166
+ <math>
1167
+ <mi mathvariant='normal'>L</mi>
1168
+ <mi mathvariant='normal'>a</mi>
1169
+ </math>
1170
+ </mrow>
1171
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
1172
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
1173
+ <UnitName xml:lang='en'>meter</UnitName>
1174
+ <UnitSymbol type='HTML'>m</UnitSymbol>
1175
+ <UnitSymbol type='MathML'>
1176
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1177
+ <mrow>
1178
+ <mi mathvariant='normal'>m</mi>
1179
+ </mrow>
1180
+ </math>
1181
+ </UnitSymbol>
1182
+ </Unit>
1183
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd1'>
1184
+ <Length symbol='L' powerNumerator='1'/>
1185
+ </Dimension>
1186
+ <mo>+</mo>
1187
+ <mn>10</mn>
1188
+ <mo rspace='thickmathspace'>&#x2062;</mo>
1189
+ <mrow xref='U_cm.s-2'>
1190
+ <math>
1191
+ <mi mathvariant='normal'>c</mi>
1192
+ <mi mathvariant='normal'>m</mi>
1193
+ <mo>&#x22C5;</mo>
1194
+ <msup>
1195
+ <mrow>
1196
+ <mi mathvariant='normal'>s</mi>
1197
+ </mrow>
1198
+ <mrow>
1199
+ <mo>&#x2212;</mo>
1200
+ </mrow>
1201
+ </msup>
1202
+ <mn>2</mn>
1203
+ </math>
1204
+ </mrow>
1205
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_cm.s-2' dimensionURL='#NISTd28'>
1206
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
1207
+ <UnitName xml:lang='en'>cm*s^-2</UnitName>
1208
+ <UnitSymbol type='HTML'>
1209
+ cm&#xB7;s
1210
+ <sup>&#x2212;2</sup>
1211
+ </UnitSymbol>
1212
+ <UnitSymbol type='MathML'>
1213
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1214
+ <mrow>
1215
+ <mi mathvariant='normal'>cm</mi>
1216
+ <mo>&#xB7;</mo>
1217
+ <msup>
1218
+ <mrow>
1219
+ <mi mathvariant='normal'>s</mi>
1220
+ </mrow>
1221
+ <mrow>
1222
+ <mo>&#x2212;</mo>
1223
+ <mn>2</mn>
1224
+ </mrow>
1225
+ </msup>
1226
+ </mrow>
1227
+ </math>
1228
+ </UnitSymbol>
1229
+ <RootUnits>
1230
+ <EnumeratedRootUnit unit='meter' prefix='c'/>
1231
+ <EnumeratedRootUnit unit='second' powerNumerator='-2'/>
1232
+ </RootUnits>
1233
+ </Unit>
1234
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
1235
+ <PrefixName xml:lang='en'>centi</PrefixName>
1236
+ <PrefixSymbol type='ASCII'>c</PrefixSymbol>
1237
+ <PrefixSymbol type='unicode'>c</PrefixSymbol>
1238
+ <PrefixSymbol type='LaTeX'>c</PrefixSymbol>
1239
+ <PrefixSymbol type='HTML'>c</PrefixSymbol>
1240
+ </Prefix>
1241
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd28'>
1242
+ <Length symbol='L' powerNumerator='1'/>
1243
+ <Time symbol='T' powerNumerator='-2'/>
1244
+ </Dimension>
1245
+ </math>
1246
+ OUTPUT
1247
+ end
1248
+
1249
+ it "deals with multiplier input" do
1250
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
1251
+ 10 "unitsml(cm*s^-2, multiplier: xx)"
1252
+ INPUT
1253
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1254
+ <mn>10</mn>
1255
+ <mo rspace='thickmathspace'>&#x2062;</mo>
1256
+ <mrow xref='U_cm.s-2'>
1257
+ <mi mathvariant='normal'>cm</mi>
1258
+ <mo>xx</mo>
1259
+ <msup>
1260
+ <mrow>
1261
+ <mi mathvariant='normal'>s</mi>
1262
+ </mrow>
1263
+ <mrow>
1264
+ <mo>&#x2212;</mo>
1265
+ <mn>2</mn>
1266
+ </mrow>
1267
+ </msup>
1268
+ </mrow>
1269
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_cm.s-2' dimensionURL='#NISTd28'>
1270
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
1271
+ <UnitName xml:lang='en'>cm*s^-2</UnitName>
1272
+ <UnitSymbol type='HTML'>
1273
+ cm&#xB7;s
1274
+ <sup>&#x2212;2</sup>
1275
+ </UnitSymbol>
1276
+ <UnitSymbol type='MathML'>
1277
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1278
+ <mrow>
1279
+ <mi mathvariant='normal'>cm</mi>
1280
+ <mo>&#xB7;</mo>
1281
+ <msup>
1282
+ <mrow>
1283
+ <mi mathvariant='normal'>s</mi>
1284
+ </mrow>
1285
+ <mrow>
1286
+ <mo>&#x2212;</mo>
1287
+ <mn>2</mn>
1288
+ </mrow>
1289
+ </msup>
1290
+ </mrow>
1291
+ </math>
1292
+ </UnitSymbol>
1293
+ <RootUnits>
1294
+ <EnumeratedRootUnit unit='meter' prefix='c'/>
1295
+ <EnumeratedRootUnit unit='second' powerNumerator='-2'/>
1296
+ </RootUnits>
1297
+ </Unit>
1298
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
1299
+ <PrefixName xml:lang='en'>centi</PrefixName>
1300
+ <PrefixSymbol type='ASCII'>c</PrefixSymbol>
1301
+ <PrefixSymbol type='unicode'>c</PrefixSymbol>
1302
+ <PrefixSymbol type='LaTeX'>c</PrefixSymbol>
1303
+ <PrefixSymbol type='HTML'>c</PrefixSymbol>
1304
+ </Prefix>
1305
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd28'>
1306
+ <Length symbol='L' powerNumerator='1'/>
1307
+ <Time symbol='T' powerNumerator='-2'/>
1308
+ </Dimension>
1309
+ </math>
1310
+ OUTPUT
1311
+ end
806
1312
 
807
1313
  end