Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a test helper superclass

  • Loading branch information...
commit 47c4176ce9a349bac0417ebada7690babf79b2a5 1 parent a19b965
@tenderlove authored
Showing with 132 additions and 142 deletions.
  1. +2 −2 Manifest.txt
  2. +11 −0 test/psych/helper.rb
  3. +2 −4 test/psych/test_alias_and_anchor.rb
  4. +3 −3 test/psych/test_array.rb
  5. +2 −3 test/psych/test_boolean.rb
  6. +2 −3 test/psych/test_class.rb
  7. +2 −3 test/psych/test_coder.rb
  8. +3 −3 test/psych/test_document.rb
  9. +3 −4 test/psych/test_emitter.rb
  10. +2 −3 test/psych/test_encoding.rb
  11. +3 −3 test/psych/test_exception.rb
  12. +3 −3 test/psych/test_hash.rb
  13. +2 −3 test/psych/test_json_tree.rb
  14. +2 −3 test/psych/test_null.rb
  15. +2 −3 test/psych/test_object.rb
  16. +2 −3 test/psych/test_omap.rb
  17. +2 −4 test/psych/test_parser.rb
  18. +2 −4 test/psych/test_psych.rb
  19. +2 −3 test/psych/test_scalar.rb
  20. +54 −52 test/psych/test_scalar_scanner.rb
  21. +2 −3 test/psych/test_serialize_subclasses.rb
  22. +3 −3 test/psych/test_set.rb
  23. +2 −3 test/psych/test_string.rb
  24. +2 −3 test/psych/test_struct.rb
  25. +2 −3 test/psych/test_symbol.rb
  26. +1 −2  test/psych/test_to_yaml_properties.rb
  27. +3 −3 test/psych/test_tree_builder.rb
  28. +2 −3 test/psych/test_yaml.rb
  29. +3 −3 test/psych/visitors/test_emitter.rb
  30. +3 −4 test/psych/visitors/test_to_ruby.rb
  31. +3 −3 test/psych/visitors/test_yaml_tree.rb
View
4 Manifest.txt
@@ -17,6 +17,7 @@ ext/psych/yaml_tree.c
ext/psych/yaml_tree.h
lib/psych.rb
lib/psych/coder.rb
+lib/psych/core_ext.rb
lib/psych/emitter.rb
lib/psych/handler.rb
lib/psych/nodes.rb
@@ -29,7 +30,6 @@ lib/psych/nodes/sequence.rb
lib/psych/nodes/stream.rb
lib/psych/omap.rb
lib/psych/parser.rb
-lib/psych/psych.bundle
lib/psych/scalar_scanner.rb
lib/psych/set.rb
lib/psych/tree_builder.rb
@@ -39,7 +39,7 @@ lib/psych/visitors/json_tree.rb
lib/psych/visitors/to_ruby.rb
lib/psych/visitors/visitor.rb
lib/psych/visitors/yaml_tree.rb
-lib/psych/yaml.rb
+test/psych/helper.rb
test/psych/test_alias_and_anchor.rb
test/psych/test_array.rb
test/psych/test_boolean.rb
View
11 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
View
6 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
---
View
6 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
View
5 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}")
View
5 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
View
5 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
View
6 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:
View
7 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
View
5 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
View
6 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 @@ def initialize *args
end
def setup
+ super
@wups = Wups.new
end
View
6 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
View
5 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
View
5 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)
---
View
5 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 @@ def initialize
end
end
- class TestObject < MiniTest::Unit::TestCase
+ class TestObject < TestCase
def test_dump_with_tag
tag = Tagged.new
assert_match('foo', Psych.dump(tag))
View
5 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'
View
6 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 @@ def #{m} *args
def setup
super
- warn "#{name}" if ENV['TESTOPTS'] == '-v'
@parser = Psych::Parser.new EventCatcher.new
end
View
6 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)
View
5 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
View
106 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
View
5 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
View
6 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'
View
5 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
View
5 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 @@ def initialize *args
end
module Psych
- class TestStruct < MiniTest::Unit::TestCase
+ class TestStruct < TestCase
class StructSubclass < Struct.new(:foo)
def initialize foo, bar
super(foo)
View
5 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
View
3  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
View
6 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
View
5 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
View
6 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
View
7 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
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.