1"""
2Test that variable expressions of floating point types are evaluated correctly.
3"""
4
5import AbstractBase
6import unittest2
7import lldb
8import sys
9from lldbtest import dsym_test, dwarf_test
10
11class FloatTypesExprTestCase(AbstractBase.GenericTester):
12
13    mydir = "types"
14
15    # rdar://problem/8493023
16    # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error?
17
18    def setUp(self):
19        # Call super's setUp().
20        AbstractBase.GenericTester.setUp(self)
21        # disable "There is a running process, kill it and restart?" prompt
22        self.runCmd("settings set auto-confirm true")
23        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
24
25    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
26    @dsym_test
27    def test_float_type_with_dsym(self):
28        """Test that float-type variable expressions are evaluated correctly."""
29        self.build_and_run_expr('float.cpp', set(['float']))
30
31    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
32    @dsym_test
33    def test_float_type_from_block_with_dsym(self):
34        """Test that float-type variables are displayed correctly from a block."""
35        self.build_and_run_expr('float.cpp', set(['float']), bc=True)
36
37    @dwarf_test
38    def test_float_type_with_dwarf(self):
39        """Test that float-type variable expressions are evaluated correctly."""
40        self.build_and_run_expr('float.cpp', set(['float']), dsym=False)
41
42    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
43    @dsym_test
44    def test_double_type_with_dsym(self):
45        """Test that double-type variable expressions are evaluated correctly."""
46        self.build_and_run_expr('double.cpp', set(['double']))
47
48    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
49    @dsym_test
50    def test_double_type_from_block_with_dsym(self):
51        """Test that double-type variables are displayed correctly from a block."""
52        self.build_and_run_expr('double.cpp', set(['double']), bc=True)
53
54    @dwarf_test
55    def test_double_type_with_dwarf(self):
56        """Test that double-type variable expressions are evaluated correctly."""
57        self.build_and_run_expr('double.cpp', set(['double']), dsym=False)
58
59
60if __name__ == '__main__':
61    import atexit
62    lldb.SBDebugger.Initialize()
63    atexit.register(lambda: lldb.SBDebugger.Terminate())
64    unittest2.main()
65