Sha256: 2fea29ef6a9b884363f167dd7250cd7f0015d9f7c6d40584463654075b192dd3

Contents?: true

Size: 700 Bytes

Versions: 9

Compression:

Stored size: 700 Bytes

Contents

require 'minitest_helper'

class TestTokens < MiniTest::Unit::TestCase
  include Hilbert::Lexer::Tokens
  def setup
  end

  def full_match(rgx, str)
    assert_equal(0, rgx =~ str)
    assert_equal(str, $&)
  end

  def not_match(rgx, str)
    assert_equal(nil, rgx =~ str)
  end

  def test_nums
    full_match(NUM, '1')
    full_match(NUM, '234987423')
    full_match(NUM, '23423948.298743')
    full_match(NUM, 'e')
    full_match(NUM, 'pi')
    not_match(NUM, 'a')
  end

  def test_function
    full_match(/[fgh]\(\w( ?, ?\w)*\) ?= ?[^\r\n]+/, 'f(x) = xy')
  end

  def test_differentiate
    rgx = /d\/d[a-zA-Z] .*/
    full_match(rgx, 'd/dx sin(x)')
    full_match(rgx, 'd/dz z^2')
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hilbert-0.0.2700420 test/internal/test_tokens.rb
hilbert-0.0.2700410 test/internal/test_tokens.rb
hilbert-0.0.2700400 test/internal/test_tokens.rb
hilbert-0.0.2700320 test/internal/test_tokens.rb
hilbert-0.0.2700300 test/internal/test_tokens.rb
hilbert-0.0.2700210 test/internal/test_tokens.rb
hilbert-0.0.2700110 test/internal/test_tokens.rb
hilbert-0.0.2700100 test/internal/test_tokens.rb
hilbert-0.0.2700001 test/internal/test_tokens.rb