Sha256: cd16b3091493795cbac3a33d504e1d4a76e8215181e29b3c0061d0abf8b5f4cf

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

require 'spec_helper'

describe "For commenting, the language" do
  
  include Trxl::SpecHelper
  
  before :each do
    @parser = Trxl::Calculator.new
  end
  
  it "should allow single line comments" do
    eval("# This is only a comment").should be_nil
    eval("# This is only a comment\n").should be_nil
    eval("# This is only a comment a = 5; a;").should be_nil
    eval("a = 5 # This is only a comment").should == 5
    eval("a = 5 # This is only a comment\n").should == 5
    eval("a = 5; # This is only a comment").should == 5
    eval("a = 5; # This is only a comment\n").should == 5
  end

  it "should allow multi line comments" do
    eval("/* This is a multiline comment */ a = 5; a;").should == 5
    eval("a = 5; /* This is a multiline comment */ a;").should == 5

    program = <<-PROGRAM
      a = 1;
      /*
       * This is a multiline comment
       */
      a * 2;
    PROGRAM
    eval(program).should == 2
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trxl-0.1.11 spec/trxl/comments_spec.rb
trxl-0.1.10 spec/trxl/comments_spec.rb
trxl-0.1.9 spec/trxl/comments_spec.rb
trxl-0.1.8 spec/trxl/comments_spec.rb
trxl-0.1.5 spec/trxl/comments_spec.rb