Sha256: c976fac39ec2e739905886212ce77f5bb02588c75d51b50c8fa56ffbd4d2fdbe
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
#encoding: utf-8 require 'rspec' require 'asciimath' require_relative 'ast' RSpec.configure do |c| c.include ::AsciiMath::ASTHelper end describe 'AsciiMath::Parser', :variant => :ast do it "should support custom symbols" do my_tokens_table = AsciiMath::SymbolTableBuilder.new AsciiMath::Parser.add_default_parser_symbols(my_tokens_table) my_tokens_table.add('mysymbol', :mysymbol, :symbol) parsed = AsciiMath::parse("a + mysymbol + b", my_tokens_table.build) expect(parsed.ast).to eq(seq(identifier('a'), symbol('+'), ::AsciiMath::AST::Symbol.new(:mysymbol, 'mysymbol', :symbol), symbol('+'), identifier('b'))) end it "should support replacing standard symbols" do my_tokens_table = AsciiMath::SymbolTableBuilder.new AsciiMath::Parser.add_default_parser_symbols(my_tokens_table) my_tokens_table.add('+', :foo, :symbol) parsed = AsciiMath::parse("a + b", my_tokens_table.build) expect(parsed.ast).to eq(seq(identifier('a'), ::AsciiMath::AST::Symbol.new(:foo, '+', :symbol), identifier('b'))) end it "should support disallowing symbol overwrites" do my_tokens_table = AsciiMath::SymbolTableBuilder.new(allow_symbol_overwrites: false) AsciiMath::Parser.add_default_parser_symbols(my_tokens_table) expect{my_tokens_table.add('+', :foo, :symbol)}.to raise_error 'Symbol overwrites are disallowed, but were attempted for +' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asciimath-2.0.5 | spec/customisation_spec.rb |