from ..base import BaseTopazTest


class TestSymbolObject(BaseTopazTest):
    def test_name(self, space):
        space.execute("Symbol")

    def test_symbol(self, space):
        w_res = space.execute("return :foo")
        assert space.symbol_w(w_res) == "foo"

    def test_to_s(self, space):
        w_res = space.execute("return :foo.to_s")
        assert space.str_w(w_res) == "foo"

    def test_inspect(self, space):
        w_res = space.execute("return :foo.inspect")
        assert space.str_w(w_res) == ":foo"

    def test_comparator_lt(self, space):
        w_res = space.execute("return :a <=> :b")
        assert space.int_w(w_res) == -1

    def test_comparator_eq(self, space):
        w_res = space.execute("return :a <=> :a")
        assert space.int_w(w_res) == 0

    def test_comparator_gt(self, space):
        w_res = space.execute("return :b <=> :a")
        assert space.int_w(w_res) == 1

    def test_comparator_non_symbol(self, space):
        w_res = space.execute("return :a <=> 12")
        assert w_res is space.w_nil

    def test_identity(self, space):
        w_res = space.execute("return [:x.object_id, :x.object_id]")
        id1, id2 = self.unwrap(space, w_res)
        assert id1 == id2

    def test_to_sym(self, space):
        w_res = space.execute("return :x, :x.to_sym")
        s1, s2 = self.unwrap(space, w_res)
        assert s1 == s2 == "x"

    def test_to_proc(self, space):
        w_res = space.execute("return :+.to_proc.call(2, 3)")
        assert space.int_w(w_res) == 5

@@ -1,8 +1,63 @@
+from topaz.objects.symbolobject import W_SymbolObject%0A%0A
 from ..b
@@ -1578,8 +1578,788 @@
 s) == 5%0A
+%0A    def test_succ(self, space):%0A        w_res = space.execute('return :abcd.succ')%0A        assert space.str_w(w_res) == %22abce%22%0A        assert isinstance(w_res, W_SymbolObject)%0A        w_res = space.execute('return :THX1138.succ')%0A        assert space.str_w(w_res) == %22THX1139%22%0A        assert isinstance(w_res, W_SymbolObject)%0A        w_res = space.execute('return :%22%3C%3Ckoala%3E%3E%22.succ')%0A        assert space.str_w(w_res) == %22%3C%3Ckoalb%3E%3E%22%0A        assert isinstance(w_res, W_SymbolObject)%0A        w_res = space.execute('return :%22ZZZ9999%22.succ')%0A        assert space.str_w(w_res) == %22AAAA0000%22%0A        assert isinstance(w_res, W_SymbolObject)%0A        w_res = space.execute('return :%22***%22.succ')%0A        assert space.str_w(w_res) == %22**+%22%0A        assert isinstance(w_res, W_SymbolObject)%0A

add a test for symbol#succ