danica 2.7.4 → 2.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +28 -0
- data/.gitignore +6 -1
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +100 -0
- data/Dockerfile +26 -0
- data/Gemfile +2 -1
- data/Rakefile +4 -0
- data/config/rubycritc.rb +12 -0
- data/config/yardstick.rb +13 -0
- data/config/yardstick.yml +33 -0
- data/danica.gemspec +14 -7
- data/docker-compose.yml +14 -9
- data/lib/danica.rb +2 -1
- data/lib/danica/base_operations.rb +2 -0
- data/lib/danica/builder.rb +2 -0
- data/lib/danica/common.rb +5 -2
- data/lib/danica/dsl.rb +8 -6
- data/lib/danica/dsl/builder.rb +3 -1
- data/lib/danica/equation.rb +3 -3
- data/lib/danica/equation/builder.rb +2 -0
- data/lib/danica/exception.rb +3 -2
- data/lib/danica/expressable.rb +14 -8
- data/lib/danica/expression.rb +4 -2
- data/lib/danica/expression/gauss.rb +5 -5
- data/lib/danica/formatted.rb +4 -2
- data/lib/danica/function.rb +5 -3
- data/lib/danica/function/name.rb +2 -0
- data/lib/danica/operator.rb +12 -9
- data/lib/danica/operator/addition.rb +4 -3
- data/lib/danica/operator/chained.rb +4 -3
- data/lib/danica/operator/cos.rb +2 -1
- data/lib/danica/operator/division.rb +2 -1
- data/lib/danica/operator/exponential.rb +2 -1
- data/lib/danica/operator/functional.rb +3 -2
- data/lib/danica/operator/multiplication.rb +4 -2
- data/lib/danica/operator/power.rb +4 -3
- data/lib/danica/operator/sin.rb +2 -1
- data/lib/danica/operator/squared_root.rb +2 -1
- data/lib/danica/variables_holder.rb +7 -4
- data/lib/danica/variables_holder/alias_builder.rb +4 -4
- data/lib/danica/variables_holder/calculator.rb +2 -0
- data/lib/danica/variables_holder/store.rb +3 -2
- data/lib/danica/variables_holder/variables_builder.rb +2 -1
- data/lib/danica/version.rb +3 -1
- data/lib/danica/wrapper.rb +11 -9
- data/lib/danica/wrapper/constant.rb +9 -14
- data/lib/danica/wrapper/container.rb +2 -3
- data/lib/danica/wrapper/group.rb +2 -2
- data/lib/danica/wrapper/negative.rb +2 -1
- data/lib/danica/wrapper/number.rb +4 -3
- data/lib/danica/wrapper/plus_minus.rb +2 -1
- data/lib/danica/wrapper/variable.rb +10 -8
- data/scripts/check_readme.sh +6 -0
- data/scripts/rubycritic.sh +10 -0
- data/spec/integration/global/danica/formatted_spec.rb +87 -0
- data/spec/integration/global/danica/operator/addition_spec.rb +32 -0
- data/spec/integration/{multiplication_spec.rb → global/danica/operator/multiplication_spec.rb} +12 -9
- data/spec/integration/{power_spec.rb → global/danica/operator/power_spec.rb} +4 -2
- data/spec/integration/{negative_spec.rb → global/danica/wrapper/negative_spec.rb} +9 -8
- data/spec/integration/{plus_minus_spec.rb → global/danica/wrapper/plus_minus_spec.rb} +5 -4
- data/spec/integration/readme/constant_spec.rb +4 -1
- data/spec/integration/readme/danica/formatted_spec.rb +24 -0
- data/spec/integration/readme/danica_spec.rb +20 -4
- data/spec/integration/readme/equation_spec.rb +4 -2
- data/spec/integration/readme/expression_spec.rb +11 -8
- data/spec/integration/readme/function_spec.rb +11 -7
- data/spec/integration/readme/number_spec.rb +9 -8
- data/spec/integration/readme/operator_spec.rb +3 -1
- data/spec/integration/readme/variables_spec.rb +8 -6
- data/spec/lib/danica/common_spec.rb +23 -9
- data/spec/lib/danica/dsl_spec.rb +5 -2
- data/spec/lib/danica/equation_spec.rb +10 -8
- data/spec/lib/danica/expressable_spec.rb +5 -2
- data/spec/lib/danica/expression/gauss_spec.rb +6 -3
- data/spec/lib/danica/expression_spec.rb +48 -26
- data/spec/lib/danica/formatted_spec.rb +20 -14
- data/spec/lib/danica/function/name_spec.rb +3 -1
- data/spec/lib/danica/function_spec.rb +14 -10
- data/spec/lib/danica/operator/addition_spec.rb +16 -15
- data/spec/lib/danica/operator/cos_spec.rb +9 -8
- data/spec/lib/danica/operator/division_spec.rb +18 -17
- data/spec/lib/danica/operator/exponential_spec.rb +9 -8
- data/spec/lib/danica/operator/multiplication_spec.rb +16 -15
- data/spec/lib/danica/operator/power_spec.rb +17 -16
- data/spec/lib/danica/operator/sin_spec.rb +9 -8
- data/spec/lib/danica/operator/squared_root_spec.rb +9 -8
- data/spec/lib/danica/operator_spec.rb +13 -4
- data/spec/lib/danica/variables_holder/store_spec.rb +19 -13
- data/spec/lib/danica/variables_holder_spec.rb +76 -59
- data/spec/lib/danica/wrapper/constant_spec.rb +9 -2
- data/spec/lib/danica/wrapper/group_spec.rb +4 -1
- data/spec/lib/danica/wrapper/negative_spec.rb +4 -1
- data/spec/lib/danica/wrapper/number_spec.rb +8 -3
- data/spec/lib/danica/wrapper/plus_minus_spec.rb +4 -1
- data/spec/lib/danica/wrapper/variable_spec.rb +6 -3
- data/spec/lib/danica/wrapper_spec.rb +14 -12
- data/spec/lib/danica_spec.rb +6 -5
- data/spec/spec_helper.rb +2 -1
- data/spec/support/models/expression/baskara.rb +3 -3
- data/spec/support/models/expression/parabole.rb +2 -0
- data/spec/support/models/expression/quadratic_sum.rb +3 -1
- data/spec/support/models/expression/spatial.rb +2 -1
- data/spec/support/models/function/my_function.rb +3 -1
- data/spec/support/models/function/parabole.rb +1 -1
- data/spec/support/models/function/quadratic_sum.rb +2 -0
- data/spec/support/models/function/spatial.rb +2 -0
- data/spec/support/models/operator/inverse.rb +3 -1
- data/spec/support/models/operator/my_operator.rb +3 -1
- data/spec/support/models/variables_holder/dummy.rb +3 -1
- data/spec/support/shared_contexts/common.rb +4 -2
- data/spec/support/shared_examples/base_operations.rb +7 -4
- data/spec/support/shared_examples/common.rb +3 -1
- data/spec/support/shared_examples/operator/chained.rb +12 -6
- data/spec/support/shared_examples/operator/dual_term.rb +9 -8
- data/spec/support/shared_examples/operator/single_input.rb +7 -2
- data/spec/support/shared_examples/variable.rb +8 -4
- metadata +109 -30
- data/spec/integration/addition_spec.rb +0 -28
- data/spec/integration/formatted_spec.rb +0 -75
- data/spec/integration/readme/formatting_spec.rb +0 -34
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_examples 'a operator with a single input value' do |arguments|
|
2
|
-
include_context 'variables are initialized', arguments,
|
3
|
-
let(:variable) { { name: "X", value: variable_value } }
|
4
|
+
include_context 'when variables are initialized', arguments, 'variable_value', 'expected_number', 'expected_tex', 'expected_number_tex', 'expected_gnu', 'expected_number_gnu'
|
4
5
|
subject { described_class.new(variable) }
|
5
6
|
|
7
|
+
let(:variable) { { name: 'X', value: variable_value } }
|
8
|
+
|
6
9
|
describe '#to_f' do
|
7
10
|
context 'when variables are not numbers but have value' do
|
8
11
|
it 'returns the division of the values' do
|
@@ -40,6 +43,7 @@ shared_examples 'a operator with a single input value' do |arguments|
|
|
40
43
|
before do
|
41
44
|
subject.variables[0].value = variable_value
|
42
45
|
end
|
46
|
+
|
43
47
|
it 'prints both numbers' do
|
44
48
|
expect(subject.to_tex).to eq(expected_number_tex)
|
45
49
|
end
|
@@ -59,6 +63,7 @@ shared_examples 'a operator with a single input value' do |arguments|
|
|
59
63
|
before do
|
60
64
|
subject.variables[0].value = variable_value
|
61
65
|
end
|
66
|
+
|
62
67
|
it 'prints both numbers' do
|
63
68
|
expect(subject.to_gnu).to eq(expected_number_gnu)
|
64
69
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_examples 'a variable method to formated string' do |method, format|
|
4
|
+
subject { described_class.new(arguments) }
|
5
|
+
|
2
6
|
let(:name) { :delta }
|
3
7
|
let(:value) { 10.0 }
|
4
8
|
let(:arguments) { { name: name, latex: '\delta', gnuplot: 'del' } }
|
5
|
-
subject { described_class.new(arguments) }
|
6
9
|
|
7
10
|
context "when #{format} is not defined" do
|
8
11
|
before { arguments.delete(format) }
|
@@ -13,6 +16,7 @@ shared_examples 'a variable method to formated string' do |method, format|
|
|
13
16
|
|
14
17
|
context 'when value is defined' do
|
15
18
|
before { arguments[:value] = value }
|
19
|
+
|
16
20
|
it_behaves_like 'a method that display the numeric value', method
|
17
21
|
end
|
18
22
|
end
|
@@ -32,7 +36,7 @@ shared_examples 'a method that display the numeric value' do |method|
|
|
32
36
|
expect(subject.public_send(method)).to eq('10')
|
33
37
|
end
|
34
38
|
|
35
|
-
context '
|
39
|
+
context 'when passing the decimals argument' do
|
36
40
|
it 'returns the value float string' do
|
37
41
|
expect(subject.public_send(method, decimals: 4)).to eq('10')
|
38
42
|
end
|
@@ -46,13 +50,13 @@ shared_examples 'a method that display the numeric value' do |method|
|
|
46
50
|
expect(subject.public_send(method)).to eq('3.3333333333333335')
|
47
51
|
end
|
48
52
|
|
49
|
-
context '
|
53
|
+
context 'when passing the decimals argument' do
|
50
54
|
it 'returns the value float string' do
|
51
55
|
expect(subject.public_send(method, decimals: 4)).to eq('3.3333')
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
55
|
-
context '
|
59
|
+
context 'when the number has less decimals' do
|
56
60
|
let(:value) { 10.5 }
|
57
61
|
|
58
62
|
it 'returns the value integer string' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darthjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,72 +44,142 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.16.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.16.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-nav
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.4
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.4
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 12.3.1
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 12.3.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.8'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.58.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.58.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.30.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.30.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubycritic
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 4.0.2
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 4.0.2
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
71
141
|
requirement: !ruby/object:Gem::Requirement
|
72
142
|
requirements:
|
73
143
|
- - "~>"
|
74
144
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
145
|
+
version: 0.16.x
|
76
146
|
type: :development
|
77
147
|
prerelease: false
|
78
148
|
version_requirements: !ruby/object:Gem::Requirement
|
79
149
|
requirements:
|
80
150
|
- - "~>"
|
81
151
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
152
|
+
version: 0.16.x
|
83
153
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
154
|
+
name: yard
|
85
155
|
requirement: !ruby/object:Gem::Requirement
|
86
156
|
requirements:
|
87
157
|
- - ">="
|
88
158
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
159
|
+
version: 0.9.18
|
90
160
|
type: :development
|
91
161
|
prerelease: false
|
92
162
|
version_requirements: !ruby/object:Gem::Requirement
|
93
163
|
requirements:
|
94
164
|
- - ">="
|
95
165
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
166
|
+
version: 0.9.18
|
97
167
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
168
|
+
name: yardstick
|
99
169
|
requirement: !ruby/object:Gem::Requirement
|
100
170
|
requirements:
|
101
171
|
- - ">="
|
102
172
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
173
|
+
version: 0.9.9
|
104
174
|
type: :development
|
105
175
|
prerelease: false
|
106
176
|
version_requirements: !ruby/object:Gem::Requirement
|
107
177
|
requirements:
|
108
178
|
- - ">="
|
109
179
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
180
|
+
version: 0.9.9
|
111
181
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
182
|
+
name: rspec-mocks
|
113
183
|
requirement: !ruby/object:Gem::Requirement
|
114
184
|
requirements:
|
115
185
|
- - ">="
|
@@ -129,13 +199,20 @@ executables: []
|
|
129
199
|
extensions: []
|
130
200
|
extra_rdoc_files: []
|
131
201
|
files:
|
202
|
+
- ".circleci/config.yml"
|
132
203
|
- ".gitignore"
|
133
204
|
- ".rspec"
|
205
|
+
- ".rubocop.yml"
|
206
|
+
- ".rubocop_todo.yml"
|
207
|
+
- Dockerfile
|
134
208
|
- Gemfile
|
135
209
|
- LICENSE
|
136
210
|
- README.md
|
137
211
|
- Rakefile
|
138
212
|
- circle.yml
|
213
|
+
- config/rubycritc.rb
|
214
|
+
- config/yardstick.rb
|
215
|
+
- config/yardstick.yml
|
139
216
|
- danica.gemspec
|
140
217
|
- docker-compose.yml
|
141
218
|
- lib/danica.rb
|
@@ -178,17 +255,19 @@ files:
|
|
178
255
|
- lib/danica/wrapper/number.rb
|
179
256
|
- lib/danica/wrapper/plus_minus.rb
|
180
257
|
- lib/danica/wrapper/variable.rb
|
181
|
-
-
|
182
|
-
-
|
183
|
-
- spec/integration/
|
184
|
-
- spec/integration/
|
185
|
-
- spec/integration/
|
186
|
-
- spec/integration/power_spec.rb
|
258
|
+
- scripts/check_readme.sh
|
259
|
+
- scripts/rubycritic.sh
|
260
|
+
- spec/integration/global/danica/formatted_spec.rb
|
261
|
+
- spec/integration/global/danica/operator/addition_spec.rb
|
262
|
+
- spec/integration/global/danica/operator/multiplication_spec.rb
|
263
|
+
- spec/integration/global/danica/operator/power_spec.rb
|
264
|
+
- spec/integration/global/danica/wrapper/negative_spec.rb
|
265
|
+
- spec/integration/global/danica/wrapper/plus_minus_spec.rb
|
187
266
|
- spec/integration/readme/constant_spec.rb
|
267
|
+
- spec/integration/readme/danica/formatted_spec.rb
|
188
268
|
- spec/integration/readme/danica_spec.rb
|
189
269
|
- spec/integration/readme/equation_spec.rb
|
190
270
|
- spec/integration/readme/expression_spec.rb
|
191
|
-
- spec/integration/readme/formatting_spec.rb
|
192
271
|
- spec/integration/readme/function_spec.rb
|
193
272
|
- spec/integration/readme/number_spec.rb
|
194
273
|
- spec/integration/readme/operator_spec.rb
|
@@ -259,22 +338,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
338
|
version: '0'
|
260
339
|
requirements: []
|
261
340
|
rubyforge_project:
|
262
|
-
rubygems_version: 2.6
|
341
|
+
rubygems_version: 2.7.6
|
263
342
|
signing_key:
|
264
343
|
specification_version: 4
|
265
344
|
summary: Danica
|
266
345
|
test_files:
|
267
|
-
- spec/integration/
|
268
|
-
- spec/integration/
|
269
|
-
- spec/integration/multiplication_spec.rb
|
270
|
-
- spec/integration/
|
271
|
-
- spec/integration/
|
272
|
-
- spec/integration/
|
346
|
+
- spec/integration/global/danica/formatted_spec.rb
|
347
|
+
- spec/integration/global/danica/operator/addition_spec.rb
|
348
|
+
- spec/integration/global/danica/operator/multiplication_spec.rb
|
349
|
+
- spec/integration/global/danica/operator/power_spec.rb
|
350
|
+
- spec/integration/global/danica/wrapper/negative_spec.rb
|
351
|
+
- spec/integration/global/danica/wrapper/plus_minus_spec.rb
|
273
352
|
- spec/integration/readme/constant_spec.rb
|
353
|
+
- spec/integration/readme/danica/formatted_spec.rb
|
274
354
|
- spec/integration/readme/danica_spec.rb
|
275
355
|
- spec/integration/readme/equation_spec.rb
|
276
356
|
- spec/integration/readme/expression_spec.rb
|
277
|
-
- spec/integration/readme/formatting_spec.rb
|
278
357
|
- spec/integration/readme/function_spec.rb
|
279
358
|
- spec/integration/readme/number_spec.rb
|
280
359
|
- spec/integration/readme/operator_spec.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'integration of addition' do
|
4
|
-
describe 'with negative and positivenegative (+/-) numbers' do
|
5
|
-
subject do
|
6
|
-
Danica::Operator::Addition.new(
|
7
|
-
Danica::Wrapper::Negative.new(1),
|
8
|
-
2,
|
9
|
-
-3,
|
10
|
-
4,
|
11
|
-
Danica::Wrapper::PlusMinus.new(5),
|
12
|
-
Danica::Wrapper::Number.new(-6)
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#to_gnu' do
|
17
|
-
it 'returns the correct string' do
|
18
|
-
expect(subject.to_gnu).to eq('-1 + 2 -3 + 4 + 5 -6')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#to_tex' do
|
23
|
-
it 'returns the correct string' do
|
24
|
-
expect(subject.to_tex).to eq('-1 + 2 -3 + 4 \pm 5 -6')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'integration of formatted objects' do
|
4
|
-
let(:variable) { Danica.build(:v) { v } }
|
5
|
-
subject do
|
6
|
-
variable.tex
|
7
|
-
end
|
8
|
-
|
9
|
-
context 'when interacting with a multiplication' do
|
10
|
-
let(:other) do
|
11
|
-
Danica.build(:x, :y) { x * y }
|
12
|
-
end
|
13
|
-
context 'when multipling another multiplication' do
|
14
|
-
let(:result) { subject * other }
|
15
|
-
it do
|
16
|
-
expect(result).to be_a(Danica::Formatted)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'knows how to convert it to string' do
|
20
|
-
expect(result.to_s).to eq('v \\cdot x \\cdot y')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when multiplicated by another multiplication' do
|
25
|
-
let(:result) { other * subject }
|
26
|
-
it do
|
27
|
-
expect(result).to be_a(Danica::Formatted)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'knows how to convert it to string' do
|
31
|
-
expect(result.to_s).to eq('x \\cdot y \\cdot v')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when interacting with a sum' do
|
37
|
-
let(:other) do
|
38
|
-
Danica.build(:x, :y) { x + y }
|
39
|
-
end
|
40
|
-
context 'when summing another sum' do
|
41
|
-
let(:result) { subject + other }
|
42
|
-
it do
|
43
|
-
expect(result).to be_a(Danica::Formatted)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'knows how to convert it to string' do
|
47
|
-
expect(result.to_s).to eq('v + x + y')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when added by another sum' do
|
52
|
-
let(:result) { other + subject }
|
53
|
-
it do
|
54
|
-
expect(result).to be_a(Danica::Formatted)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'knows how to convert it to string' do
|
58
|
-
expect(result.to_s).to eq('x + y + v')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when operating multiplication and subtraction all toguether' do
|
64
|
-
let(:variable) { Danica::Wrapper::Variable.new(:v) }
|
65
|
-
let(:x) { Danica::Wrapper::Variable.new(:x) }
|
66
|
-
let(:result) { x * (-subject) }
|
67
|
-
it do
|
68
|
-
expect(result).to be_a(Danica::Formatted)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'knows how to convert it to string' do
|
72
|
-
expect(result.to_s).to eq('x \cdot \left(-v\right)')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'formatting' do
|
4
|
-
subject do
|
5
|
-
value = 1 / 3.0
|
6
|
-
Danica.build(:x) do
|
7
|
-
x + value
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#to_tex' do
|
12
|
-
it 'formats the output' do
|
13
|
-
expect(subject.to_tex(decimals: 3)).to eq('x + 0.333')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe Danica::Formatted do
|
19
|
-
let(:expression) do
|
20
|
-
value = 1 / 3.0
|
21
|
-
Danica.build(:x) do
|
22
|
-
x + value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
subject do
|
26
|
-
expression.tex(decimals: 3)
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#to_tex' do
|
30
|
-
it 'formats the output' do
|
31
|
-
expect(subject.to_s).to eq('x + 0.333')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|