Sha256: fee9b76cf63b9798db371cca2aae73bf6933a0af43022afce10e38ee2877ad24
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
describe Gobstones::Parser, "procedure definitions" do let(:body) { CmdBlock.empty } it "should parse an empty procedure def without args" do args = VarTuple.new [] proc_def = Procedure.new 'MyProc', args, body expect('procedure MyProc() {}'). to be_parsed_as(:definition).and_return(proc_def) end it "should parse an empty procedure with some args" do first_arg = VarName.new 'firstArg' second_arg = VarName.new 'secondArg' third_arg = VarName.new 'thirdArg' args = VarTuple.new [first_arg, second_arg, third_arg] proc_def = Procedure.new 'MyProc', args, body expect('procedure MyProc (firstArg, secondArg, thirdArg) {}'). to be_parsed_as(:definition).and_return(proc_def) end it "should parse a procedure with some statements" do args = VarTuple.new [VarName.new('arg')] body = CmdBlock.new [Poner.new(Verde.new)] proc_def = Procedure.new 'MyProc', args, body expect('procedure MyProc(arg) { Poner(Verde) }').to be_parsed_as(:definition).and_return(proc_def) end it "should not parse a procedure without a valid identifier" do expect('procedure myWrongProc() {}').to be_parsed_as(:definition).and_fail end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gobstones-0.0.1.1 | spec/parser/procedure_definitions_spec.rb |