77# [ruby-core:01946]
88module Psych_Tests
99 StructTest = Struct ::new ( :c )
10- DataTest = Data . define ( :c )
10+ DataTest = Data . define ( :c ) if defined? ( :: Data )
1111end
1212
1313class Psych_Unit_Tests < Psych ::TestCase
@@ -1067,16 +1067,17 @@ def test_ruby_struct
10671067
10681068 end
10691069
1070- def test_ruby_data
1071- Object . remove_const :MyBookData if Object . const_defined? ( :MyBookData )
1072- # Ruby Data value objects
1073- book_class = Data . define ( :author , :title , :year , :isbn )
1074- Object . const_set ( :MyBookData , book_class )
1075- assert_to_yaml (
1076- [ book_class . new ( "Yukihiro Matsumoto" , "Ruby in a Nutshell" , 2002 , "0-596-00214-9" ) ,
1077- book_class . new ( [ 'Dave Thomas' , 'Andy Hunt' ] , "The Pickaxe" , 2002 ,
1078- book_class . new ( "This should be the ISBN" , "but I have more data here" , 2002 , "None" )
1079- ) ] , <<EOY
1070+ if defined? ( ::Data )
1071+ def test_ruby_data
1072+ Object . remove_const :MyBookData if Object . const_defined? ( :MyBookData )
1073+ # Ruby Data value objects
1074+ book_class = Data . define ( :author , :title , :year , :isbn )
1075+ Object . const_set ( :MyBookData , book_class )
1076+ assert_to_yaml (
1077+ [ book_class . new ( "Yukihiro Matsumoto" , "Ruby in a Nutshell" , 2002 , "0-596-00214-9" ) ,
1078+ book_class . new ( [ 'Dave Thomas' , 'Andy Hunt' ] , "The Pickaxe" , 2002 ,
1079+ book_class . new ( "This should be the ISBN" , "but I have more data here" , 2002 , "None" )
1080+ ) ] , <<EOY
10801081- !ruby/data:MyBookData
10811082 author: Yukihiro Matsumoto
10821083 title: Ruby in a Nutshell
@@ -1094,13 +1095,14 @@ def test_ruby_data
10941095 year: 2002
10951096 isbn: None
10961097EOY
1097- )
1098+ )
10981099
1099- assert_to_yaml ( Psych_Tests ::DataTest . new ( 123 ) , <<EOY )
1100+ assert_to_yaml ( Psych_Tests ::DataTest . new ( 123 ) , <<EOY )
11001101--- !ruby/data:Psych_Tests::DataTest
11011102c: 123
11021103EOY
11031104
1105+ end
11041106 end
11051107
11061108 def test_ruby_rational
0 commit comments