Sha256: 4b9d0f6371f815c55e7716ff7094d62e68cb3fe607ad06847e501b6fc7dc2ece
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asciimath-2.0.4 | spec/customisation_spec.rb |