Files
swift-mirror/test/SourceKit/CodeComplete/complete_operators.swift
Ben Langmuir 8f9299cc97 [CodeCompletion] Add assignment to experimental operator completion
When the LHS is an lvalue/assignable tuple and there is no leading
sequence of binary expressions.

It's a bit hacky right now since we don't have a good way to
differentiate general pattern completions from builtin operators.

rdar://problem/23209683
2016-03-02 18:21:37 -08:00

66 lines
1.7 KiB
Swift

// RUN: %complete-test -tok=INT_OPERATORS %s | FileCheck %s
// RUN: %complete-test -add-inner-results -tok=INT_OPERATORS_INNER %s | FileCheck %s -check-prefix=INNER
// RUN: %complete-test -raw -hide-none -tok=INT_OPERATORS %s | FileCheck %s -check-prefix=RAW
// RUN: %complete-test -tok=BOOL_OPERATORS %s | FileCheck %s -check-prefix=BOOL
struct MyInt {
var bigPowers: Int { return 1 }
}
func +(x: MyInt, y: MyInt) -> MyInt { return x }
postfix func ++(x: inout MyInt) -> MyInt { return x }
func !=(x: MyInt, y: MyInt) -> Bool { return true }
let xxxx = 1
func test1(var x: MyInt) {
x#^INT_OPERATORS^#
}
// CHECK: .
// CHECK: !=
// CHECK: +
// CHECK: ++
// CHECK: =
func test2(var x: MyInt) {
#^INT_OPERATORS_INNER,x^#
}
// INNER: x.
// INNER: x+
// INNER: x++
// INNER: xxxx
// INNER: x=
// INNER: x.bigPowers
// RAW: {
// RAW: key.kind: source.lang.swift.decl.function.operator.infix,
// RAW: key.name: "!=",
// RAW: key.sourcetext: " != <#T##MyInt#>",
// RAW: key.description: "!=",
// RAW: key.typename: "Bool",
// RAW: {
// RAW: key.kind: source.lang.swift.decl.function.operator.infix,
// RAW: key.name: "+",
// RAW: key.sourcetext: " + <#T##MyInt#>",
// RAW: key.description: "+",
// RAW: key.typename: "MyInt",
// RAW: },
// RAW: {
// RAW: key.kind: source.lang.swift.decl.function.operator.postfix,
// RAW: key.name: "++",
// RAW: key.sourcetext: "++",
// RAW: key.description: "++",
// RAW: key.typename: "MyInt",
// RAW: },
struct MyBool {
var foo: Int
}
func &&(x: MyBool, y: MyBool) -> MyBool { return x }
func ||(x: MyBool, y: MyBool) -> MyBool { return x }
func test3(x: MyBool) {
x#^BOOL_OPERATORS^#
}
// BOOL: .
// BOOL: &&
// BOOL: ||