Sha256: 79d869a77bb7de9a97c4e4c302ed4b6fadeca57d7c203e26145efcde01877a6b

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

Stored size: 960 Bytes

Contents

$LOAD_PATH << "../../.." unless $LOAD_PATH.include?("../../..")
require 'test/unit'
require 'langscan/javascript'

class TestJavaScript < Test::Unit::TestCase
  def assert_yield_any(recv, meth, *args)
    success = false
    recv.__send__(meth, *args) {|*block_args|
      if yield(*block_args)
        assert(true)
        success = true
        break
      end
    }
    assert(false, "no expected yields") unless success
  end

  def assert_yield_all(recv, meth, *args)
    recv.__send__(meth, *args) {|*block_args|
      if !yield(*block_args)
        assert(false, "unexpected yields")
        return
      end
    }
    assert(true)
  end

  def test_funcall
    assert_yield_any(LangScan::JavaScript, :scan, "a()") {|f|
      f.type == :funcall && f.text == 'a'
    }
  end

  def test_fundef
    assert_yield_any(LangScan::JavaScript, :scan, "a(){}") {|f|
      f.type == :fundef && f.text == 'a'
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
langscan-1.2-x86-mswin32-60 test/langscan/javascript/test/test_javascript.rb
langscan-1.2 test/langscan/javascript/test/test_javascript.rb