Sha256: d35d699bf59902b8c94cf793b2f1878d34b7869d642a42160c0984083c265808

Contents?: true

Size: 891 Bytes

Versions: 374

Compression:

Stored size: 891 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'test/unit'
case ENV['JSON']
when 'pure' then require 'json/pure'
when 'ext'  then require 'json/ext'
else             require 'json'
end

class TC_JSONFixtures < Test::Unit::TestCase
  def setup
    fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json')
    passed, failed = Dir[fixtures].partition { |f| f['pass'] }
    @passed = passed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
    @failed = failed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
  end

  def test_passing
    for name, source in @passed
      assert JSON.parse(source),
        "Did not pass for fixture '#{name}'"
    end
  end

  def test_failing
    for name, source in @failed
      assert_raises(JSON::ParserError, JSON::NestingError,
        "Did not fail for fixture '#{name}'") do
        JSON.parse(source)
      end
    end
  end
end

Version data entries

374 entries across 336 versions & 17 rubygems

Version Path
edward-crazy_ivan-0.2.0 vendor/json-1.1.7/tests/test_json_fixtures.rb
edward-crazy_ivan-0.2.1 vendor/json-1.1.7/tests/test_json_fixtures.rb
edward-crazy_ivan-0.2.2 vendor/json-1.1.7/tests/test_json_fixtures.rb
edward-crazy_ivan-0.3.0 vendor/json-1.1.7/tests/test_json_fixtures.rb
edward-crazy_ivan-0.3.1 vendor/json-1.1.7/tests/test_json_fixtures.rb
depengine-0.0.31 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.31 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.26 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.25 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb
depengine-0.0.24 etc/isolate/jruby-1.8/gems/json_pure-1.4.3/tests/test_json_fixtures.rb