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.
Files changed (123) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +71 -0
  3. data/.gitignore +6 -1
  4. data/.rubocop.yml +18 -0
  5. data/.rubocop_todo.yml +123 -0
  6. data/Dockerfile +22 -0
  7. data/Gemfile +2 -1
  8. data/README.md +9 -1
  9. data/Rakefile +4 -0
  10. data/config/check_specs.yml +13 -0
  11. data/config/rubycritc.rb +12 -0
  12. data/config/yardstick.rb +13 -0
  13. data/config/yardstick.yml +33 -0
  14. data/danica.gemspec +19 -10
  15. data/docker-compose.yml +14 -9
  16. data/lib/danica.rb +2 -1
  17. data/lib/danica/base_operations.rb +3 -0
  18. data/lib/danica/builder.rb +2 -0
  19. data/lib/danica/common.rb +8 -4
  20. data/lib/danica/dsl.rb +8 -6
  21. data/lib/danica/dsl/builder.rb +4 -1
  22. data/lib/danica/equation.rb +3 -3
  23. data/lib/danica/equation/builder.rb +2 -0
  24. data/lib/danica/exception.rb +3 -2
  25. data/lib/danica/expressable.rb +14 -8
  26. data/lib/danica/expression.rb +4 -2
  27. data/lib/danica/expression/gauss.rb +5 -5
  28. data/lib/danica/formatted.rb +27 -8
  29. data/lib/danica/function.rb +5 -3
  30. data/lib/danica/function/name.rb +2 -0
  31. data/lib/danica/operator.rb +13 -9
  32. data/lib/danica/operator/addition.rb +4 -3
  33. data/lib/danica/operator/chained.rb +4 -3
  34. data/lib/danica/operator/cos.rb +2 -1
  35. data/lib/danica/operator/division.rb +2 -1
  36. data/lib/danica/operator/exponential.rb +2 -1
  37. data/lib/danica/operator/functional.rb +3 -2
  38. data/lib/danica/operator/multiplication.rb +4 -2
  39. data/lib/danica/operator/power.rb +4 -3
  40. data/lib/danica/operator/sin.rb +2 -1
  41. data/lib/danica/operator/squared_root.rb +2 -1
  42. data/lib/danica/variables_holder.rb +7 -4
  43. data/lib/danica/variables_holder/alias_builder.rb +4 -4
  44. data/lib/danica/variables_holder/calculator.rb +2 -0
  45. data/lib/danica/variables_holder/store.rb +3 -2
  46. data/lib/danica/variables_holder/variables_builder.rb +2 -1
  47. data/lib/danica/version.rb +3 -1
  48. data/lib/danica/wrapper.rb +14 -9
  49. data/lib/danica/wrapper/constant.rb +10 -14
  50. data/lib/danica/wrapper/container.rb +3 -3
  51. data/lib/danica/wrapper/group.rb +3 -2
  52. data/lib/danica/wrapper/negative.rb +3 -1
  53. data/lib/danica/wrapper/number.rb +6 -3
  54. data/lib/danica/wrapper/plus_minus.rb +3 -1
  55. data/lib/danica/wrapper/variable.rb +13 -8
  56. data/scripts/check_readme.sh +6 -0
  57. data/scripts/rubycritic.sh +10 -0
  58. data/spec/integration/global/danica/formatted_spec.rb +87 -0
  59. data/spec/integration/global/danica/operator/addition_spec.rb +32 -0
  60. data/spec/integration/{multiplication_spec.rb → global/danica/operator/multiplication_spec.rb} +12 -9
  61. data/spec/integration/{power_spec.rb → global/danica/operator/power_spec.rb} +4 -2
  62. data/spec/integration/{negative_spec.rb → global/danica/wrapper/negative_spec.rb} +9 -8
  63. data/spec/integration/{plus_minus_spec.rb → global/danica/wrapper/plus_minus_spec.rb} +5 -4
  64. data/spec/integration/readme/constant_spec.rb +4 -1
  65. data/spec/integration/readme/danica/formatted_spec.rb +24 -0
  66. data/spec/integration/readme/danica_spec.rb +20 -4
  67. data/spec/integration/readme/equation_spec.rb +4 -2
  68. data/spec/integration/readme/expression_spec.rb +11 -8
  69. data/spec/integration/readme/function_spec.rb +11 -7
  70. data/spec/integration/readme/number_spec.rb +9 -8
  71. data/spec/integration/readme/operator_spec.rb +3 -1
  72. data/spec/integration/readme/variables_spec.rb +8 -6
  73. data/spec/lib/danica/common_spec.rb +71 -10
  74. data/spec/lib/danica/dsl_spec.rb +21 -18
  75. data/spec/lib/danica/equation_spec.rb +10 -8
  76. data/spec/lib/danica/expressable_spec.rb +5 -2
  77. data/spec/lib/danica/expression/gauss_spec.rb +6 -3
  78. data/spec/lib/danica/expression_spec.rb +48 -26
  79. data/spec/lib/danica/formatted_spec.rb +34 -13
  80. data/spec/lib/danica/function/name_spec.rb +3 -1
  81. data/spec/lib/danica/function_spec.rb +14 -10
  82. data/spec/lib/danica/operator/addition_spec.rb +16 -15
  83. data/spec/lib/danica/operator/cos_spec.rb +9 -8
  84. data/spec/lib/danica/operator/division_spec.rb +18 -17
  85. data/spec/lib/danica/operator/exponential_spec.rb +9 -8
  86. data/spec/lib/danica/operator/multiplication_spec.rb +16 -15
  87. data/spec/lib/danica/operator/power_spec.rb +17 -16
  88. data/spec/lib/danica/operator/sin_spec.rb +9 -8
  89. data/spec/lib/danica/operator/squared_root_spec.rb +9 -8
  90. data/spec/lib/danica/operator_spec.rb +13 -4
  91. data/spec/lib/danica/variables_holder/store_spec.rb +19 -13
  92. data/spec/lib/danica/variables_holder_spec.rb +76 -59
  93. data/spec/lib/danica/wrapper/constant_spec.rb +9 -2
  94. data/spec/lib/danica/wrapper/group_spec.rb +4 -1
  95. data/spec/lib/danica/wrapper/negative_spec.rb +4 -1
  96. data/spec/lib/danica/wrapper/number_spec.rb +8 -3
  97. data/spec/lib/danica/wrapper/plus_minus_spec.rb +4 -1
  98. data/spec/lib/danica/wrapper/variable_spec.rb +6 -3
  99. data/spec/lib/danica/wrapper_spec.rb +14 -12
  100. data/spec/lib/danica_spec.rb +6 -5
  101. data/spec/spec_helper.rb +3 -2
  102. data/spec/support/models/expression/baskara.rb +3 -3
  103. data/spec/support/models/expression/parabole.rb +2 -0
  104. data/spec/support/models/expression/quadratic_sum.rb +3 -1
  105. data/spec/support/models/expression/spatial.rb +2 -1
  106. data/spec/support/models/function/my_function.rb +3 -1
  107. data/spec/support/models/function/parabole.rb +1 -1
  108. data/spec/support/models/function/quadratic_sum.rb +2 -0
  109. data/spec/support/models/function/spatial.rb +2 -0
  110. data/spec/support/models/operator/inverse.rb +3 -1
  111. data/spec/support/models/operator/my_operator.rb +3 -1
  112. data/spec/support/models/variables_holder/dummy.rb +3 -1
  113. data/spec/support/shared_contexts/common.rb +4 -2
  114. data/spec/support/shared_examples/base_operations.rb +7 -4
  115. data/spec/support/shared_examples/common.rb +3 -1
  116. data/spec/support/shared_examples/operator/chained.rb +12 -6
  117. data/spec/support/shared_examples/operator/dual_term.rb +9 -8
  118. data/spec/support/shared_examples/operator/single_input.rb +7 -2
  119. data/spec/support/shared_examples/variable.rb +8 -4
  120. metadata +158 -36
  121. data/spec/integration/addition_spec.rb +0 -28
  122. data/spec/integration/formatted_spec.rb +0 -75
  123. data/spec/integration/readme/formatting_spec.rb +0 -34
@@ -1,5 +1,6 @@
1
- require 'spec_helper'
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
- subject do
32
- described_class.new(content, format, options)
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
- :+ => ['V + 2', '2 + V'],
70
- :- => ['V -2', '2 -V'],
71
- :* => ['V \cdot 2', '2 \cdot V'],
72
- :/ => ['\frac{V}{2}', '\frac{2}{V}'],
73
- :** => ['V^{2}', '2^{V}']
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(Danica::Formatted)
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(Danica::Formatted)
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) { Danica::Wrapper::Variable.new(name: :x, latex: '\mu', gnuplot: 'u')}
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(x y) }
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([:x, :y])
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 do
161
- function.x = 2
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 'and one of the variables is changed' do
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 'from a hash' do
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 'from a hash' do
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
- calculated: 10,
28
- numeric_variables: [ 1.5, 3.0, 3.5 ],
29
- tex: {
30
- string_expected: 'X1 + X2 + X3 + X4',
31
- integer_expected: '1.5 + 3 + X3 + X4',
32
- float_expected: '1.5 + 3 + 3.5 + X4'
33
- },
34
- gnu: {
35
- string_expected: 'X1 + X2 + X3 + X4',
36
- integer_expected: '1.5 + 3 + X3 + X4',
37
- float_expected: '1.5 + 3 + 3.5 + X4'
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
- variable_value: Math::PI,
11
- expected_number: -1.0,
12
- expected_number_tex: 'cos(3.141592653589793)',
13
- expected_number_gnu: 'cos(3.141592653589793)',
14
- expected_tex: 'cos(X)',
15
- expected_gnu: 'cos(X)'
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
- values: [ 2, 4 ],
24
- calculated: 1.0 / 2.0,
25
- to_tex: {
26
- string_expected: '\frac{X1}{X2}',
27
- numeric_string_expected: '\frac{2}{4}',
28
- partial_string_expected: '\frac{2}{X2}'
29
- },
30
- to_gnu: {
31
- string_expected: '(X1)/(X2)',
32
- numeric_string_expected: '(2)/(4)',
33
- partial_string_expected: '(2)/(X2)'
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
- Danica::Operator::Division.new(
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
- variable_value: 2,
11
- expected_number: Math.exp(2),
12
- expected_number_tex: 'e^{2}',
13
- expected_number_gnu: 'exp(2)',
14
- expected_tex: 'e^{X}',
15
- expected_gnu: 'exp(X)'
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
- calculated: 24,
27
- numeric_variables: [ 1.5, 2, 3.5 ],
28
- tex: {
29
- string_expected: %w(X1 X2 X3 X4).join(' \cdot '),
30
- integer_expected: %w(1.5 2 X3 X4).join(' \cdot '),
31
- float_expected: %w(1.5 2 3.5 X4).join(' \cdot ')
32
- },
33
- gnu: {
34
- string_expected: %w(X1 X2 X3 X4).join(' * '),
35
- integer_expected: %w(1.5 2 X3 X4).join(' * '),
36
- float_expected: %w(1.5 2 3.5 X4).join(' * '),
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
- values: [ 3, 2 ],
12
- calculated: 9.0,
13
- to_tex: {
14
- string_expected: 'X1^{X2}',
15
- numeric_string_expected: '3^{2}',
16
- partial_string_expected: '3^{X2}'
17
- },
18
- to_gnu: {
19
- string_expected: 'X1**(X2)',
20
- numeric_string_expected: '3**(2)',
21
- partial_string_expected: '3**(X2)'
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
-