File: discriminator.swift

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 (46 lines) | stat: -rw-r--r-- 1,591 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
func sink(_ a: (Int) -> Void) {}
    
func testSingleStatementClosure() {
  sink { items in
    // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s --check-prefix=SINGLE-STMT-CLOSURE
    var items = items
  }
  // SINGLE-STMT-CLOSURE: s:13discriminator26testSingleStatementClosureyyFySiXEfU_5itemsL0_Sivp
}


func testMultiStatementClosure() {
  sink { items in
    // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s --check-prefix=MULTI-STMT-CLOSURE
    var items = items
    print("xxx")
  }
  // MULTI-STMT-CLOSURE: s:13discriminator25testMultiStatementClosureyyFySiXEfU_5itemsL0_Sivp
}

func testNestedClosures() {
  func dataTask(completionHandler: (Int?) -> Void) {}
  func async2(execute work: () -> Void) {}

  dataTask { (error) in
    do {
      // RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):17 %s -- %s | %FileCheck %s --check-prefix=NESTED_CLOSURE
    } catch let error {
      async2 {
        print("")
      }
    }
  }
  // NESTED_CLOSURE: s:13discriminator18testNestedClosuresyyFySiSgXEfU_5errorL1_s5Error_pvp
}

func testReuseAST(bytes: Int) {
  // RUN: %sourcekitd-test -req=cursor -pos=%(line + 2):7 %s -- %s == \
  // RUN:   -req=cursor -pos=%(line + 2):7 %s -- %s | %FileCheck %s --check-prefix=REUSE_AST
  let size = 3
  var bytes = 6
  // REUSE_AST: source.lang.swift.decl.var.local (40:7-40:11)
  // REUSE_AST: s:13discriminator12testReuseAST5bytesySi_tF4sizeL_Sivp
  // REUSE_AST: source.lang.swift.decl.var.local (41:7-41:12)
  // REUSE_AST: s:13discriminator12testReuseAST5bytesySi_tFACL0_Sivp
}