phys-units 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,41 @@ require "helper"
3
3
 
4
4
  describe "Phys::Quantity" do
5
5
 
6
+ context "equality" do
7
+ describe Q[12] do
8
+ it {should == 12}
9
+ it {should == Q[12]}
10
+ it {should == Q[12,"radian"]}
11
+ it {should == Q[1,"dozen"]}
12
+ it {should_not == Q[12,"pi"]}
13
+ it {should_not == Q[12,"km"]}
14
+ end
15
+ describe Q[12,"radian"] do
16
+ it {should == 12}
17
+ it {should == Q[12]}
18
+ it {should == Q[12,"radian"]}
19
+ it {should == Q[1,"dozen"]}
20
+ it {should_not == Q[12,"pi"]}
21
+ it {should_not == Q[12,"km"]}
22
+ end
23
+ describe Q[12,"km"] do
24
+ it {should_not == 12}
25
+ it {should_not == Q[12]}
26
+ it {should_not == Q[12,"radian"]}
27
+ it {should_not == Q[1,"dozen"]}
28
+ it {should_not == Q[12,"pi"]}
29
+ it {should == Q[12,"km"]}
30
+ it {should == Q[1,"dozen km"]}
31
+ end
32
+ describe 12 do
33
+ it {should == Q[12]}
34
+ it {should == Q[12,"radian"]}
35
+ it {should == Q[1,"dozen"]}
36
+ it {should_not == Q[12,"pi"]}
37
+ it {should_not == Q[12,"km"]}
38
+ end
39
+ end
40
+
6
41
  context "methods" do
7
42
  describe Q[1.25,"km"] do
8
43
  before {@q = Q[1.25,"km"]; @r = Q[500,"m"]}
@@ -91,10 +126,10 @@ describe "Phys::Quantity" do
91
126
  end
92
127
 
93
128
  context "Temperature" do
94
- describe Q[1,"tempC"] - Q[1,"tempC"] do
129
+ describe Q[1,"tempC"] - Q[1,"tempC"] do
95
130
  it {should == Q[0,"tempC"]}
96
131
  end
97
- describe Q[50,"tempF"] + Q[10,"tempC"] do
132
+ describe Q[50,"tempF"] + Q[10,"tempC"] do
98
133
  it {should == Q[68,"tempF"]}
99
134
  end
100
135
  describe Q[0,"tempC"].want("tempF") do
@@ -103,7 +138,7 @@ describe "Phys::Quantity" do
103
138
  describe Q[32,"tempF"].want("tempC") do
104
139
  its(:value){should == 0}
105
140
  end
106
- describe 2 * Q[2,"tempF"] do
141
+ describe 2 * Q[2,"tempF"] do
107
142
  it {should == Q[4,"tempF"]}
108
143
  end
109
144
  describe Q[2.5,"tempC"] * 4 do
@@ -112,19 +147,19 @@ describe "Phys::Quantity" do
112
147
  describe Q[10.0,"tempC"] / 4 do
113
148
  its(:value){should == 2.5}
114
149
  end
115
- describe "tempC*tempC" do
150
+ describe "tempC*tempC" do
116
151
  it {expect{Q[1,"tempC"]*Q[2,"tempC"]}.to raise_error}
117
152
  end
118
- describe "tempC*K" do
153
+ describe "tempC*K" do
119
154
  it {expect{Q[1,"tempC"]*Q[2,"K"]}.to raise_error}
120
155
  end
121
- describe "K*tempC" do
156
+ describe "K*tempC" do
122
157
  it {expect{Q[1,"K"]*Q[2,"tempC"]}.to raise_error}
123
158
  end
124
- describe "tempC**2" do
159
+ describe "tempC**2" do
125
160
  it {expect{Q[2,"tempC"]**2}.to raise_error}
126
161
  end
127
- describe "tempC/tempC" do
162
+ describe "tempC/tempC" do
128
163
  it {expect{Q[2,"tempC"]/Q[1,"tempC"]}.to raise_error}
129
164
  end
130
165
  end
@@ -133,7 +168,7 @@ describe "Phys::Quantity" do
133
168
  describe Q[36,"km/hour"] do
134
169
  its(:to_base_unit){should == Q[10,"m/s"]}
135
170
  end
136
- describe Q[36,"km/hour"].want('m/s') do
171
+ describe Q[36,"km/hour"].want('m/s') do
137
172
  its(:value){should == 10}
138
173
  end
139
174
  end
@@ -147,4 +182,11 @@ describe "Phys::Quantity" do
147
182
  end
148
183
  end
149
184
 
185
+ context "Complex units" do
186
+ describe Q[1,"(8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)"] do
187
+ it{should be_a_quantity_close_to Q[43.533969,"psi"]}
188
+ end
189
+ end
190
+
150
191
  end
192
+
data/spec/unit_spec.rb CHANGED
@@ -63,7 +63,7 @@ describe "Create Units" do
63
63
  it {should be_operable}
64
64
  end
65
65
 
66
- describe U[:m] do
66
+ describe U[:m] do
67
67
  it {should == U["m"]}
68
68
  end
69
69
 
@@ -227,7 +227,7 @@ describe "Create Units" do
227
227
 
228
228
  describe "temperature unit" do
229
229
  it "operation error" do
230
- expect {U['tempC']*2}.to raise_error(Phys::UnitOperationError)
230
+ expect {U['tempC']*2}.to raise_error(Phys::UnitError)
231
231
  end
232
232
  end
233
233
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phys-units
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-30 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,21 +53,27 @@ files:
53
53
  - lib/phys/units.rb
54
54
  - lib/phys/units/Makefile
55
55
  - lib/phys/units/errors.rb
56
+ - lib/phys/units/jp.rb
56
57
  - lib/phys/units/load_units.rb
57
58
  - lib/phys/units/mixin.rb
58
59
  - lib/phys/units/parse.rb
59
60
  - lib/phys/units/parse.y
60
61
  - lib/phys/units/quantity.rb
62
+ - lib/phys/units/quanty.rb
61
63
  - lib/phys/units/unit.rb
62
64
  - lib/phys/units/unit_class.rb
63
65
  - lib/phys/units/utils.rb
64
66
  - lib/phys/units/version.rb
67
+ - misc/mkjpspec.rb
68
+ - misc/mkunitspec.rb
69
+ - misc/readme.jp.md
65
70
  - phys-units.gemspec
66
71
  - setup.rb
72
+ - spec/all_units_spec.rb
67
73
  - spec/helper.rb
74
+ - spec/jp_units_spec.rb
68
75
  - spec/quantity_spec.rb
69
76
  - spec/unit_spec.rb
70
- - spec/units_dat_spec.rb
71
77
  - spec/utils_spec.rb
72
78
  homepage: https://github.com/masa16/phys-units
73
79
  licenses:
@@ -94,9 +100,10 @@ signing_key:
94
100
  specification_version: 4
95
101
  summary: GNU Units-compatible library for Ruby, formarly 'Quanty' class library.
96
102
  test_files:
103
+ - spec/all_units_spec.rb
97
104
  - spec/helper.rb
105
+ - spec/jp_units_spec.rb
98
106
  - spec/quantity_spec.rb
99
107
  - spec/unit_spec.rb
100
- - spec/units_dat_spec.rb
101
108
  - spec/utils_spec.rb
102
109
  has_rdoc: