blob: e02f791f278bd4d54737a9e63101bb8ab81f47ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
require 'test/unit'
$KCODE = 'none'
class TestStruct < Test::Unit::TestCase
def test_struct
struct_test = Struct.new("Test", :foo, :bar)
assert_equal(struct_test, Struct::Test)
test = struct_test.new(1, 2)
assert(test.foo == 1 && test.bar == 2)
assert(test[0] == 1 && test[1] == 2)
a, b = test.to_a
assert(a == 1 && b == 2)
test[0] = 22
assert_equal(test.foo, 22)
test.bar = 47
assert_equal(test.bar, 47)
end
end
|