striuct 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.gitignore +35 -34
  2. data/.travis.yml +6 -6
  3. data/Gemfile +12 -12
  4. data/History.rdoc +279 -273
  5. data/LICENSE +21 -21
  6. data/Manifest.txt +91 -90
  7. data/README.ja.old.rdoc +297 -297
  8. data/README.md +128 -128
  9. data/Rakefile +11 -11
  10. data/benchmark/basics.rb +56 -56
  11. data/example/README.rb +44 -44
  12. data/example/example.old.rdoc +187 -187
  13. data/example/example1.rb +233 -233
  14. data/example/example2.rb +22 -22
  15. data/example/see_trace.rb +32 -32
  16. data/lib/striuct/classmethods/README.md +5 -5
  17. data/lib/striuct/classmethods/adjustment.rb +32 -32
  18. data/lib/striuct/classmethods/constructor.rb +63 -63
  19. data/lib/striuct/classmethods/default.rb +27 -27
  20. data/lib/striuct/classmethods/enum.rb +48 -48
  21. data/lib/striuct/classmethods/inner.rb +91 -91
  22. data/lib/striuct/classmethods/length.rb +14 -14
  23. data/lib/striuct/classmethods/macro.rb +144 -144
  24. data/lib/striuct/classmethods/named.rb +113 -113
  25. data/lib/striuct/classmethods/object.rb +54 -54
  26. data/lib/striuct/classmethods/prevent_conflicts.rb +89 -89
  27. data/lib/striuct/classmethods/requiremnets.rb +11 -11
  28. data/lib/striuct/classmethods/to_struct.rb +23 -25
  29. data/lib/striuct/classmethods/validation.rb +55 -55
  30. data/lib/striuct/classmethods.rb +1 -1
  31. data/lib/striuct/instancemethods/README.md +5 -5
  32. data/lib/striuct/instancemethods/assign.rb +30 -30
  33. data/lib/striuct/instancemethods/cast.rb +34 -34
  34. data/lib/striuct/instancemethods/compare.rb +30 -30
  35. data/lib/striuct/instancemethods/default.rb +13 -13
  36. data/lib/striuct/instancemethods/delegate_class_methods.rb +28 -28
  37. data/lib/striuct/instancemethods/enum.rb +103 -103
  38. data/lib/striuct/instancemethods/hashy.rb +121 -121
  39. data/lib/striuct/instancemethods/inner.rb +60 -60
  40. data/lib/striuct/instancemethods/keyvalidatable.rb +14 -14
  41. data/lib/striuct/instancemethods/lock.rb +61 -61
  42. data/lib/striuct/instancemethods/object.rb +52 -52
  43. data/lib/striuct/instancemethods/requirements.rb +14 -14
  44. data/lib/striuct/instancemethods/safety.rb +11 -11
  45. data/lib/striuct/instancemethods/subscript.rb +55 -55
  46. data/lib/striuct/instancemethods/validation.rb +29 -25
  47. data/lib/striuct/instancemethods/values.rb +57 -57
  48. data/lib/striuct/instancemethods.rb +1 -1
  49. data/lib/striuct/requirements.rb +5 -5
  50. data/lib/striuct/singleton_class.rb +66 -66
  51. data/lib/striuct/specificcontainer.rb +19 -19
  52. data/lib/striuct/structs.rb +7 -7
  53. data/lib/striuct/version.rb +5 -5
  54. data/lib/striuct.rb +13 -13
  55. data/striuct.gemspec +24 -24
  56. data/test/helper.rb +5 -5
  57. data/test/test_striuct-singleton_class-define.rb +19 -19
  58. data/test/test_striuct-subclass-class-cloning.rb +20 -20
  59. data/test/test_striuct-subclass-class-close.rb +36 -36
  60. data/test/test_striuct-subclass-class-constructor.rb +82 -82
  61. data/test/test_striuct-subclass-class-freeze.rb +36 -36
  62. data/test/test_striuct-subclass-class-inheritable.rb +57 -57
  63. data/test/test_striuct-subclass-class-macro.rb +13 -13
  64. data/test/test_striuct-subclass-class-safety_naming.rb +72 -72
  65. data/test/test_striuct-subclass-class-validation.rb +26 -26
  66. data/test/test_striuct-subclass-feature-alias_member.rb +53 -53
  67. data/test/test_striuct-subclass-feature-to_struct.rb +61 -25
  68. data/test/test_striuct-subclass-feature-validation_util.rb +57 -0
  69. data/test/test_striuct-subclass-instance-accessor.rb +137 -137
  70. data/test/test_striuct-subclass-instance-adjuster.rb +94 -94
  71. data/test/test_striuct-subclass-instance-assign.rb +30 -30
  72. data/test/test_striuct-subclass-instance-basic.rb +32 -32
  73. data/test/test_striuct-subclass-instance-cloning.rb +22 -22
  74. data/test/test_striuct-subclass-instance-compare.rb +51 -51
  75. data/test/test_striuct-subclass-instance-default_value.rb +128 -128
  76. data/test/test_striuct-subclass-instance-enum.rb +92 -92
  77. data/test/test_striuct-subclass-instance-freeze.rb +19 -19
  78. data/test/test_striuct-subclass-instance-hashlike.rb +153 -153
  79. data/test/test_striuct-subclass-instance-keyvalidatable.rb +24 -24
  80. data/test/test_striuct-subclass-instance-lock.rb +39 -39
  81. data/test/test_striuct-subclass-instance-to_s_family.rb +25 -25
  82. data/test/test_striuct-subclass-instance-validation_functional_condition.rb +50 -50
  83. data/test/test_striuct-subclass-instance-validation_inference.rb +50 -50
  84. data/test/test_striuct-subclass-instance-validation_specific_conditions.rb +247 -247
  85. data/test/test_striuct-subclass-instance-validation_with_getter.rb +33 -33
  86. data/test/test_striuct-subclass-instance_names.rb +18 -18
  87. data/test/test_striuct-version.rb +10 -10
  88. metadata +4 -2
@@ -1,137 +1,137 @@
1
- require_relative 'helper'
2
-
3
- class Test_Striuct_Subclass_Instance_Setter < Test::Unit::TestCase
4
-
5
- class User < Striuct.new
6
- member :id, Integer
7
- member :last_name, /\A\w+\z/
8
- member :family_name, /\A\w+\z/
9
- member :address, /\A((\w+) ?)+\z/
10
- member :age, ->age{(20..140).include? age}
11
- end
12
-
13
- def test_setter
14
- user = User.new
15
- user[:last_name] = 'foo'
16
- assert_equal user.last_name, 'foo'
17
- user.last_name = 'bar'
18
- assert_equal user[:last_name], 'bar'
19
-
20
- assert_raises Validation::InvalidWritingError do
21
- user[:last_name] = 'foo s'
22
- end
23
-
24
- assert_raises Validation::InvalidWritingError do
25
- User.new 'asda'
26
- end
27
-
28
- assert_raises Validation::InvalidWritingError do
29
- user.age = 19
30
- end
31
- end
32
-
33
- end
34
-
35
- class Test_Striuct_Subclass_Instance_Accessor_With_Validation < Test::Unit::TestCase
36
-
37
- class User < Striuct.new
38
- member :id, Integer
39
- member :last_name, /\A\w+\z/
40
- member :family_name, /\A\w+\z/
41
- member :address, /\A((\w+) ?)+\z/
42
- member :age, ->age{(20..140).include? age}
43
- end
44
-
45
- def setup
46
- @user = User.new 9999, 'taro', 'yamada', 'Tokyo Japan', 30
47
- end
48
-
49
- def test_reader
50
- assert_equal @user[1], 'taro'
51
- assert_equal @user[:last_name], 'taro'
52
- assert_equal @user.last_name, 'taro'
53
- end
54
-
55
- def test_setter_pass
56
- assert_equal((@user.id = 2139203509295), 2139203509295)
57
- assert_equal @user.id, 2139203509295
58
- assert_equal((@user.last_name = 'jiro'), 'jiro')
59
- assert_equal @user.last_name, 'jiro'
60
- assert_equal((@user.age = 40), 40)
61
- assert_equal @user.age, 40
62
- end
63
-
64
- def test_setter_fail
65
- assert_raises Validation::InvalidWritingError do
66
- @user.id = 2139203509295.0
67
- end
68
-
69
- assert_raises Validation::InvalidWritingError do
70
- @user.last_name = 'ignore name'
71
- end
72
-
73
- assert_raises Validation::InvalidWritingError do
74
- @user.age = 19
75
- end
76
- end
77
-
78
- def test_strict?
79
- assert_same @user.sufficient?(:last_name), true
80
- assert_same @user.strict?, true
81
- assert_same @user.sufficient?(:last_name), true
82
- @user.last_name.clear
83
- assert_same @user.sufficient?(:last_name), false
84
- assert_same @user.strict?, false
85
- end
86
-
87
- end
88
-
89
-
90
- class Test_Striuct_Subclass_Instance_Accsessor < Test::Unit::TestCase
91
-
92
- class Sth < Striuct.new
93
- member :bool, OR(true, false)
94
- member :sth
95
- protect_level :struct
96
- member :lambda, OR(->v{v % 3 == 2}, ->v{v.kind_of? Float})
97
- end
98
-
99
- def setup
100
- @sth = Sth.new
101
- end
102
-
103
- def test_accessor
104
- @sth.bool = true
105
- assert_same true, @sth.bool
106
- @sth.bool = false
107
- assert_same false, @sth.bool
108
-
109
- assert_raises Validation::InvalidWritingError do
110
- @sth.bool = nil
111
- end
112
-
113
- @sth.sth = 1
114
- assert_same 1, @sth.sth
115
-
116
- @sth.sth = 'String'
117
- assert_equal 'String', @sth.sth
118
-
119
- @sth.sth = Class.class
120
- assert_same Class.class, @sth.sth
121
-
122
- assert_raises Validation::InvalidWritingError do
123
- @sth.lambda = 9
124
- end
125
-
126
- assert_raises Validation::InvalidWritingError do
127
- @sth.lambda = 7
128
- end
129
-
130
- @sth.lambda = 8
131
- assert_same 8, @sth.lambda
132
-
133
- @sth.lambda = 9.0
134
- assert_equal 9.0, @sth.lambda
135
- end
136
-
137
- end
1
+ require_relative 'helper'
2
+
3
+ class Test_Striuct_Subclass_Instance_Setter < Test::Unit::TestCase
4
+
5
+ class User < Striuct.new
6
+ member :id, Integer
7
+ member :last_name, /\A\w+\z/
8
+ member :family_name, /\A\w+\z/
9
+ member :address, /\A((\w+) ?)+\z/
10
+ member :age, ->age{(20..140).include? age}
11
+ end
12
+
13
+ def test_setter
14
+ user = User.new
15
+ user[:last_name] = 'foo'
16
+ assert_equal user.last_name, 'foo'
17
+ user.last_name = 'bar'
18
+ assert_equal user[:last_name], 'bar'
19
+
20
+ assert_raises Validation::InvalidWritingError do
21
+ user[:last_name] = 'foo s'
22
+ end
23
+
24
+ assert_raises Validation::InvalidWritingError do
25
+ User.new 'asda'
26
+ end
27
+
28
+ assert_raises Validation::InvalidWritingError do
29
+ user.age = 19
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ class Test_Striuct_Subclass_Instance_Accessor_With_Validation < Test::Unit::TestCase
36
+
37
+ class User < Striuct.new
38
+ member :id, Integer
39
+ member :last_name, /\A\w+\z/
40
+ member :family_name, /\A\w+\z/
41
+ member :address, /\A((\w+) ?)+\z/
42
+ member :age, ->age{(20..140).include? age}
43
+ end
44
+
45
+ def setup
46
+ @user = User.new 9999, 'taro', 'yamada', 'Tokyo Japan', 30
47
+ end
48
+
49
+ def test_reader
50
+ assert_equal @user[1], 'taro'
51
+ assert_equal @user[:last_name], 'taro'
52
+ assert_equal @user.last_name, 'taro'
53
+ end
54
+
55
+ def test_setter_pass
56
+ assert_equal((@user.id = 2139203509295), 2139203509295)
57
+ assert_equal @user.id, 2139203509295
58
+ assert_equal((@user.last_name = 'jiro'), 'jiro')
59
+ assert_equal @user.last_name, 'jiro'
60
+ assert_equal((@user.age = 40), 40)
61
+ assert_equal @user.age, 40
62
+ end
63
+
64
+ def test_setter_fail
65
+ assert_raises Validation::InvalidWritingError do
66
+ @user.id = 2139203509295.0
67
+ end
68
+
69
+ assert_raises Validation::InvalidWritingError do
70
+ @user.last_name = 'ignore name'
71
+ end
72
+
73
+ assert_raises Validation::InvalidWritingError do
74
+ @user.age = 19
75
+ end
76
+ end
77
+
78
+ def test_strict?
79
+ assert_same @user.sufficient?(:last_name), true
80
+ assert_same @user.strict?, true
81
+ assert_same @user.sufficient?(:last_name), true
82
+ @user.last_name.clear
83
+ assert_same @user.sufficient?(:last_name), false
84
+ assert_same @user.strict?, false
85
+ end
86
+
87
+ end
88
+
89
+
90
+ class Test_Striuct_Subclass_Instance_Accsessor < Test::Unit::TestCase
91
+
92
+ class Sth < Striuct.new
93
+ member :bool, OR(true, false)
94
+ member :sth
95
+ protect_level :struct
96
+ member :lambda, OR(->v{v % 3 == 2}, ->v{v.kind_of? Float})
97
+ end
98
+
99
+ def setup
100
+ @sth = Sth.new
101
+ end
102
+
103
+ def test_accessor
104
+ @sth.bool = true
105
+ assert_same true, @sth.bool
106
+ @sth.bool = false
107
+ assert_same false, @sth.bool
108
+
109
+ assert_raises Validation::InvalidWritingError do
110
+ @sth.bool = nil
111
+ end
112
+
113
+ @sth.sth = 1
114
+ assert_same 1, @sth.sth
115
+
116
+ @sth.sth = 'String'
117
+ assert_equal 'String', @sth.sth
118
+
119
+ @sth.sth = Class.class
120
+ assert_same Class.class, @sth.sth
121
+
122
+ assert_raises Validation::InvalidWritingError do
123
+ @sth.lambda = 9
124
+ end
125
+
126
+ assert_raises Validation::InvalidWritingError do
127
+ @sth.lambda = 7
128
+ end
129
+
130
+ @sth.lambda = 8
131
+ assert_same 8, @sth.lambda
132
+
133
+ @sth.lambda = 9.0
134
+ assert_equal 9.0, @sth.lambda
135
+ end
136
+
137
+ end
@@ -1,95 +1,95 @@
1
- require_relative 'helper'
2
-
3
-
4
- class Test_Striuct_Subclass_Instance_Adjuster < Test::Unit::TestCase
5
-
6
- class MyClass
7
- def self.parse(v)
8
- raise unless /\A[a-z]+\z/ =~ v
9
- new
10
- end
11
- end
12
-
13
- Sth = Striuct.define do
14
- member :chomped, AND(Symbol, /[^\n]\z/), &WHEN(String, ->v{v.chomp.to_sym})
15
- member :no_reduced, Symbol, &->v{v.to_sym}
16
- member :reduced, Symbol, &INJECT(->v{v.to_s}, ->v{v.to_sym})
17
- member :integer, Integer, &PARSE(Integer)
18
- member :myobj, ->v{v.instance_of? MyClass}, &PARSE(MyClass)
19
- end
20
-
21
- def test_WHEN
22
- sth = Sth.new
23
-
24
- assert_raises Validation::InvalidWritingError do
25
- sth.chomped = :"a\n"
26
- end
27
-
28
- sth.chomped = "a\n"
29
-
30
- assert_equal :a, sth.chomped
31
-
32
- sth.chomped = :b
33
- assert_equal :b, sth.chomped
34
- end
35
-
36
- def test_INJECT
37
- sth = Sth.new
38
-
39
- assert_raises Validation::UnmanagebleError do
40
- sth.no_reduced = 1
41
- end
42
-
43
- sth.reduced = 1
44
-
45
- assert_equal :'1', sth.reduced
46
- end
47
-
48
- def test_PARSE
49
- sth = Sth.new
50
-
51
- assert_raises Validation::UnmanagebleError do
52
- sth.integer = '1.0'
53
- end
54
-
55
- sth.integer = '1'
56
-
57
- assert_equal 1, sth.integer
58
-
59
- assert_raises Validation::UnmanagebleError do
60
- sth.myobj = '1'
61
- end
62
-
63
- sth.myobj = 'a'
64
-
65
- assert_kind_of MyClass, sth.myobj
66
- end
67
-
68
- end
69
-
70
- class Test_Striuct_Subclass_Instance_AdjusterOld < Test::Unit::TestCase
71
-
72
- Sth = Striuct.new do
73
- member :age, Numeric, &->arg{Integer arg}
74
- end
75
-
76
- def setup
77
- @sth = Sth.new
78
- assert_same nil, @sth.age
79
- end
80
-
81
- def test_procedure
82
- @sth.age = 10
83
- assert_same 10, @sth.age
84
- @sth.age = 10.0
85
- assert_same 10, @sth.age
86
-
87
- assert_raises Validation::UnmanagebleError do
88
- @sth.age = '10.0'
89
- end
90
-
91
- @sth.age = '10'
92
- assert_same 10, @sth.age
93
- end
94
-
1
+ require_relative 'helper'
2
+
3
+
4
+ class Test_Striuct_Subclass_Instance_Adjuster < Test::Unit::TestCase
5
+
6
+ class MyClass
7
+ def self.parse(v)
8
+ raise unless /\A[a-z]+\z/ =~ v
9
+ new
10
+ end
11
+ end
12
+
13
+ Sth = Striuct.define do
14
+ member :chomped, AND(Symbol, /[^\n]\z/), &WHEN(String, ->v{v.chomp.to_sym})
15
+ member :no_reduced, Symbol, &->v{v.to_sym}
16
+ member :reduced, Symbol, &INJECT(->v{v.to_s}, ->v{v.to_sym})
17
+ member :integer, Integer, &PARSE(Integer)
18
+ member :myobj, ->v{v.instance_of? MyClass}, &PARSE(MyClass)
19
+ end
20
+
21
+ def test_WHEN
22
+ sth = Sth.new
23
+
24
+ assert_raises Validation::InvalidWritingError do
25
+ sth.chomped = :"a\n"
26
+ end
27
+
28
+ sth.chomped = "a\n"
29
+
30
+ assert_equal :a, sth.chomped
31
+
32
+ sth.chomped = :b
33
+ assert_equal :b, sth.chomped
34
+ end
35
+
36
+ def test_INJECT
37
+ sth = Sth.new
38
+
39
+ assert_raises Validation::UnmanagebleError do
40
+ sth.no_reduced = 1
41
+ end
42
+
43
+ sth.reduced = 1
44
+
45
+ assert_equal :'1', sth.reduced
46
+ end
47
+
48
+ def test_PARSE
49
+ sth = Sth.new
50
+
51
+ assert_raises Validation::UnmanagebleError do
52
+ sth.integer = '1.0'
53
+ end
54
+
55
+ sth.integer = '1'
56
+
57
+ assert_equal 1, sth.integer
58
+
59
+ assert_raises Validation::UnmanagebleError do
60
+ sth.myobj = '1'
61
+ end
62
+
63
+ sth.myobj = 'a'
64
+
65
+ assert_kind_of MyClass, sth.myobj
66
+ end
67
+
68
+ end
69
+
70
+ class Test_Striuct_Subclass_Instance_AdjusterOld < Test::Unit::TestCase
71
+
72
+ Sth = Striuct.new do
73
+ member :age, Numeric, &->arg{Integer arg}
74
+ end
75
+
76
+ def setup
77
+ @sth = Sth.new
78
+ assert_same nil, @sth.age
79
+ end
80
+
81
+ def test_procedure
82
+ @sth.age = 10
83
+ assert_same 10, @sth.age
84
+ @sth.age = 10.0
85
+ assert_same 10, @sth.age
86
+
87
+ assert_raises Validation::UnmanagebleError do
88
+ @sth.age = '10.0'
89
+ end
90
+
91
+ @sth.age = '10'
92
+ assert_same 10, @sth.age
93
+ end
94
+
95
95
  end
@@ -1,30 +1,30 @@
1
- require_relative 'helper'
2
-
3
- class Test_Striuct_Subclass_Instance_Assign < Test::Unit::TestCase
4
-
5
- Sth = Striuct.new do
6
- member :foo
7
- end
8
-
9
- def test_unassign
10
- sth = Sth.new
11
- assert_equal false, sth.assign?(:foo)
12
- sth.foo = nil
13
- assert_equal true, sth.assign?(:foo)
14
- sth.unassign :foo
15
- assert_equal false, sth.assign?(:foo)
16
- sth.foo = nil
17
- assert_equal true, sth.assign?(:foo)
18
- sth.clear_at 0
19
- assert_equal false, sth.assign?(:foo)
20
-
21
- assert_raises NameError do
22
- sth.unassign :var
23
- end
24
-
25
- assert_raises IndexError do
26
- sth.unassign 1
27
- end
28
- end
29
-
30
- end
1
+ require_relative 'helper'
2
+
3
+ class Test_Striuct_Subclass_Instance_Assign < Test::Unit::TestCase
4
+
5
+ Sth = Striuct.new do
6
+ member :foo
7
+ end
8
+
9
+ def test_unassign
10
+ sth = Sth.new
11
+ assert_equal false, sth.assign?(:foo)
12
+ sth.foo = nil
13
+ assert_equal true, sth.assign?(:foo)
14
+ sth.unassign :foo
15
+ assert_equal false, sth.assign?(:foo)
16
+ sth.foo = nil
17
+ assert_equal true, sth.assign?(:foo)
18
+ sth.clear_at 0
19
+ assert_equal false, sth.assign?(:foo)
20
+
21
+ assert_raises NameError do
22
+ sth.unassign :var
23
+ end
24
+
25
+ assert_raises IndexError do
26
+ sth.unassign 1
27
+ end
28
+ end
29
+
30
+ end
@@ -1,32 +1,32 @@
1
- require_relative 'helper'
2
-
3
- class Test_Striuct_Subclass_Instance_Basic < Test::Unit::TestCase
4
-
5
- class User < Striuct.new
6
- member :id, Integer
7
- member :last_name, /\A\w+\z/
8
- member :family_name, /\A\w+\z/
9
- member :address, /\A((\w+) ?)+\z/
10
- member :age, ->age{(20..140).include? age}
11
- end
12
-
13
- def setup
14
- @user = User.new 9999, 'taro', 'yamada', 'Tokyo Japan', 30
15
- @user2 = User.new 9999, 'taro', 'yamada', 'Tokyo Japan', 30
16
- end
17
-
18
- def test_delegate_class_method
19
- assert_equal @user.members, User.members
20
- assert_equal @user.size, User.size
21
- assert_equal @user.member?(:age), User.member?(:age)
22
- end
23
-
24
- def test_values
25
- assert_equal @user.values, [9999, 'taro', 'yamada', 'Tokyo Japan', 30]
26
- end
27
-
28
- def test_values_at
29
- assert_equal(@user.values_at(4, 0, (2..4)), [30, 9999, 'yamada', 'Tokyo Japan', 30])
30
- end
31
-
32
- end
1
+ require_relative 'helper'
2
+
3
+ class Test_Striuct_Subclass_Instance_Basic < Test::Unit::TestCase
4
+
5
+ class User < Striuct.new
6
+ member :id, Integer
7
+ member :last_name, /\A\w+\z/
8
+ member :family_name, /\A\w+\z/
9
+ member :address, /\A((\w+) ?)+\z/
10
+ member :age, ->age{(20..140).include? age}
11
+ end
12
+
13
+ def setup
14
+ @user = User.new 9999, 'taro', 'yamada', 'Tokyo Japan', 30
15
+ @user2 = User.new 9999, 'taro', 'yamada', 'Tokyo Japan', 30
16
+ end
17
+
18
+ def test_delegate_class_method
19
+ assert_equal @user.members, User.members
20
+ assert_equal @user.size, User.size
21
+ assert_equal @user.member?(:age), User.member?(:age)
22
+ end
23
+
24
+ def test_values
25
+ assert_equal @user.values, [9999, 'taro', 'yamada', 'Tokyo Japan', 30]
26
+ end
27
+
28
+ def test_values_at
29
+ assert_equal(@user.values_at(4, 0, (2..4)), [30, 9999, 'yamada', 'Tokyo Japan', 30])
30
+ end
31
+
32
+ end
@@ -1,23 +1,23 @@
1
- require_relative 'helper'
2
-
3
- class Test_Striuct_Subclass_Instance_Cloning < Test::Unit::TestCase
4
-
5
- class Sth < Striuct.new
6
- member :sth
7
- end
8
-
9
- def test_dup
10
- sth = Sth.new
11
- sth2 = sth.dup
12
- sth.sth = 1
13
- assert_equal false, (sth.sth == sth2.sth)
14
- end
15
-
16
- def test_clone
17
- sth = Sth.new
18
- sth2 = sth.clone
19
- sth.sth = 2
20
- assert_equal false, (sth.sth == sth2.sth)
21
- end
22
-
1
+ require_relative 'helper'
2
+
3
+ class Test_Striuct_Subclass_Instance_Cloning < Test::Unit::TestCase
4
+
5
+ class Sth < Striuct.new
6
+ member :sth
7
+ end
8
+
9
+ def test_dup
10
+ sth = Sth.new
11
+ sth2 = sth.dup
12
+ sth.sth = 1
13
+ assert_equal false, (sth.sth == sth2.sth)
14
+ end
15
+
16
+ def test_clone
17
+ sth = Sth.new
18
+ sth2 = sth.clone
19
+ sth.sth = 2
20
+ assert_equal false, (sth.sth == sth2.sth)
21
+ end
22
+
23
23
  end