Sha256: 914c4ce194df2dd283a84ec46f8bad35151f16d749251387d0290664d202edeb

Contents?: true

Size: 699 Bytes

Versions: 6

Compression:

Stored size: 699 Bytes

Contents

require 'minitest_helper'

class TestTokens < MiniTest::Unit::TestCase
  include Qlang::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

6 entries across 6 versions & 1 rubygems

Version Path
qlang-0.0.27182123 test/internal/test_tokens.rb
qlang-0.0.27182122 test/internal/test_tokens.rb
qlang-0.0.27182121 test/internal/test_tokens.rb
qlang-0.0.27182120 test/internal/test_tokens.rb
qlang-0.0.27182110 test/internal/test_tokens.rb
qlang-0.0.27182100 test/internal/test_tokens.rb