File: TestSwiftVariadicGenerics.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (92 lines) | stat: -rw-r--r-- 3,326 bytes parent folder | download
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import unittest2

class TestSwiftVariadicGenerics(TestBase):

    @skipUnlessDarwin
    @swiftTest
    def test(self):
        self.build()

        target,  process, _, _ = lldbutil.run_to_source_breakpoint(
            self, "break here", lldb.SBFileSpec('a.swift'))

        # f1(args: a, b)
        self.expect("frame variable",
                    substrs=["Pack{(a.A, a.B)}", "args", "i = 23", "d = 2.71"])

        # Test that an expression can be set up in a variadic environment.
        self.expect("expr --bind-generic-types=true -- 0", substrs=["0"])
        self.expect("expr --bind-generic-types=false -- 0", substrs=["0"])
        # FIXME: crashes the compiler.
        #self.expect("expr --bind-generic-params=false -- (repeat each args)",
        #            substrs=["args"])

        # f2(us: a, vs: b)
        process.Continue()
        self.expect("frame variable",
                    substrs=["Pack{(a.A)}", "us", "i = 23",
                             "Pack{(a.B)}", "vs", "d = 2.71"])

        # f3(ts: a, b, more_ts: a, b)
        process.Continue()
        self.expect("frame variable",
                    substrs=["Pack{(a.A, a.B)}", "ts", "i = 23", "d = 2.71",
                             "Pack{(a.A, a.B)}", "more_ts", "i = 23", "d = 2.71"])

        # f4(uvs: (a, b), (a, b))
        process.Continue()
        self.expect("frame variable",
                    substrs=[""])

        # f5(ts: (a, b), (42, b))
        process.Continue()
        self.expect("frame variable",
                    substrs=[# FIXME: "Pack{(a.A, a.B), (Int, a,B)}",
                             "ts", "i = 23", "d = 2.71"
                             # FIXME: "42", "d = 2.71"
                    ])

        # f6(us: a, more_us: a, vs: b, b)
        process.Continue()
        self.expect("frame variable",
                    substrs=["Pack{(a.A)}", "us", "i = 23",
                             "Pack{(a.A)}", "more_us", "i = 23",
                             "Pack{(a.B, a.B)}", "vs", "d = 2.71", "d = 2.71"
                             ])

        # f7(us: a, vs: 1, b, more_us: a, more_vs: 2, b)
        process.Continue()
        self.expect("frame variable",
                    substrs=["Pack{(a.A)}", "us", "i = 23",
                             "Pack{(Int, a.B)}", "vs", "= 1", "d = 2.71",
                             "Pack{(a.A)}", "more_us", "i = 23",
                             "Pack{(Int, a.B)}", "more_vs", "= 2", "d = 2.71"
                    ])

        # f8(<specialized self>)
        process.Continue()
        # specialized global
        process.Continue()
        self.expect("target variable s",
                    substrs=["vals", "0 = 23", "1 = 2.71"])

        # f9(s: S<repeat each T>)
        process.Continue()
        self.expect("frame variable", substrs=["t", "0 = 23", "1 = 2.71"])

        # f10<each T>(args: repeat each T)
        process.Continue()
        self.expect(
            "frame variable", substrs=[
                "Pack{(a.A, a.B)}",
                "args",
                "i = 23",
                "d ="
                # FIXME: The wrong value for d is currently shown.
                #"d = 2.71"
            ]
        )