File: TestComplexInt.py

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (48 lines) | stat: -rw-r--r-- 2,206 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Tests GCC's complex integer types.
"""

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

class TestCase(TestBase):

    mydir = TestBase.compute_mydir(__file__)

    @no_debug_info_test
    @skipIfWindows
    def test(self):
        self.build()
        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))

        long_size_eq_int = self.frame().EvaluateExpression("sizeof(long) == sizeof(int)")

        # FIXME: LLDB treats all complex ints as unsigned, so the value is wrong.
        self.expect_expr("complex_int", result_type="_Complex int", result_value="4294967295 + 4294967294i")
        self.expect_expr("complex_unsigned", result_type="_Complex int", result_value="1 + 2i")

        # FIXME: We get the type wrong if long has the same size as int.
        if long_size_eq_int.GetValue() == "true":
            self.expect_expr("complex_long", result_type="_Complex int")
            self.expect_expr("complex_unsigned_long", result_type="_Complex int", result_value="1 + 2i")
        else:
            self.expect_expr("complex_long", result_type="_Complex long")
            self.expect_expr("complex_unsigned_long", result_type="_Complex long", result_value="1 + 2i")

    @no_debug_info_test
    @skipIfWindows
    def test_long_long(self):
        self.build()
        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))

        # FIXME: We get the type wrong if long has the same size as long long.
        # FIXME: LLDB treats all complex ints as unsigned, so the value is wrong.
        long_size_eq_long_long = self.frame().EvaluateExpression("sizeof(long) == sizeof(long long)")
        if long_size_eq_long_long.GetValue() == "true":
            self.expect_expr("complex_long_long", result_type="_Complex long")
            self.expect_expr("complex_unsigned_long_long", result_type="_Complex long", result_value="1 + 2i")
        else:
            self.expect_expr("complex_long_long", result_type="_Complex long long")
            self.expect_expr("complex_unsigned_long_long", result_type="_Complex long long", result_value="1 + 2i")