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
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
DIFF_LIST=$(git diff --name-only $CIRCLE_SHA1 $(git merge-base $CIRCLE_SHA1 origin/master) | grep "^lib/")
|
4
|
+
|
5
|
+
if [ ! -z "$DIFF_LIST" ]; then
|
6
|
+
mkdir -p tmp/rubycritic/compare
|
7
|
+
bundle exec rubycritic --format console --branch origin/master -t 0 --maximum-decrease 1 $DIFF_LIST
|
8
|
+
else
|
9
|
+
echo "No changes detected. Skipping rubycritic..."
|
10
|
+
fi
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Danica::Formatted do
|
6
|
+
describe 'integration of formatted objects' do
|
7
|
+
subject do
|
8
|
+
variable.tex
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:variable) { Danica.build(:v) { v } }
|
12
|
+
|
13
|
+
context 'when interacting with a multiplication' do
|
14
|
+
let(:other) do
|
15
|
+
Danica.build(:x, :y) { x * y }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when multipling another multiplication' do
|
19
|
+
let(:result) { subject * other }
|
20
|
+
|
21
|
+
it do
|
22
|
+
expect(result).to be_a(described_class)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'knows how to convert it to string' do
|
26
|
+
expect(result.to_s).to eq('v \\cdot x \\cdot y')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when multiplicated by another multiplication' do
|
31
|
+
let(:result) { other * subject }
|
32
|
+
|
33
|
+
it do
|
34
|
+
expect(result).to be_a(described_class)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'knows how to convert it to string' do
|
38
|
+
expect(result.to_s).to eq('x \\cdot y \\cdot v')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when interacting with a sum' do
|
44
|
+
let(:other) do
|
45
|
+
Danica.build(:x, :y) { x + y }
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when summing another sum' do
|
49
|
+
let(:result) { subject + other }
|
50
|
+
|
51
|
+
it do
|
52
|
+
expect(result).to be_a(described_class)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'knows how to convert it to string' do
|
56
|
+
expect(result.to_s).to eq('v + x + y')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when added by another sum' do
|
61
|
+
let(:result) { other + subject }
|
62
|
+
|
63
|
+
it do
|
64
|
+
expect(result).to be_a(described_class)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'knows how to convert it to string' do
|
68
|
+
expect(result.to_s).to eq('x + y + v')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when operating multiplication and subtraction all toguether' do
|
74
|
+
let(:variable) { Danica::Wrapper::Variable.new(:v) }
|
75
|
+
let(:x) { Danica::Wrapper::Variable.new(:x) }
|
76
|
+
let(:result) { x * -subject }
|
77
|
+
|
78
|
+
it do
|
79
|
+
expect(result).to be_a(described_class)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'knows how to convert it to string' do
|
83
|
+
expect(result.to_s).to eq('x \cdot \left(-v\right)')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Danica::Operator::Addition do
|
6
|
+
describe 'integration' do
|
7
|
+
describe 'with negative and positivenegative (+/-) numbers' do
|
8
|
+
subject do
|
9
|
+
described_class.new(
|
10
|
+
Danica::Wrapper::Negative.new(1),
|
11
|
+
2,
|
12
|
+
-3,
|
13
|
+
4,
|
14
|
+
Danica::Wrapper::PlusMinus.new(5),
|
15
|
+
Danica::Wrapper::Number.new(-6)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#to_gnu' do
|
20
|
+
it 'returns the correct string' do
|
21
|
+
expect(subject.to_gnu).to eq('-1 + 2 -3 + 4 + 5 -6')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#to_tex' do
|
26
|
+
it 'returns the correct string' do
|
27
|
+
expect(subject.to_tex).to eq('-1 + 2 -3 + 4 \pm 5 -6')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/integration/{multiplication_spec.rb → global/danica/operator/multiplication_spec.rb}
RENAMED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe
|
5
|
+
describe Danica::Operator::Multiplication do
|
4
6
|
describe 'of number and addition' do
|
5
7
|
subject do
|
6
|
-
|
8
|
+
described_class.new(
|
7
9
|
3, Danica::Operator::Addition.new(2, 4)
|
8
10
|
)
|
9
11
|
end
|
@@ -23,9 +25,9 @@ describe 'integration of multiplication' do
|
|
23
25
|
|
24
26
|
describe 'of additions' do
|
25
27
|
subject do
|
26
|
-
|
27
|
-
Danica::Operator::Addition.new(1,2),
|
28
|
-
Danica::Operator::Addition.new(3,4)
|
28
|
+
described_class.new(
|
29
|
+
Danica::Operator::Addition.new(1, 2),
|
30
|
+
Danica::Operator::Addition.new(3, 4)
|
29
31
|
)
|
30
32
|
end
|
31
33
|
|
@@ -44,13 +46,14 @@ describe 'integration of multiplication' do
|
|
44
46
|
|
45
47
|
describe 'when calling * operator' do
|
46
48
|
subject do
|
47
|
-
|
49
|
+
described_class.new(:x, :y)
|
48
50
|
end
|
51
|
+
|
49
52
|
let(:variable) { Danica::Wrapper::Variable.new(:v) }
|
50
53
|
let(:result) { subject * variable }
|
51
54
|
|
52
55
|
it do
|
53
|
-
expect(result).to be_a(
|
56
|
+
expect(result).to be_a(described_class)
|
54
57
|
end
|
55
58
|
|
56
59
|
it 'knows how to order variables' do
|
@@ -61,7 +64,7 @@ describe 'integration of multiplication' do
|
|
61
64
|
let(:result) { variable * subject }
|
62
65
|
|
63
66
|
it do
|
64
|
-
expect(result).to be_a(
|
67
|
+
expect(result).to be_a(described_class)
|
65
68
|
end
|
66
69
|
|
67
70
|
it 'knows how to order variables' do
|
@@ -77,7 +80,7 @@ describe 'integration of multiplication' do
|
|
77
80
|
let(:result) { x * negative }
|
78
81
|
|
79
82
|
it do
|
80
|
-
expect(result).to be_a(
|
83
|
+
expect(result).to be_a(described_class)
|
81
84
|
end
|
82
85
|
|
83
86
|
it 'knows how to order variables' do
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe
|
5
|
+
describe Danica::Operator::Power do
|
4
6
|
describe 'of additions' do
|
5
7
|
subject do
|
6
|
-
|
8
|
+
described_class.new(
|
7
9
|
Danica::Operator::Addition.new(3, 4),
|
8
10
|
Danica::Operator::Addition.new(5, 6)
|
9
11
|
)
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe
|
5
|
+
describe Danica::Wrapper::Negative do
|
4
6
|
describe 'with a addition' do
|
5
7
|
subject do
|
6
|
-
|
7
|
-
Danica::Operator::Addition.new(1,2,3)
|
8
|
+
described_class.new(
|
9
|
+
Danica::Operator::Addition.new(1, 2, 3)
|
8
10
|
)
|
9
11
|
end
|
10
12
|
|
@@ -21,13 +23,14 @@ describe 'integration of negative' do
|
|
21
23
|
end
|
22
24
|
|
23
25
|
describe 'when it is the result of an expression' do
|
26
|
+
subject do
|
27
|
+
x - negative_parcel
|
28
|
+
end
|
29
|
+
|
24
30
|
let(:x) { Danica::Wrapper::Variable.new(:x) }
|
25
31
|
let(:y) { Danica::Wrapper::Variable.new(:y) }
|
26
32
|
let(:z) { Danica::Wrapper::Variable.new(:z) }
|
27
33
|
let(:negative_parcel) { y + z }
|
28
|
-
subject do
|
29
|
-
x - negative_parcel
|
30
|
-
end
|
31
34
|
|
32
35
|
it 'wraps parcel into a group' do
|
33
36
|
expect(subject.to_gnu).to eq('x -(y + z)')
|
@@ -51,5 +54,3 @@ describe 'integration of negative' do
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|
54
|
-
|
55
|
-
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe
|
5
|
+
describe Danica::Wrapper::PlusMinus do
|
4
6
|
describe 'with a addition' do
|
5
7
|
subject do
|
6
|
-
|
7
|
-
Danica::Operator::Addition.new(1,2,3)
|
8
|
+
described_class.new(
|
9
|
+
Danica::Operator::Addition.new(1, 2, 3)
|
8
10
|
)
|
9
11
|
end
|
10
12
|
|
@@ -21,4 +23,3 @@ describe 'integration of positive negative' do
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Wrapper::Constant do
|
4
6
|
subject do
|
5
|
-
|
7
|
+
described_class.new(gnuplot: 'pi', latex: '\pi', value: 3.141592)
|
6
8
|
end
|
9
|
+
|
7
10
|
let(:output) do
|
8
11
|
{
|
9
12
|
tex: '\pi',
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Danica::Formatted do
|
6
|
+
describe 'formatting' do
|
7
|
+
subject do
|
8
|
+
expression.tex(decimals: 3)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:expression) do
|
12
|
+
value = 1 / 3.0
|
13
|
+
Danica.build(:x) do
|
14
|
+
x + value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#to_tex' do
|
19
|
+
it 'formats the output' do
|
20
|
+
expect(subject.to_s).to eq('x + 0.333')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,11 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica do
|
6
|
+
describe 'formatting' do
|
7
|
+
subject do
|
8
|
+
value = 1 / 3.0
|
9
|
+
described_class.build(:x) do
|
10
|
+
x + value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#to_tex' do
|
15
|
+
it 'formats the output' do
|
16
|
+
expect(subject.to_tex(decimals: 3)).to eq('x + 0.333')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
4
21
|
describe '.build' do
|
5
22
|
context 'when building an expression' do
|
6
23
|
let(:expression) do
|
7
|
-
|
8
|
-
(number(1) + 2) * power(3,4)
|
24
|
+
described_class.build do
|
25
|
+
(number(1) + 2) * power(3, 4)
|
9
26
|
end
|
10
27
|
end
|
11
28
|
|
@@ -16,7 +33,7 @@ describe Danica do
|
|
16
33
|
|
17
34
|
context 'when building a function' do
|
18
35
|
let(:function) do
|
19
|
-
|
36
|
+
described_class.build do
|
20
37
|
Danica::Function.create(:x, :y) do
|
21
38
|
(number(1) + x) * power(3, y)
|
22
39
|
end
|
@@ -29,4 +46,3 @@ describe Danica do
|
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
32
|
-
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Equation do
|
4
6
|
subject do
|
5
7
|
described_class.build(:x, :y, :z) do
|
6
|
-
left { x
|
7
|
-
right { number(1) - z
|
8
|
+
left { x**2 + y**2 }
|
9
|
+
right { number(1) - z**2 }
|
8
10
|
end.new
|
9
11
|
end
|
10
12
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Expression::Baskara do
|
@@ -9,18 +11,19 @@ describe Danica::Expression::Baskara do
|
|
9
11
|
end
|
10
12
|
|
11
13
|
describe Danica::Expression do
|
14
|
+
subject { clazz.new }
|
15
|
+
|
12
16
|
let(:clazz) do
|
13
17
|
described_class.build(:a, :b, :c) do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
(
|
19
|
+
negative(b) + Danica::Wrapper::PlusMinus.new(
|
20
|
+
squared_root(
|
21
|
+
power(b, 2) - multiplication(4, a, c)
|
22
|
+
)
|
23
|
+
)
|
24
|
+
) / (number(2) * a)
|
21
25
|
end
|
22
26
|
end
|
23
|
-
subject { clazz.new }
|
24
27
|
|
25
28
|
describe 'to_tex' do
|
26
29
|
it 'returns bascara tex string' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Danica::Function::Spatial do
|
@@ -13,19 +15,20 @@ describe Danica::Function::Spatial do
|
|
13
15
|
let(:name) { :f }
|
14
16
|
|
15
17
|
context 'when using it as default' do
|
18
|
+
subject { described_class.new }
|
19
|
+
|
16
20
|
let(:left) { "#{name}(time, acceleration, initial_space, initial_velocity)" }
|
17
21
|
let(:right) { 'initial_space + initial_velocity * time + (acceleration * time**(2))/(2)' }
|
18
22
|
|
19
|
-
subject { described_class.new }
|
20
|
-
|
21
23
|
it 'knows how to return to gnu format' do
|
22
24
|
expect(subject.to_gnu).to eq("#{left} = #{right}")
|
23
25
|
end
|
24
26
|
|
25
27
|
context 'when changing the name' do
|
26
|
-
let(:name) { :g }
|
27
28
|
subject { described_class.new(name: name) }
|
28
29
|
|
30
|
+
let(:name) { :g }
|
31
|
+
|
29
32
|
it 'knows how to return to gnu format' do
|
30
33
|
expect(subject.to_gnu).to eq("#{left} = #{right}")
|
31
34
|
end
|
@@ -33,14 +36,14 @@ describe Danica::Function::Spatial do
|
|
33
36
|
end
|
34
37
|
|
35
38
|
context 'when setting the variables' do
|
39
|
+
subject { described_class.new(variables) }
|
40
|
+
|
36
41
|
let(:variables) do
|
37
42
|
{ time: :t, acceleration: :a, initial_space: :s0, initial_velocity: :v0 }
|
38
43
|
end
|
39
44
|
let(:left) { "#{name}(t, a, s0, v0)" }
|
40
45
|
let(:right) { 's0 + v0 * t + (a * t**(2))/(2)' }
|
41
46
|
|
42
|
-
subject { described_class.new(variables) }
|
43
|
-
|
44
47
|
it 'knows how to return to gnu format' do
|
45
48
|
expect(subject.to_gnu).to eq("#{left} = #{right}")
|
46
49
|
end
|
@@ -76,13 +79,14 @@ end
|
|
76
79
|
describe Danica::Function::QuadraticSum do
|
77
80
|
describe '#to_tex' do
|
78
81
|
it 'creates a funcion out of an expression' do
|
79
|
-
expect(subject.to_tex).to eq(
|
82
|
+
expect(subject.to_tex).to eq('f(x, y) = \\left(x + y\\right)^{2}')
|
80
83
|
end
|
81
84
|
end
|
82
85
|
end
|
83
86
|
|
84
87
|
describe Danica::Function do
|
85
|
-
subject { described_class.build(:x, :y, :z) { z*(x
|
88
|
+
subject { described_class.build(:x, :y, :z) { z * (x**y) }.new(y: 3, z: Danica::PI) }
|
89
|
+
|
86
90
|
describe '#to_tex' do
|
87
91
|
it do
|
88
92
|
expect(subject.to_tex).to eq('f(x, 3) = \pi \cdot x^{3}')
|