2 # -*- coding: utf-8 -*-
5 require File.join(File.dirname(__FILE__), 'setup_variant')
7 class TC_JSONFixtures < Test::Unit::TestCase
9 fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json')
10 passed, failed = Dir[fixtures].partition { |f| f['pass'] }
11 @passed = passed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
12 @failed = failed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
16 for name, source in @passed
18 assert JSON.parse(source),
19 "Did not pass for fixture '#{name}': #{source.inspect}"
21 warn "\nCaught #{e.class}(#{e}) for fixture '#{name}': #{source.inspect}\n#{e.backtrace * "\n"}"
28 for name, source in @failed
29 assert_raises(JSON::ParserError, JSON::NestingError,
30 "Did not fail for fixture '#{name}': #{source.inspect}") do