danica 2.7.2 → 2.7.7
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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +71 -0
- data/.gitignore +6 -1
- data/.rubocop.yml +18 -0
- data/.rubocop_todo.yml +123 -0
- data/Dockerfile +22 -0
- data/Gemfile +2 -1
- data/README.md +9 -1
- data/Rakefile +4 -0
- data/config/check_specs.yml +13 -0
- data/config/rubycritc.rb +12 -0
- data/config/yardstick.rb +13 -0
- data/config/yardstick.yml +33 -0
- data/danica.gemspec +19 -10
- data/docker-compose.yml +14 -9
- data/lib/danica.rb +2 -1
- data/lib/danica/base_operations.rb +3 -0
- data/lib/danica/builder.rb +2 -0
- data/lib/danica/common.rb +8 -4
- data/lib/danica/dsl.rb +8 -6
- data/lib/danica/dsl/builder.rb +4 -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 +27 -8
- data/lib/danica/function.rb +5 -3
- data/lib/danica/function/name.rb +2 -0
- data/lib/danica/operator.rb +13 -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 +14 -9
- data/lib/danica/wrapper/constant.rb +10 -14
- data/lib/danica/wrapper/container.rb +3 -3
- data/lib/danica/wrapper/group.rb +3 -2
- data/lib/danica/wrapper/negative.rb +3 -1
- data/lib/danica/wrapper/number.rb +6 -3
- data/lib/danica/wrapper/plus_minus.rb +3 -1
- data/lib/danica/wrapper/variable.rb +13 -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 +71 -10
- data/spec/lib/danica/dsl_spec.rb +21 -18
- 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 +34 -13
- 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 +3 -2
- 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 +158 -36
- 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,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spec_helper'
|
3
4
|
|
4
5
|
shared_examples 'a formatted result' do |output|
|
5
6
|
it do
|
@@ -15,21 +16,40 @@ shared_examples('a formatted object that responds to basic operations') do |oper
|
|
15
16
|
operations_map.each do |operation, (output, reverse_output)|
|
16
17
|
describe(operation.to_s) do
|
17
18
|
let(:result) { subject.public_send(operation, 2) }
|
19
|
+
|
18
20
|
it_behaves_like 'a formatted result', output
|
19
21
|
|
20
22
|
context 'when doing it backwards' do
|
21
23
|
let(:result) { Danica::Wrapper::Number.new(2).public_send(operation, subject) }
|
24
|
+
|
22
25
|
it_behaves_like 'a formatted result', reverse_output
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
describe Danica::Formatted do
|
31
|
+
subject do
|
32
|
+
described_class.new(content, format: format, **options)
|
33
|
+
end
|
34
|
+
|
28
35
|
let(:content) { Danica::Wrapper::Variable.new(latex: :V, gnuplot: :v) }
|
29
36
|
let(:format) { :tex }
|
30
37
|
let(:options) { {} }
|
31
|
-
|
32
|
-
|
38
|
+
|
39
|
+
describe '#repack' do
|
40
|
+
let(:expression) { Danica::Wrapper::Number.new(1.0 / 3) }
|
41
|
+
|
42
|
+
it do
|
43
|
+
expect(subject.repack(expression)).to be_a(described_class)
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when there are options' do
|
47
|
+
let(:options) { { decimals: 3 } }
|
48
|
+
|
49
|
+
it 'wraps expression with options' do
|
50
|
+
expect(subject.repack(expression).to_s).to eq('0.333')
|
51
|
+
end
|
52
|
+
end
|
33
53
|
end
|
34
54
|
|
35
55
|
describe '#to_s' do
|
@@ -48,7 +68,7 @@ describe Danica::Formatted do
|
|
48
68
|
end
|
49
69
|
|
50
70
|
context 'when variable has numeric value' do
|
51
|
-
let(:content) { Danica::Wrapper::Number.new(1/3.0) }
|
71
|
+
let(:content) { Danica::Wrapper::Number.new(1 / 3.0) }
|
52
72
|
|
53
73
|
it 'returns the formatted number' do
|
54
74
|
expect(subject.to_s).to eq('0.3333333333333333')
|
@@ -65,13 +85,12 @@ describe Danica::Formatted do
|
|
65
85
|
end
|
66
86
|
|
67
87
|
describe 'operators' do
|
68
|
-
it_behaves_like 'a formatted object that responds to basic operations',
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
88
|
+
it_behaves_like 'a formatted object that responds to basic operations',
|
89
|
+
:+ => ['V + 2', '2 + V'],
|
90
|
+
:- => ['V -2', '2 -V'],
|
91
|
+
:* => ['V \cdot 2', '2 \cdot V'],
|
92
|
+
:/ => ['\frac{V}{2}', '\frac{2}{V}'],
|
93
|
+
:** => ['V^{2}', '2^{V}']
|
75
94
|
|
76
95
|
describe '-@' do
|
77
96
|
it do
|
@@ -108,7 +127,7 @@ describe Danica::Formatted do
|
|
108
127
|
|
109
128
|
describe '#tex' do
|
110
129
|
it do
|
111
|
-
expect(subject.tex).to be_a(
|
130
|
+
expect(subject.tex).to be_a(described_class)
|
112
131
|
end
|
113
132
|
|
114
133
|
context 'when original format is tex' do
|
@@ -123,6 +142,7 @@ describe Danica::Formatted do
|
|
123
142
|
|
124
143
|
context 'when original format is gnu' do
|
125
144
|
let(:format) { :gnu }
|
145
|
+
|
126
146
|
it 'returns the tex string' do
|
127
147
|
expect(subject.tex.to_s).to eq('V')
|
128
148
|
end
|
@@ -135,7 +155,7 @@ describe Danica::Formatted do
|
|
135
155
|
|
136
156
|
describe '#gnu' do
|
137
157
|
it do
|
138
|
-
expect(subject.gnu).to be_a(
|
158
|
+
expect(subject.gnu).to be_a(described_class)
|
139
159
|
end
|
140
160
|
|
141
161
|
context 'when original format is tex' do
|
@@ -146,6 +166,7 @@ describe Danica::Formatted do
|
|
146
166
|
|
147
167
|
context 'when original format is gnu' do
|
148
168
|
let(:format) { :gnu }
|
169
|
+
|
149
170
|
it 'returns the gnu string' do
|
150
171
|
expect(subject.gnu.to_s).to eq('v')
|
151
172
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Function::Name do
|
4
|
-
let(:x) {
|
6
|
+
let(:x) { Danica::Wrapper::Variable.new(name: :x, latex: '\mu', gnuplot: 'u') }
|
5
7
|
let(:subject) { described_class.new(name: :f, variables: [x]) }
|
6
8
|
|
7
9
|
it_behaves_like 'an object that respond to basic_methods'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
shared_examples 'a generically generated function' do
|
@@ -28,8 +30,9 @@ end
|
|
28
30
|
|
29
31
|
describe Danica::Function do
|
30
32
|
subject { function }
|
33
|
+
|
31
34
|
let(:function) { function_class.new }
|
32
|
-
let(:variables) { %i
|
35
|
+
let(:variables) { %i[x y] }
|
33
36
|
let(:function_class) do
|
34
37
|
described_class.build(*variables) do
|
35
38
|
Danica::Operator::Power.new(x, y)
|
@@ -37,12 +40,13 @@ describe Danica::Function do
|
|
37
40
|
end
|
38
41
|
|
39
42
|
describe '.for' do
|
40
|
-
let(:expression_class) { Danica::Expression::Gauss }
|
41
|
-
let(:expression) { expression_class.new }
|
42
43
|
subject do
|
43
44
|
described_class.for(expression_class).new
|
44
45
|
end
|
45
46
|
|
47
|
+
let(:expression_class) { Danica::Expression::Gauss }
|
48
|
+
let(:expression) { expression_class.new }
|
49
|
+
|
46
50
|
it 'returns a function' do
|
47
51
|
expect(subject).to be_a(described_class)
|
48
52
|
end
|
@@ -111,7 +115,7 @@ describe Danica::Function do
|
|
111
115
|
let(:function_class) { Danica::Function::SaddleParabole }
|
112
116
|
|
113
117
|
it 'has the defined variables on class definition' do
|
114
|
-
expect(function_class.variables_names).to eq([
|
118
|
+
expect(function_class.variables_names).to eq(%i[x y])
|
115
119
|
end
|
116
120
|
|
117
121
|
it 'has the defined variables' do
|
@@ -143,6 +147,7 @@ describe Danica::Function do
|
|
143
147
|
f.name = :f
|
144
148
|
end
|
145
149
|
end
|
150
|
+
|
146
151
|
it_behaves_like 'a generically generated function'
|
147
152
|
end
|
148
153
|
|
@@ -157,9 +162,8 @@ describe Danica::Function do
|
|
157
162
|
|
158
163
|
context 'when changing the function variables' do
|
159
164
|
it 'changes the name variables' do
|
160
|
-
expect
|
161
|
-
function.
|
162
|
-
end.to change { function.name.variables.map(&:content) }
|
165
|
+
expect { function.x = 2 }
|
166
|
+
.to(change { function.name.variables.map(&:content) })
|
163
167
|
end
|
164
168
|
end
|
165
169
|
end
|
@@ -174,7 +178,7 @@ describe Danica::Function do
|
|
174
178
|
expect(function.to_tex).to eq('f(x, y) = x^{y}')
|
175
179
|
end
|
176
180
|
|
177
|
-
context '
|
181
|
+
context 'when one of the variables is changed' do
|
178
182
|
it 'uses the new variable value' do
|
179
183
|
expect do
|
180
184
|
function.y = 2
|
@@ -192,7 +196,7 @@ describe Danica::Function do
|
|
192
196
|
expect(function.to_tex).to eq('f(y) = \pi^{y}')
|
193
197
|
end
|
194
198
|
|
195
|
-
context '
|
199
|
+
context 'when name is in the hash' do
|
196
200
|
let(:function) do
|
197
201
|
function_class.new(name: :f, x: { latex: '\pi', gnuplot: 'pi', value: 3.14 })
|
198
202
|
end
|
@@ -244,7 +248,7 @@ describe Danica::Function do
|
|
244
248
|
expect(function.to_gnu).to eq('f(y) = pi**(y)')
|
245
249
|
end
|
246
250
|
|
247
|
-
context '
|
251
|
+
context 'when name is in the hash' do
|
248
252
|
let(:function) do
|
249
253
|
function_class.new(name: :f, x: { latex: '\pi', gnuplot: 'pi', value: 3.14 })
|
250
254
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Operator::Addition do
|
@@ -11,7 +13,7 @@ describe Danica::Operator::Addition do
|
|
11
13
|
|
12
14
|
it_behaves_like 'an object that respond to basic_methods'
|
13
15
|
|
14
|
-
it_behaves_like 'an object with basic operation', ignore: %i
|
16
|
+
it_behaves_like 'an object with basic operation', ignore: %i[+ -]
|
15
17
|
it_behaves_like 'an object with + operation' do
|
16
18
|
context 'when other is also a addition' do
|
17
19
|
let(:other) { described_class.new(200, 5) }
|
@@ -23,18 +25,17 @@ describe Danica::Operator::Addition do
|
|
23
25
|
end
|
24
26
|
it_behaves_like 'an object with - operation'
|
25
27
|
|
26
|
-
it_behaves_like 'a operator that joins many variables with same operation',
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
28
|
+
it_behaves_like 'a operator that joins many variables with same operation',
|
29
|
+
calculated: 10,
|
30
|
+
numeric_variables: [1.5, 3.0, 3.5],
|
31
|
+
tex: {
|
32
|
+
string_expected: 'X1 + X2 + X3 + X4',
|
33
|
+
integer_expected: '1.5 + 3 + X3 + X4',
|
34
|
+
float_expected: '1.5 + 3 + 3.5 + X4'
|
35
|
+
},
|
36
|
+
gnu: {
|
37
|
+
string_expected: 'X1 + X2 + X3 + X4',
|
38
|
+
integer_expected: '1.5 + 3 + X3 + X4',
|
39
|
+
float_expected: '1.5 + 3 + 3.5 + X4'
|
40
|
+
}
|
40
41
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Operator::Cos do
|
@@ -6,12 +8,11 @@ describe Danica::Operator::Cos do
|
|
6
8
|
it_behaves_like 'an object that respond to basic_methods'
|
7
9
|
it_behaves_like 'an object with basic operation'
|
8
10
|
|
9
|
-
it_behaves_like 'a operator with a single input value',
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
11
|
+
it_behaves_like 'a operator with a single input value',
|
12
|
+
variable_value: Math::PI,
|
13
|
+
expected_number: -1.0,
|
14
|
+
expected_number_tex: 'cos(3.141592653589793)',
|
15
|
+
expected_number_gnu: 'cos(3.141592653589793)',
|
16
|
+
expected_tex: 'cos(X)',
|
17
|
+
expected_gnu: 'cos(X)'
|
17
18
|
end
|
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Operator::Division do
|
4
|
-
let(:variables) { [2, 4] }
|
5
6
|
subject { described_class.new(*variables) }
|
6
7
|
|
8
|
+
let(:variables) { [2, 4] }
|
9
|
+
|
7
10
|
describe '#numerator' do
|
8
11
|
it 'returns the numerator' do
|
9
12
|
expect(subject.numerator).to eq(Danica::Wrapper::Number.new(2))
|
@@ -19,25 +22,24 @@ describe Danica::Operator::Division do
|
|
19
22
|
it_behaves_like 'an object that respond to basic_methods'
|
20
23
|
it_behaves_like 'an object with basic operation'
|
21
24
|
|
22
|
-
it_behaves_like 'a operator that has two terms', :division,
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
25
|
+
it_behaves_like 'a operator that has two terms', :division,
|
26
|
+
values: [2, 4],
|
27
|
+
calculated: 1.0 / 2.0,
|
28
|
+
to_tex: {
|
29
|
+
string_expected: '\frac{X1}{X2}',
|
30
|
+
numeric_string_expected: '\frac{2}{4}',
|
31
|
+
partial_string_expected: '\frac{2}{X2}'
|
32
|
+
},
|
33
|
+
to_gnu: {
|
34
|
+
string_expected: '(X1)/(X2)',
|
35
|
+
numeric_string_expected: '(2)/(4)',
|
36
|
+
partial_string_expected: '(2)/(X2)'
|
37
|
+
}
|
36
38
|
|
37
39
|
describe 'more complex division' do
|
38
40
|
describe 'of two additions' do
|
39
41
|
subject do
|
40
|
-
|
42
|
+
described_class.new(
|
41
43
|
Danica::Operator::Addition.new(2, :x),
|
42
44
|
Danica::Operator::Addition.new(3, :y)
|
43
45
|
)
|
@@ -55,4 +57,3 @@ describe Danica::Operator::Division do
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
58
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Operator::Exponential do
|
@@ -6,12 +8,11 @@ describe Danica::Operator::Exponential do
|
|
6
8
|
it_behaves_like 'an object that respond to basic_methods'
|
7
9
|
it_behaves_like 'an object with basic operation'
|
8
10
|
|
9
|
-
it_behaves_like 'a operator with a single input value',
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
11
|
+
it_behaves_like 'a operator with a single input value',
|
12
|
+
variable_value: 2,
|
13
|
+
expected_number: Math.exp(2),
|
14
|
+
expected_number_tex: 'e^{2}',
|
15
|
+
expected_number_gnu: 'exp(2)',
|
16
|
+
expected_tex: 'e^{X}',
|
17
|
+
expected_gnu: 'exp(X)'
|
17
18
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Operator::Multiplication do
|
4
|
-
subject { described_class.new(2,4) }
|
6
|
+
subject { described_class.new(2, 4) }
|
5
7
|
|
6
8
|
it 'initializes from array' do
|
7
9
|
expect do
|
@@ -22,18 +24,17 @@ describe Danica::Operator::Multiplication do
|
|
22
24
|
end
|
23
25
|
it_behaves_like 'an object with basic operation', ignore: :*
|
24
26
|
|
25
|
-
it_behaves_like 'a operator that joins many variables with same operation',
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
27
|
+
it_behaves_like 'a operator that joins many variables with same operation',
|
28
|
+
calculated: 24,
|
29
|
+
numeric_variables: [1.5, 2, 3.5],
|
30
|
+
tex: {
|
31
|
+
string_expected: %w[X1 X2 X3 X4].join(' \cdot '),
|
32
|
+
integer_expected: %w[1.5 2 X3 X4].join(' \cdot '),
|
33
|
+
float_expected: %w[1.5 2 3.5 X4].join(' \cdot ')
|
34
|
+
},
|
35
|
+
gnu: {
|
36
|
+
string_expected: %w[X1 X2 X3 X4].join(' * '),
|
37
|
+
integer_expected: %w[1.5 2 X3 X4].join(' * '),
|
38
|
+
float_expected: %w[1.5 2 3.5 X4].join(' * ')
|
39
|
+
}
|
39
40
|
end
|
@@ -1,25 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Operator::Power do
|
4
|
-
let(:variables) { [2, 4] }
|
5
6
|
subject { described_class.new(*variables) }
|
6
7
|
|
8
|
+
let(:variables) { [2, 4] }
|
9
|
+
|
7
10
|
it_behaves_like 'an object that respond to basic_methods'
|
8
11
|
it_behaves_like 'an object with basic operation'
|
9
12
|
|
10
|
-
it_behaves_like 'a operator that has two terms', :power,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
13
|
+
it_behaves_like 'a operator that has two terms', :power,
|
14
|
+
values: [3, 2],
|
15
|
+
calculated: 9.0,
|
16
|
+
to_tex: {
|
17
|
+
string_expected: 'X1^{X2}',
|
18
|
+
numeric_string_expected: '3^{2}',
|
19
|
+
partial_string_expected: '3^{X2}'
|
20
|
+
},
|
21
|
+
to_gnu: {
|
22
|
+
string_expected: 'X1**(X2)',
|
23
|
+
numeric_string_expected: '3**(2)',
|
24
|
+
partial_string_expected: '3**(X2)'
|
25
|
+
}
|
24
26
|
end
|
25
|
-
|