Skip to content

Commit a54cb9d

Browse files
committed
Add top-level and init/deinit tests
1 parent e255bac commit a54cb9d

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

test/IDE/complete_single_expression_return.swift

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@
3434
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestNonSingleExprSubscriptUnresolved | %FileCheck %s -check-prefix=TestNonSingleExprSubscriptUnresolved
3535
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingleExprSubscriptGlobal | %FileCheck %s -check-prefix=TestSingleExprSubscriptGlobal
3636

37+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitInvalid | %FileCheck %s -check-prefix=TestSingeExprInitInvalid
38+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitNone | %FileCheck %s -check-prefix=TestSingeExprInitNone
39+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitNilRet | %FileCheck %s -check-prefix=TestSingeExprInitNilRet
40+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprInitNil | %FileCheck %s -check-prefix=TestSingeExprInitNil
41+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestNonSingeExprInitNil1 | %FileCheck %s -check-prefix=TestNonSingeExprInitNil
42+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestNonSingeExprInitNil2 | %FileCheck %s -check-prefix=TestNonSingeExprInitNil
43+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TestSingeExprDeinitInvalid | %FileCheck %s -check-prefix=TestSingeExprDeinitInvalid
44+
45+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=testAccessorUnresolvedTopLevel | %FileCheck %s -check-prefix=TopLevelEnum
46+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=testAccessorUnresolvedTopLevelGet | %FileCheck %s -check-prefix=TopLevelEnum
47+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=testClosureUnresolvedTopLevelInit | %FileCheck %s -check-prefix=TopLevelEnum
48+
3749
// MARK: Single-expression closures
3850

3951
struct TestSingleExprClosureRet {
@@ -548,3 +560,88 @@ struct TestSingleExprSubscriptGlobal {
548560
// TestSingleExprSubscriptGlobal-DAG: Decl[InstanceMethod]/CurrNominal: void()[#Void#];
549561
// TestSingleExprSubscriptGlobal: End completions
550562
}
563+
564+
// MARK: Single-expression initializers
565+
566+
enum TestSingeExprInitInvalid {
567+
case foo
568+
init() {
569+
.#^TestSingeExprInitInvalid^#
570+
}
571+
// TestSingeExprInitInvalid-NOT: foo
572+
}
573+
574+
enum TestSingeExprInitNone {
575+
case foo
576+
init?() {
577+
.#^TestSingeExprInitNone^#
578+
}
579+
// TestSingeExprInitNone-NOT: foo
580+
// Note: only `nil` is allowed here, not `.none`.
581+
// TestSingeExprInitNone-NOT: none
582+
}
583+
584+
enum TestSingeExprInitNilRet {
585+
case foo
586+
init?() {
587+
return #^TestSingeExprInitNilRet^#
588+
}
589+
// TestSingeExprInitNilRet: Literal[Nil]/None/TypeRelation[Identical]: nil[#TestSingeExprInitNil{{(Ret)?}}?#];
590+
}
591+
592+
enum TestSingeExprInitNil {
593+
case foo
594+
init?() {
595+
#^TestSingeExprInitNil^#
596+
}
597+
// FIXME: For consistency, this should be same as TestSingeExprInitNilRet.
598+
// TestSingeExprInitNil: Literal[Nil]/None: nil;
599+
}
600+
601+
enum TestNonSingeExprInitNil1 {
602+
case foo
603+
init?() {
604+
#^TestNonSingeExprInitNil1^#
605+
return nil
606+
}
607+
// No type relation.
608+
// TestNonSingeExprInitNil: Literal[Nil]/None: nil;
609+
}
610+
611+
enum TestNonSingeExprInitNil2 {
612+
case foo
613+
init?() {
614+
#^TestNonSingeExprInitNil2^#
615+
self = .foo
616+
}
617+
}
618+
619+
enum TestSingeExprDeinitInvalid {
620+
case foo
621+
deinit {
622+
.#^TestSingeExprDeinitInvalid^#
623+
}
624+
// TestSingeExprDeinitInvalid-NOT: foo
625+
}
626+
627+
// MARK: Top-level code
628+
629+
enum TopLevelEnum {
630+
case foo
631+
}
632+
633+
// TopLevelEnum: Decl[EnumElement]/ExprSpecific: foo[#TopLevelEnum#];
634+
635+
var testAccessorUnresolvedTopLevel: TopLevelEnum {
636+
.#^testAccessorUnresolvedTopLevel^#
637+
}
638+
639+
var testAccessorUnresolvedTopLevelGet: TopLevelEnum {
640+
get {
641+
.#^testAccessorUnresolvedTopLevelGet^#
642+
}
643+
}
644+
645+
var testClosureUnresolvedTopLevelInit: TopLevelEnum = {
646+
.#^testClosureUnresolvedTopLevelInit^#
647+
}()

0 commit comments

Comments
 (0)