2020 expect ( node . value ) . to eq ( 11 )
2121 end
2222
23- it 'requires numeric operands' do
23+ it 'requires operands that respond to + ' do
2424 expect {
25- described_class . new ( five , t )
26- } . to raise_error ( Dentaku ::NodeError , /requires numeric operands/ )
25+ described_class . new ( five , t ) . value
26+ } . to raise_error ( Dentaku ::ArgumentError , /requires operands that respond to + / )
2727
2828 expression = Dentaku ::AST ::Multiplication . new ( five , five )
2929 group = Dentaku ::AST ::Grouping . new ( expression )
3030
3131 expect {
32- described_class . new ( group , five )
32+ described_class . new ( group , five ) . value
3333 } . not_to raise_error
3434 end
3535
3636 it 'allows operands that respond to addition' do
3737 # Sample struct that has a custom definition for addition
38-
3938 Addable = Struct . new ( :value ) do
4039 def +( other )
4140 case other
@@ -51,12 +50,18 @@ def +(other)
5150 operand_six = Dentaku ::AST ::Numeric . new Dentaku ::Token . new ( :numeric , Addable . new ( 6 ) )
5251
5352 expect {
54- described_class . new ( operand_five , operand_six )
53+ described_class . new ( operand_five , operand_six ) . value
5554 } . not_to raise_error
5655
5756 expect {
58- described_class . new ( operand_five , six )
57+ described_class . new ( operand_five , six ) . value
5958 } . not_to raise_error
59+ end
60+
61+ it 'does not try to parse nested string as date' do
62+ a = [ '2017-01-01' , '2017-01-02' ]
63+ b = [ '2017-01-01' ]
6064
65+ expect ( Dentaku ( 'a + b' , a : a , b : b ) ) . to eq ( [ '2017-01-01' , '2017-01-02' , '2017-01-01' ] )
6166 end
6267end
0 commit comments