import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import os
import unittest2


class TestSwiftOptimizedBoundGenericEnum(lldbtest.TestBase):

    mydir = lldbtest.TestBase.compute_mydir(__file__)

    @swiftTest
    def test(self):
        """Test the bound generic enum types in "optimized" code."""
        self.build()
        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(self,
            'break one', lldb.SBFileSpec('main.swift'))
        bkpt_two = target.BreakpointCreateBySourceRegex(
            'break two', lldb.SBFileSpec('main.swift'))
        self.assertGreater(bkpt_two.GetNumLocations(), 0)


        var_self = self.frame().FindVariable("self")
        # FIXME, this fails with a data extractor error.
        lldbutil.check_variable(self, var_self, False, value=None)
        lldbutil.continue_to_breakpoint(process, bkpt_two)
        var_self = self.frame().FindVariable("self")
        lldbutil.check_variable(self, var_self, True, value="success")

[((241, 282), 'lldbsuite.test.lldbtest.TestBase.compute_mydir', 'lldbtest.TestBase.compute_mydir', (['__file__'], {}), '(__file__)\n', (272, 282), True, 'import lldbsuite.test.lldbtest as lldbtest\n'), ((836, 894), 'lldbsuite.test.lldbutil.check_variable', 'lldbutil.check_variable', (['self', 'var_self', '(False)'], {'value': 'None'}), '(self, var_self, False, value=None)\n', (859, 894), True, 'import lldbsuite.test.lldbutil as lldbutil\n'), ((903, 953), 'lldbsuite.test.lldbutil.continue_to_breakpoint', 'lldbutil.continue_to_breakpoint', (['process', 'bkpt_two'], {}), '(process, bkpt_two)\n', (934, 953), True, 'import lldbsuite.test.lldbutil as lldbutil\n'), ((1015, 1077), 'lldbsuite.test.lldbutil.check_variable', 'lldbutil.check_variable', (['self', 'var_self', '(True)'], {'value': '"""success"""'}), "(self, var_self, True, value='success')\n", (1038, 1077), True, 'import lldbsuite.test.lldbutil as lldbutil\n'), ((514, 543), 'lldb.SBFileSpec', 'lldb.SBFileSpec', (['"""main.swift"""'], {}), "('main.swift')\n", (529, 543), False, 'import lldb\n'), ((627, 656), 'lldb.SBFileSpec', 'lldb.SBFileSpec', (['"""main.swift"""'], {}), "('main.swift')\n", (642, 656), False, 'import lldb\n')]