File: forward-slash-regex-skipping-allowed.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 (68 lines) | stat: -rw-r--r-- 1,641 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
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -parse -enable-bare-slash-regex -disable-availability-checking -experimental-skip-all-function-bodies -verify -stats-output-dir %t %s
// RUN: %{python} %utils/process-stats-dir.py --set-csv-baseline %t/stats.csv %t
// RUN: %FileCheck -input-file %t/stats.csv %s

// REQUIRES: swift_swift_parser

// Make sure we can skip in all of the below cases.

// The printing implementation differs in asserts and no-asserts builds, it will
// either print `"Parse.NumFunctionsParsed" 0` or not print it at all. Make sure
// we don't output any non-zero value.
// CHECK-NOT: {{"Parse.NumFunctionsParsed" [^0]}}

// Ensures there is a parse error
var : Int // expected-error{{expected pattern}}

// Balanced `{}`, so okay.
func a() { / {}/ }
func b() { / \{}/ }
func c() { / {"{"}/ }

// Some cases of infix '/' that we should continue to skip.
func d() {
  _ = 1 / 2 + 3 * 4
  _ = 1 / 2 / 3 / 4
}
func e() {
  let arr = [1, 2, 3]
  _ = arr.reduce(0, /) / 2

  func foo(_ i: Int, _ fn: () -> Void) {}
  foo(1 / 2 / 3, { print("}}}{{{") })
}

// Some cases of prefix '/' that we should continue to skip.
prefix operator /
prefix func / <T> (_ x: T) -> T { x }

enum E {
  case e
  func foo<T>(_ x: T) {}
}

func f() {
  _ = /E.e
  (/E.e).foo(/0)

  func foo<T, U>(_ x: T, _ y: U) {}
  foo(/E.e, /E.e)
  foo((/E.e), /E.e)
  foo((/)(E.e), /E.e)

  func bar<T>(_ x: T) -> Int { 0 }
  _ = bar(/E.e) / 2
}

postfix operator /
prefix func / <T> (_ x: T) -> T { x }

// Some cases of postfix '/' that we should continue to skip.
func g() {
    _ = 0/
    _ = 0/ / 1/
    _ = 1/ + 1/
    _ = 1 + 2/
}