"""Test that importing modules in Objective-C works as expected."""

import lldb

from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class ObjCModulesAutoImportTestCase(TestBase):
    SHARED_BUILD_TESTCASE = False

    @skipIf(macos_version=["<", "10.12"])
    @skipIf(compiler="clang", compiler_version=["<", "20.0"])
    def test_expr(self):
        self.build()
        lldbutil.run_to_source_breakpoint(
            self, "// break here", lldb.SBFileSpec("main.m", False)
        )

        self.runCmd("settings set target.auto-import-clang-modules true")
        self.expect_expr("getpid()", result_type="pid_t")

    @skipIf(macos_version=["<", "10.12"])
    @skipIf(compiler="clang", compiler_version=["<", "20.0"])
    def test_expr_no_sysroot(self):
        self.build(dictionary={"TEST_EXTRA_FLAGS": f"-fno-debug-record-sysroot"})
        lldbutil.run_to_source_breakpoint(
            self, "// break here", lldb.SBFileSpec("main.m", False)
        )

        self.runCmd("settings set target.auto-import-clang-modules true")
        self.expect_expr("getpid()", result_type="pid_t")
