spec/iq_spec.rb in qlang-0.0.14142135 vs spec/iq_spec.rb in qlang-0.0.27000000

- old
+ new

@@ -13,19 +13,56 @@ expect(Iq.execute(input)).to eq(output) reset end end + describe 'General' do + cal_test('ex1', '2x', '2x') + cal_test('ex2', 'x + x', '2x') + cal_test('ex3', 'x * y', 'xy') + end + describe 'Matrix' do - it do - expect(Iq.execute('(1 2 3; 4 5 6)')).to eq('(1 2 3; 4 5 6)') - expect(Iq.execute('(1 2 3; 4 5 6) + (1 2 3; 4 5 6)')).to eq('(2 4 6; 8 10 12)') - expect(Iq.execute('(1 2 3; 4 5 6) - (2 4 1; 8 3 9)')).to eq('(-1 -2 2; -4 2 -3)') - expect(Iq.execute('(1 2; 3 4) * (1 2; 3 4)')).to eq('(7 10; 15 22)') - expect(Iq.execute('(1 2; 3 4) ** 2')).to eq('(7 10; 15 22)') - expect(Iq.execute('(1 2; 3 4) * (1 2)')).to eq('(5 11)') - end + cal_test('ex1', + '(1 2 3; 4 5 6)', + '(1 2 3; 4 5 6)' + ) + + cal_test('ex2', + '(1 2 3; 4 5 6) + (1 2 3; 4 5 6)', + '(2 4 6; 8 10 12)' + ) + + cal_test('ex3', + '(1 2 3; 4 5 6) - (2 4 1; 8 3 9)', + '(-1 -2 2; -4 2 -3)' + ) + + cal_test('ex4', + '(1 2; 3 4) * (1 2; 3 4)', + '(7 10; 15 22)' + ) + + cal_test('ex5', + '(1 2; 3 4) ** 2', + '(7 10; 15 22)' + ) + + cal_test('ex6', + '(1 2; 3 4) ** 2', + '(7 10; 15 22)' + ) + + cal_test('ex7', + '(1 2; 3 4) * (1 2)', + '(5 11)' + ) + + cal_test('ex8', + '(1 2 3; 4 5 6)t', + '(1 4; 2 5; 3 6)' + ) end describe 'Vector' do it do expect(Iq.execute('(1 2 3)')).to eq('(1 2 3)') @@ -65,10 +102,10 @@ describe 'Function' do def_test('ex1', 'f(x, y) = x + y', 'x + y') cal_test('ex1', 'f( 4, 5 )', '9.0') - def_test('ex2', 'f(x, y) = xy', 'x * y') + def_test('ex2', 'f( x , y) = xy', 'x * y') cal_test('ex2', 'f( 3, 9 )', '27.0') def_test('ex3', 'f(x, y) = xy^2', 'x * ( y ** 2 )') cal_test('ex3', 'f( 3, 2 )', '12.0')