Sha256: d27d3c3b6338526e8c3ebd3d133b4f1da43c7576565a6adbbc26d1809e0a0c42
Contents?: true
Size: 683 Bytes
Versions: 14
Compression:
Stored size: 683 Bytes
Contents
require 'dentaku/token_scanner' describe Dentaku::TokenScanner do let(:whitespace) { described_class.new(:whitespace, '\s') } let(:numeric) { described_class.new(:numeric, '(\d+(\.\d+)?|\.\d+)', lambda{|raw| raw =~ /\./ ? raw.to_f : raw.to_i }) } it 'should return a token for a matching string' do token = whitespace.scan(' ') token.category.should eq(:whitespace) token.value.should eq(' ') end it 'should return falsy for a non-matching string' do whitespace.scan('A').should_not be end it 'should perform raw value conversion' do token = numeric.scan('5') token.category.should eq(:numeric) token.value.should eq(5) end end
Version data entries
14 entries across 14 versions & 1 rubygems