summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-03-26 23:28:42 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-03-26 23:28:42 -0700
commit47c4176ce9a349bac0417ebada7690babf79b2a5 (patch)
treef002b4c26ed61007ca1a54b965358ea4aeb5b661 /test
parenta19b96529c9bce6f1fade726e6613f549f22dfad (diff)
downloadpsych-47c4176ce9a349bac0417ebada7690babf79b2a5.zip
adding a test helper superclass
Diffstat (limited to 'test')
-rw-r--r--test/psych/helper.rb11
-rw-r--r--test/psych/test_alias_and_anchor.rb6
-rw-r--r--test/psych/test_array.rb6
-rw-r--r--test/psych/test_boolean.rb5
-rw-r--r--test/psych/test_class.rb5
-rw-r--r--test/psych/test_coder.rb5
-rw-r--r--test/psych/test_document.rb6
-rw-r--r--test/psych/test_emitter.rb7
-rw-r--r--test/psych/test_encoding.rb5
-rw-r--r--test/psych/test_exception.rb6
-rw-r--r--test/psych/test_hash.rb6
-rw-r--r--test/psych/test_json_tree.rb5
-rw-r--r--test/psych/test_null.rb5
-rw-r--r--test/psych/test_object.rb5
-rw-r--r--test/psych/test_omap.rb5
-rw-r--r--test/psych/test_parser.rb6
-rw-r--r--test/psych/test_psych.rb6
-rw-r--r--test/psych/test_scalar.rb5
-rw-r--r--test/psych/test_scalar_scanner.rb106
-rw-r--r--test/psych/test_serialize_subclasses.rb5
-rw-r--r--test/psych/test_set.rb6
-rw-r--r--test/psych/test_string.rb5
-rw-r--r--test/psych/test_struct.rb5
-rw-r--r--test/psych/test_symbol.rb5
-rw-r--r--test/psych/test_to_yaml_properties.rb3
-rw-r--r--test/psych/test_tree_builder.rb6
-rw-r--r--test/psych/test_yaml.rb5
-rw-r--r--test/psych/visitors/test_emitter.rb6
-rw-r--r--test/psych/visitors/test_to_ruby.rb7
-rw-r--r--test/psych/visitors/test_yaml_tree.rb6
30 files changed, 130 insertions, 140 deletions
diff --git a/test/psych/helper.rb b/test/psych/helper.rb
new file mode 100644
index 0000000..184fac1
--- /dev/null
+++ b/test/psych/helper.rb
@@ -0,0 +1,11 @@
+require 'psych'
+require 'minitest/autorun'
+require 'stringio'
+require 'tempfile'
+require 'date'
+
+module Psych
+ class TestCase < MiniTest::Unit::TestCase
+ # Yes... blank for now. But we will use this.
+ end
+end
diff --git a/test/psych/test_alias_and_anchor.rb b/test/psych/test_alias_and_anchor.rb
index 51b048f..74660a4 100644
--- a/test/psych/test_alias_and_anchor.rb
+++ b/test/psych/test_alias_and_anchor.rb
@@ -1,9 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestAliasAndAnchor < MiniTest::Unit::TestCase
-
+ class TestAliasAndAnchor < TestCase
def test_mri_compatibility
yaml = <<EOYAML
---
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb
index ab83270..0158f20 100644
--- a/test/psych/test_array.rb
+++ b/test/psych/test_array.rb
@@ -1,9 +1,9 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestArray < MiniTest::Unit::TestCase
+ class TestArray < TestCase
def setup
+ super
@list = [{ :a => 'b' }, 'foo']
end
diff --git a/test/psych/test_boolean.rb b/test/psych/test_boolean.rb
index 020b603..09f780b 100644
--- a/test/psych/test_boolean.rb
+++ b/test/psych/test_boolean.rb
@@ -1,11 +1,10 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
###
# Test booleans from YAML spec:
# http://yaml.org/type/bool.html
- class TestBoolean < MiniTest::Unit::TestCase
+ class TestBoolean < TestCase
%w{ yes Yes YES true True TRUE on On ON }.each do |truth|
define_method(:"test_#{truth}") do
assert_equal true, Psych.load("--- #{truth}")
diff --git a/test/psych/test_class.rb b/test/psych/test_class.rb
index cfa5d40..48000da 100644
--- a/test/psych/test_class.rb
+++ b/test/psych/test_class.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestClass < MiniTest::Unit::TestCase
+ class TestClass < TestCase
def test_to_yaml
assert_raises(::TypeError) do
TestClass.to_yaml
diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb
index eccf5ee..ba00809 100644
--- a/test/psych/test_coder.rb
+++ b/test/psych/test_coder.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestCoder < MiniTest::Unit::TestCase
+ class TestCoder < TestCase
class InitApi
attr_accessor :implicit
attr_accessor :style
diff --git a/test/psych/test_document.rb b/test/psych/test_document.rb
index 529e3ff..e5ef00c 100644
--- a/test/psych/test_document.rb
+++ b/test/psych/test_document.rb
@@ -1,9 +1,9 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestDocument < MiniTest::Unit::TestCase
+ class TestDocument < TestCase
def setup
+ super
@stream = Psych.parse_stream(<<-eoyml)
%YAML 1.1
%TAG ! tag:tenderlovemaking.com,2009:
diff --git a/test/psych/test_emitter.rb b/test/psych/test_emitter.rb
index f4cf6b9..bb24e52 100644
--- a/test/psych/test_emitter.rb
+++ b/test/psych/test_emitter.rb
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
-require 'minitest/autorun'
-require 'psych'
-require 'stringio'
+require 'test/psych/helper'
module Psych
- class TestEmitter < MiniTest::Unit::TestCase
+ class TestEmitter < TestCase
def setup
+ super
@out = StringIO.new
@emitter = Psych::Emitter.new @out
end
diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb
index 584932c..4690621 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestEncoding < MiniTest::Unit::TestCase
+ class TestEncoding < TestCase
class EncodingCatcher < Handler
attr_reader :strings
def initialize
diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb
index b4d821e..efc5747 100644
--- a/test/psych/test_exception.rb
+++ b/test/psych/test_exception.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestException < MiniTest::Unit::TestCase
+ class TestException < TestCase
class Wups < Exception
attr_reader :foo, :bar
def initialize *args
@@ -13,6 +12,7 @@ module Psych
end
def setup
+ super
@wups = Wups.new
end
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index 76bf595..7b6cb82 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -1,9 +1,9 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestHash < MiniTest::Unit::TestCase
+ class TestHash < TestCase
def setup
+ super
@hash = { :a => 'b' }
end
diff --git a/test/psych/test_json_tree.rb b/test/psych/test_json_tree.rb
index d839d81..a032f1e 100644
--- a/test/psych/test_json_tree.rb
+++ b/test/psych/test_json_tree.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestJSONTree < MiniTest::Unit::TestCase
+ class TestJSONTree < TestCase
def test_string
assert_match(/(['"])foo\1/, Psych.to_json("foo"))
end
diff --git a/test/psych/test_null.rb b/test/psych/test_null.rb
index 261c2b9..ca78aa9 100644
--- a/test/psych/test_null.rb
+++ b/test/psych/test_null.rb
@@ -1,11 +1,10 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
###
# Test null from YAML spec:
# http://yaml.org/type/null.html
- class TestNull < MiniTest::Unit::TestCase
+ class TestNull < TestCase
def test_null_list
assert_equal [nil] * 5, Psych.load(<<-eoyml)
---
diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb
index 51f7ab4..fd86c62 100644
--- a/test/psych/test_object.rb
+++ b/test/psych/test_object.rb
@@ -1,5 +1,4 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
class Tagged
@@ -12,7 +11,7 @@ module Psych
end
end
- class TestObject < MiniTest::Unit::TestCase
+ class TestObject < TestCase
def test_dump_with_tag
tag = Tagged.new
assert_match('foo', Psych.dump(tag))
diff --git a/test/psych/test_omap.rb b/test/psych/test_omap.rb
index 3e17901..b9a3c86 100644
--- a/test/psych/test_omap.rb
+++ b/test/psych/test_omap.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestOmap < MiniTest::Unit::TestCase
+ class TestOmap < TestCase
def test_self_referential
map = Psych::Omap.new
map['foo'] = 'bar'
diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb
index 838fbe8..3886994 100644
--- a/test/psych/test_parser.rb
+++ b/test/psych/test_parser.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestParser < MiniTest::Unit::TestCase
+ class TestParser < TestCase
class EventCatcher < Handler
attr_reader :calls
def initialize
@@ -22,7 +21,6 @@ module Psych
def setup
super
- warn "#{name}" if ENV['TESTOPTS'] == '-v'
@parser = Psych::Parser.new EventCatcher.new
end
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index aa12ec7..b07af81 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -1,8 +1,6 @@
-require 'minitest/autorun'
-require 'psych'
-require 'tempfile'
+require 'test/psych/helper'
-class TestPsych < MiniTest::Unit::TestCase
+class TestPsych < Psych::TestCase
def test_dump_stream
things = [22, "foo \n", {}]
stream = Psych.dump_stream(*things)
diff --git a/test/psych/test_scalar.rb b/test/psych/test_scalar.rb
index 033f8b1..d951d70 100644
--- a/test/psych/test_scalar.rb
+++ b/test/psych/test_scalar.rb
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestScalar < MiniTest::Unit::TestCase
+ class TestScalar < TestCase
def test_utf_8
assert_equal "日本語", Psych.load("--- 日本語")
end
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb
index abe33b9..797440b 100644
--- a/test/psych/test_scalar_scanner.rb
+++ b/test/psych/test_scalar_scanner.rb
@@ -1,68 +1,70 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
-class TestScalarScanner < MiniTest::Unit::TestCase
- def test_scan_time
- [ '2001-12-15T02:59:43.1Z',
- '2001-12-14t21:59:43.10-05:00',
- '2001-12-14 21:59:43.10 -5',
- '2010-01-06 00:00:00 -08:00',
- '2001-12-15 2:59:43.10',
- ].each do |time|
- ss = Psych::ScalarScanner.new
- assert_instance_of Time, ss.tokenize(time)
+module Psych
+ class TestScalarScanner < TestCase
+ def test_scan_time
+ [ '2001-12-15T02:59:43.1Z',
+ '2001-12-14t21:59:43.10-05:00',
+ '2001-12-14 21:59:43.10 -5',
+ '2010-01-06 00:00:00 -08:00',
+ '2001-12-15 2:59:43.10',
+ ].each do |time|
+ ss = Psych::ScalarScanner.new
+ assert_instance_of Time, ss.tokenize(time)
+ end
end
- end
- attr_reader :ss
+ attr_reader :ss
- def setup
- @ss = Psych::ScalarScanner.new
- end
+ def setup
+ super
+ @ss = Psych::ScalarScanner.new
+ end
- def test_scan_date
- date = '1980-12-16'
- token = @ss.tokenize date
- assert_equal 1980, token.year
- assert_equal 12, token.month
- assert_equal 16, token.day
- end
+ def test_scan_date
+ date = '1980-12-16'
+ token = @ss.tokenize date
+ assert_equal 1980, token.year
+ assert_equal 12, token.month
+ assert_equal 16, token.day
+ end
- def test_scan_inf
- assert_equal(1 / 0.0, ss.tokenize('.inf'))
- end
+ def test_scan_inf
+ assert_equal(1 / 0.0, ss.tokenize('.inf'))
+ end
- def test_scan_minus_inf
- assert_equal(-1 / 0.0, ss.tokenize('-.inf'))
- end
+ def test_scan_minus_inf
+ assert_equal(-1 / 0.0, ss.tokenize('-.inf'))
+ end
- def test_scan_nan
- assert ss.tokenize('.nan').nan?
- end
+ def test_scan_nan
+ assert ss.tokenize('.nan').nan?
+ end
- def test_scan_null
- assert_equal nil, ss.tokenize('null')
- assert_equal nil, ss.tokenize('~')
- assert_equal nil, ss.tokenize('')
- end
+ def test_scan_null
+ assert_equal nil, ss.tokenize('null')
+ assert_equal nil, ss.tokenize('~')
+ assert_equal nil, ss.tokenize('')
+ end
- def test_scan_symbol
- assert_equal :foo, ss.tokenize(':foo')
- end
+ def test_scan_symbol
+ assert_equal :foo, ss.tokenize(':foo')
+ end
- def test_scan_sexagesimal_float
- assert_equal 685230.15, ss.tokenize('190:20:30.15')
- end
+ def test_scan_sexagesimal_float
+ assert_equal 685230.15, ss.tokenize('190:20:30.15')
+ end
- def test_scan_sexagesimal_int
- assert_equal 685230, ss.tokenize('190:20:30')
- end
+ def test_scan_sexagesimal_int
+ assert_equal 685230, ss.tokenize('190:20:30')
+ end
- def test_scan_float
- assert_equal 1.2, ss.tokenize('1.2')
- end
+ def test_scan_float
+ assert_equal 1.2, ss.tokenize('1.2')
+ end
- def test_scan_true
- assert_equal true, ss.tokenize('true')
+ def test_scan_true
+ assert_equal true, ss.tokenize('true')
+ end
end
end
diff --git a/test/psych/test_serialize_subclasses.rb b/test/psych/test_serialize_subclasses.rb
index 151b61a..e198a66 100644
--- a/test/psych/test_serialize_subclasses.rb
+++ b/test/psych/test_serialize_subclasses.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestSerializeSubclasses < MiniTest::Unit::TestCase
+ class TestSerializeSubclasses < TestCase
class SomeObject
def initialize one, two
@one = one
diff --git a/test/psych/test_set.rb b/test/psych/test_set.rb
index 071eedc..6cff8dd 100644
--- a/test/psych/test_set.rb
+++ b/test/psych/test_set.rb
@@ -1,9 +1,9 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestSet < MiniTest::Unit::TestCase
+ class TestSet < TestCase
def setup
+ super
@set = Psych::Set.new
@set['foo'] = 'bar'
@set['bar'] = 'baz'
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 5e69318..5e4b1ad 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestString < MiniTest::Unit::TestCase
+ class TestString < TestCase
def test_binary_string_null
string = "\x00"
yml = Psych.dump string
diff --git a/test/psych/test_struct.rb b/test/psych/test_struct.rb
index 566851f..44dbab9 100644
--- a/test/psych/test_struct.rb
+++ b/test/psych/test_struct.rb
@@ -1,5 +1,4 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
class PsychStructWithIvar < Struct.new(:foo)
attr_reader :bar
@@ -10,7 +9,7 @@ class PsychStructWithIvar < Struct.new(:foo)
end
module Psych
- class TestStruct < MiniTest::Unit::TestCase
+ class TestStruct < TestCase
class StructSubclass < Struct.new(:foo)
def initialize foo, bar
super(foo)
diff --git a/test/psych/test_symbol.rb b/test/psych/test_symbol.rb
index 9a783be..8f821e4 100644
--- a/test/psych/test_symbol.rb
+++ b/test/psych/test_symbol.rb
@@ -1,8 +1,7 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestSymbol < MiniTest::Unit::TestCase
+ class TestSymbol < TestCase
def test_to_yaml
assert_equal :a, Psych.load(:a.to_yaml)
end
diff --git a/test/psych/test_to_yaml_properties.rb b/test/psych/test_to_yaml_properties.rb
index ff35fcd..84ae1da 100644
--- a/test/psych/test_to_yaml_properties.rb
+++ b/test/psych/test_to_yaml_properties.rb
@@ -1,5 +1,4 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
class TestToYamlProperties < MiniTest::Unit::TestCase
diff --git a/test/psych/test_tree_builder.rb b/test/psych/test_tree_builder.rb
index 3025ef3..f03adc5 100644
--- a/test/psych/test_tree_builder.rb
+++ b/test/psych/test_tree_builder.rb
@@ -1,9 +1,9 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
- class TestTreeBuilder < MiniTest::Unit::TestCase
+ class TestTreeBuilder < TestCase
def setup
+ super
@parser = Psych::Parser.new TreeBuilder.new
@parser.parse(<<-eoyml)
%YAML 1.1
diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb
index 5aac5cb..583cf12 100644
--- a/test/psych/test_yaml.rb
+++ b/test/psych/test_yaml.rb
@@ -2,15 +2,14 @@
# vim:sw=4:ts=4
# $Id$
#
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
# [ruby-core:01946]
module Psych_Tests
StructTest = Struct::new( :c )
end
-class Psych_Unit_Tests < MiniTest::Unit::TestCase
+class Psych_Unit_Tests < Psych::TestCase
#
# Convert between Psych and the object to verify correct parsing and
# emitting
diff --git a/test/psych/visitors/test_emitter.rb b/test/psych/visitors/test_emitter.rb
index f440678..42987d1 100644
--- a/test/psych/visitors/test_emitter.rb
+++ b/test/psych/visitors/test_emitter.rb
@@ -1,10 +1,10 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
module Visitors
- class TestEmitter < MiniTest::Unit::TestCase
+ class TestEmitter < TestCase
def setup
+ super
@io = StringIO.new
@visitor = Visitors::Emitter.new @io
end
diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb
index c793d1d..dc02fbc 100644
--- a/test/psych/visitors/test_to_ruby.rb
+++ b/test/psych/visitors/test_to_ruby.rb
@@ -1,11 +1,10 @@
-require 'minitest/autorun'
-require 'psych'
-require 'date'
+require 'test/psych/helper'
module Psych
module Visitors
- class TestToRuby < MiniTest::Unit::TestCase
+ class TestToRuby < TestCase
def setup
+ super
@visitor = ToRuby.new
end
diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb
index 5768696..2a8c5c0 100644
--- a/test/psych/visitors/test_yaml_tree.rb
+++ b/test/psych/visitors/test_yaml_tree.rb
@@ -1,10 +1,10 @@
-require 'minitest/autorun'
-require 'psych'
+require 'test/psych/helper'
module Psych
module Visitors
- class TestYAMLTree < MiniTest::Unit::TestCase
+ class TestYAMLTree < TestCase
def setup
+ super
@v = Visitors::YAMLTree.new
end