mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use Array#permutation for permutation tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
070cbd942e
commit
b32bae3fbb
1 changed files with 14 additions and 21 deletions
|
@ -94,30 +94,23 @@ class TC_JSON < Test::Unit::TestCase
|
||||||
assert_equal({ "a" => 0.23 }, parse(' { "a" : 0.23 } '))
|
assert_equal({ "a" => 0.23 }, parse(' { "a" : 0.23 } '))
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
def test_parse_more_complex_arrays
|
||||||
require 'permutation'
|
a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
|
||||||
def test_parse_more_complex_arrays
|
a.permutation.each do |perm|
|
||||||
a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
|
orig_ary = a
|
||||||
perms = Permutation.for a
|
json = pretty_generate(orig_ary)
|
||||||
perms.each do |perm|
|
assert_equal orig_ary, parse(json)
|
||||||
orig_ary = perm.project
|
|
||||||
json = pretty_generate(orig_ary)
|
|
||||||
assert_equal orig_ary, parse(json)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_parse_complex_objects
|
def test_parse_complex_objects
|
||||||
a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
|
a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
|
||||||
perms = Permutation.for a
|
a.permutation.each do |perm|
|
||||||
perms.each do |perm|
|
s = "a"
|
||||||
s = "a"
|
orig_obj = a.inject({}) { |h, x| h[s.dup] = x; s = s.succ; h }
|
||||||
orig_obj = perm.project.inject({}) { |h, x| h[s.dup] = x; s = s.succ; h }
|
json = pretty_generate(orig_obj)
|
||||||
json = pretty_generate(orig_obj)
|
assert_equal orig_obj, parse(json)
|
||||||
assert_equal orig_obj, parse(json)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
rescue LoadError
|
|
||||||
warn "Skipping permutation tests."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_arrays
|
def test_parse_arrays
|
||||||
|
|
Loading…
Reference in a new issue