diff options
author | Florian Frank <flori@ping.de> | 2012-02-11 17:28:21 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2012-02-11 20:44:36 +0100 |
commit | dad9fbfbfbfcfe743563348f2c17aedecfabe803 (patch) | |
tree | e599ec933cdb88131ba8feb9ca8fb358215fbb77 /tests | |
parent | 5dcf0f9ecd09888245f3d0a64967989ed7a1e775 (diff) | |
download | json-dad9fbfbfbfcfe743563348f2c17aedecfabe803.tar.gz |
Clean up code a bit
This should fix #117
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_json.rb | 6 | ||||
-rwxr-xr-x | tests/test_json_generate.rb | 34 |
2 files changed, 21 insertions, 19 deletions
diff --git a/tests/test_json.rb b/tests/test_json.rb index c06fd19..1b39360 100755 --- a/tests/test_json.rb +++ b/tests/test_json.rb @@ -314,7 +314,7 @@ class TC_JSON < Test::Unit::TestCase assert res.item_set? end - def test_generation_of_core_subclasses_with_new_to_json + def test_generate_core_subclasses_with_new_to_json obj = SubHash2["foo" => SubHash2["bar" => true]] obj_json = JSON(obj) obj_again = JSON(obj_json) @@ -325,12 +325,12 @@ class TC_JSON < Test::Unit::TestCase assert_equal ["foo"], JSON(JSON(SubArray2["foo"])) end - def test_generation_of_core_subclasses_with_default_to_json + def test_generate_core_subclasses_with_default_to_json assert_equal '{"foo":"bar"}', JSON(SubHash["foo" => "bar"]) assert_equal '["foo"]', JSON(SubArray["foo"]) end - def test_generation_of_core_subclasses + def test_generate_of_core_subclasses obj = SubHash["foo" => SubHash["bar" => true]] obj_json = JSON(obj) obj_again = JSON(obj_json) diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb index b363de1..3a1ddc6 100755 --- a/tests/test_json_generate.rb +++ b/tests/test_json_generate.rb @@ -227,23 +227,25 @@ EOT GC.stress = stress end if GC.respond_to?(:stress=) - def test_broken_bignum # [ruby-core:38867] - pid = fork do - Bignum.class_eval do - def to_s + if defined?(JSON::Ext::Generator) + def test_broken_bignum # [ruby-core:38867] + pid = fork do + Bignum.class_eval do + def to_s + end + end + begin + JSON::Ext::Generator::State.new.generate(1<<64) + exit 1 + rescue TypeError + exit 0 end end - begin - JSON::Ext::Generator::State.new.generate(1<<64) - exit 1 - rescue TypeError - exit 0 - end + _, status = Process.waitpid2(pid) + assert status.success? + rescue NotImplementedError + # forking to avoid modifying core class of a parent process and + # introducing race conditions of tests are run in parallel end - _, status = Process.waitpid2(pid) - assert status.success? - rescue NotImplementedError - # forking to avoid modifying core class of a parent process and - # introducing race conditions of tests are run in parallel - end if defined?(JSON::Ext) + end end |