#!/usr/bin/ruby

#
## Test Object.dclone() on cyclic references
#

var src = Hash(foo => 0, bar => [0,1])

# Add a cyclic reference
src{:baz} = src

# Make a deep clone
var dst = src.dclone

# The address of src
assert_eq(src.object_id, src{:baz}.object_id)
assert_ne(src.object_id, 0)

# The address of dst
assert_eq(dst.object_id, dst{:baz}.object_id)
assert_ne(dst.object_id, 0)

assert_ne(src.object_id, dst.object_id)

say "** Test passed!"