Sha256: 4f8bfb4cbce0ac482de4278395062a7fdb2fe6c78f1956be12dc8c246df4b9de
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
#!/usr/bin/ruby # Jonathan D. Stott <jonathan.stott@gmail.com> require 'spec_helper' require 'exalted_math' include Exalted describe "Exalted::MathParser" do before do @parser = Exalted::MathsParser.new end [ ['4', Ast.num(4)], ['-1', Ast.num(-1)], ['3 * 4', Ast.mul(Ast.num(3), Ast.num(4) )], ['3 - 4', Ast.sub(Ast.num(3), Ast.num(4) )], ['3 + 4', Ast.add(Ast.num(3), Ast.num(4) )], ['6 / 3', Ast.div(Ast.num(6), Ast.num(3) )], ['Essence * 4', Ast.mul(Ast.stat('essence'), Ast.num(4) )], ['(Essence * 4) + Willpower', Ast.add(Ast.mul(Ast.stat('essence'), Ast.num(4) ), Ast.stat('willpower'))], ['highest[2](compassion,conviction,temperance,valor)', Ast.max(2, [Ast.stat('compassion'),Ast.stat('conviction'),Ast.stat('temperance'),Ast.stat('valor') ])], ['min(compassion,conviction,temperance,valor)', Ast.min(1, [Ast.stat('compassion'),Ast.stat('conviction'),Ast.stat('temperance'),Ast.stat('valor') ])] ].each do |string, ast| it "parses '#{string}'" do success, result = @parser.ast(string) success.should.be.true result.should == ast end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exalted_math-0.1.2 | spec/parser_spec.rb |