spec/front_end/parser_spec.rb in loxxy-0.0.17 vs spec/front_end/parser_spec.rb in loxxy-0.0.18

- old
+ new

@@ -260,16 +260,16 @@ expect(expr.operands[1].literal.value).to be_falsey end end # context context 'Parsing logical expressions' do - it 'should parse the logical operations betweentwo sub-expression' do + it 'should parse the logical operations between two sub-expression' do %w[or and].each do |connector| input = "5 > 2 #{connector} 3 <= 4;" ptree = subject.parse(input) expr = ptree.root - expect(expr).to be_kind_of(Ast::LoxBinaryExpr) + expect(expr).to be_kind_of(Ast::LoxLogicalExpr) expect(expr.operator).to eq(connector.to_sym) expect(expr.operands[0]).to be_kind_of(Ast::LoxBinaryExpr) expect(expr.operands[0].operator).to eq(:>) expect(expr.operands[0].operands[0].literal.value).to eq(5) expect(expr.operands[0].operands[1].literal.value).to eq(2) @@ -282,12 +282,12 @@ it 'should parse a combinations of logical expressions' do input = '4 > 3 and 1 < 2 or 4 >= 5;' ptree = subject.parse(input) expr = ptree.root - expect(expr).to be_kind_of(Ast::LoxBinaryExpr) + expect(expr).to be_kind_of(Ast::LoxLogicalExpr) expect(expr.operator).to eq(:or) # or has lower precedence than and - expect(expr.operands[0]).to be_kind_of(Ast::LoxBinaryExpr) + expect(expr.operands[0]).to be_kind_of(Ast::LoxLogicalExpr) expect(expr.operands[0].operator).to eq(:and) conjuncts = expr.operands[0].operands expect(conjuncts[0]).to be_kind_of(Ast::LoxBinaryExpr) expect(conjuncts[0].operator).to eq(:>) expect(conjuncts[0].operands[0].literal.value).to eq(4)