Commit c2431a7a6266fb760f0a1b22f44ef25b3b12b3f7

Golmote 2015-09-09T07:36:55

Merge pull request #752 from Golmote/tests-swift Add tests for Swift

diff --git a/tests/languages/swift/atrule_feature.test b/tests/languages/swift/atrule_feature.test
new file mode 100644
index 0000000..ae307f5
--- /dev/null
+++ b/tests/languages/swift/atrule_feature.test
@@ -0,0 +1,33 @@
+@IBOutlet
+@IBDesignable
+@IBAction
+@IBInspectable
+@class_protocol
+@exported
+@noreturn
+@NSCopying
+@NSManaged
+@objc
+@UIApplicationMain
+@auto_closure
+
+----------------------------------------------------
+
+[
+	["atrule", "@IBOutlet"],
+	["atrule", "@IBDesignable"],
+	["atrule", "@IBAction"],
+	["atrule", "@IBInspectable"],
+	["atrule", "@class_protocol"],
+	["atrule", "@exported"],
+	["atrule", "@noreturn"],
+	["atrule", "@NSCopying"],
+	["atrule", "@NSManaged"],
+	["atrule", "@objc"],
+	["atrule", "@UIApplicationMain"],
+	["atrule", "@auto_closure"]
+]
+
+----------------------------------------------------
+
+Checks for at-rules.
\ No newline at end of file
diff --git a/tests/languages/swift/builtin_feature.test b/tests/languages/swift/builtin_feature.test
new file mode 100644
index 0000000..9bc07e5
--- /dev/null
+++ b/tests/languages/swift/builtin_feature.test
@@ -0,0 +1,53 @@
+Foo
+Bar
+
+abs advance alignof alignofValue
+assert contains count countElements
+debugPrint debugPrintln distance
+dropFirst dropLast dump enumerate
+equal filter find first getVaList
+indices isEmpty join last
+lexicographicalCompare map max
+maxElement min minElement numericCast
+overlaps partition print
+println reduce reflect reverse
+sizeof sizeofValue sort sorted
+split startsWith stride strideof
+strideofValue suffix swap toDebugString
+toString transcode underestimateCount
+unsafeBitCast withExtendedLifetime
+withUnsafeMutablePointer
+withUnsafeMutablePointers
+withUnsafePointer withUnsafePointers
+withVaList
+
+----------------------------------------------------
+
+[
+	["builtin", "Foo"],
+	["builtin", "Bar"],
+
+	["builtin", "abs"], ["builtin", "advance"], ["builtin", "alignof"], ["builtin", "alignofValue"],
+	["builtin", "assert"], ["builtin", "contains"], ["builtin", "count"], ["builtin", "countElements"],
+	["builtin", "debugPrint"], ["builtin", "debugPrintln"], ["builtin", "distance"],
+	["builtin", "dropFirst"], ["builtin", "dropLast"], ["builtin", "dump"], ["builtin", "enumerate"],
+	["builtin", "equal"], ["builtin", "filter"], ["builtin", "find"], ["builtin", "first"], ["builtin", "getVaList"],
+	["builtin", "indices"], ["builtin", "isEmpty"], ["builtin", "join"], ["builtin", "last"],
+	["builtin", "lexicographicalCompare"], ["builtin", "map"], ["builtin", "max"],
+	["builtin", "maxElement"], ["builtin", "min"], ["builtin", "minElement"], ["builtin", "numericCast"],
+	["builtin", "overlaps"], ["builtin", "partition"], ["builtin", "print"],
+	["builtin", "println"], ["builtin", "reduce"], ["builtin", "reflect"], ["builtin", "reverse"],
+	["builtin", "sizeof"], ["builtin", "sizeofValue"], ["builtin", "sort"], ["builtin", "sorted"],
+	["builtin", "split"], ["builtin", "startsWith"], ["builtin", "stride"], ["builtin", "strideof"],
+	["builtin", "strideofValue"], ["builtin", "suffix"], ["builtin", "swap"], ["builtin", "toDebugString"],
+	["builtin", "toString"], ["builtin", "transcode"], ["builtin", "underestimateCount"],
+	["builtin", "unsafeBitCast"], ["builtin", "withExtendedLifetime"],
+	["builtin", "withUnsafeMutablePointer"],
+	["builtin", "withUnsafeMutablePointers"],
+	["builtin", "withUnsafePointer"], ["builtin", "withUnsafePointers"],
+	["builtin", "withVaList"]
+]
+
+----------------------------------------------------
+
+Checks for builtins.
\ No newline at end of file
diff --git a/tests/languages/swift/constant_feature.test b/tests/languages/swift/constant_feature.test
new file mode 100644
index 0000000..cd72339
--- /dev/null
+++ b/tests/languages/swift/constant_feature.test
@@ -0,0 +1,19 @@
+nil
+AB
+FOO_BAR
+kAb
+kFoo_bar
+
+----------------------------------------------------
+
+[
+	["constant", "nil"],
+	["constant", "AB"],
+	["constant", "FOO_BAR"],
+	["constant", "kAb"],
+	["constant", "kFoo_bar"]
+]
+
+----------------------------------------------------
+
+Checks for constants.
\ No newline at end of file
diff --git a/tests/languages/swift/keyword_feature.test b/tests/languages/swift/keyword_feature.test
new file mode 100644
index 0000000..079ffbd
--- /dev/null
+++ b/tests/languages/swift/keyword_feature.test
@@ -0,0 +1,165 @@
+as
+associativity
+break
+case
+catch
+class;
+continue
+convenience
+default
+defer
+deinit
+didSet
+do
+dynamic
+dynamicType
+else
+enum
+extension
+fallthrough
+final
+for
+func
+get
+guard
+if
+import
+in
+infix
+init
+inout
+internal
+is
+lazy
+left
+let
+mutating
+new;
+none
+nonmutating
+operator
+optional
+override
+postfix
+precedence
+prefix
+private
+Protocol
+public
+repeat
+required
+rethrows
+return
+right
+safe
+self
+Self
+set
+static
+struct
+subscript
+super
+switch
+throw
+throws
+try
+Type
+typealias
+unowned
+unsafe
+var
+weak
+where
+while
+willSet
+__COLUMN__
+__FILE__
+__FUNCTION__
+__LINE__
+
+----------------------------------------------------
+
+[
+	["keyword", "as"],
+	["keyword", "associativity"],
+	["keyword", "break"],
+	["keyword", "case"],
+	["keyword", "catch"],
+	["keyword", "class"], ["punctuation", ";"],
+	["keyword", "continue"],
+	["keyword", "convenience"],
+	["keyword", "default"],
+	["keyword", "defer"],
+	["keyword", "deinit"],
+	["keyword", "didSet"],
+	["keyword", "do"],
+	["keyword", "dynamic"],
+	["keyword", "dynamicType"],
+	["keyword", "else"],
+	["keyword", "enum"],
+	["keyword", "extension"],
+	["keyword", "fallthrough"],
+	["keyword", "final"],
+	["keyword", "for"],
+	["keyword", "func"],
+	["keyword", "get"],
+	["keyword", "guard"],
+	["keyword", "if"],
+	["keyword", "import"],
+	["keyword", "in"],
+	["keyword", "infix"],
+	["keyword", "init"],
+	["keyword", "inout"],
+	["keyword", "internal"],
+	["keyword", "is"],
+	["keyword", "lazy"],
+	["keyword", "left"],
+	["keyword", "let"],
+	["keyword", "mutating"],
+	["keyword", "new"], ["punctuation", ";"],
+	["keyword", "none"],
+	["keyword", "nonmutating"],
+	["keyword", "operator"],
+	["keyword", "optional"],
+	["keyword", "override"],
+	["keyword", "postfix"],
+	["keyword", "precedence"],
+	["keyword", "prefix"],
+	["keyword", "private"],
+	["keyword", "Protocol"],
+	["keyword", "public"],
+	["keyword", "repeat"],
+	["keyword", "required"],
+	["keyword", "rethrows"],
+	["keyword", "return"],
+	["keyword", "right"],
+	["keyword", "safe"],
+	["keyword", "self"],
+	["keyword", "Self"],
+	["keyword", "set"],
+	["keyword", "static"],
+	["keyword", "struct"],
+	["keyword", "subscript"],
+	["keyword", "super"],
+	["keyword", "switch"],
+	["keyword", "throw"],
+	["keyword", "throws"],
+	["keyword", "try"],
+	["keyword", "Type"],
+	["keyword", "typealias"],
+	["keyword", "unowned"],
+	["keyword", "unsafe"],
+	["keyword", "var"],
+	["keyword", "weak"],
+	["keyword", "where"],
+	["keyword", "while"],
+	["keyword", "willSet"],
+	["keyword", "__COLUMN__"],
+	["keyword", "__FILE__"],
+	["keyword", "__FUNCTION__"],
+	["keyword", "__LINE__"]
+]
+
+----------------------------------------------------
+
+Checks for all keywords.
\ No newline at end of file
diff --git a/tests/languages/swift/number_feature.test b/tests/languages/swift/number_feature.test
new file mode 100644
index 0000000..ca8b737
--- /dev/null
+++ b/tests/languages/swift/number_feature.test
@@ -0,0 +1,25 @@
+42
+42_000
+3.1415_9
+4.2e14
+0xBaf_Face
+0xFF47.AB_61p2
+0b0000_1111
+0o147_654
+
+----------------------------------------------------
+
+[
+	["number", "42"],
+	["number", "42_000"],
+	["number", "3.1415_9"],
+	["number", "4.2e14"],
+	["number", "0xBaf_Face"],
+	["number", "0xFF47.AB_61p2"],
+	["number", "0b0000_1111"],
+	["number", "0o147_654"]
+]
+
+----------------------------------------------------
+
+Checks for decimal, hexadecimal, octal and binary numbers.
\ No newline at end of file
diff --git a/tests/languages/swift/string_feature.test b/tests/languages/swift/string_feature.test
new file mode 100644
index 0000000..876213e
--- /dev/null
+++ b/tests/languages/swift/string_feature.test
@@ -0,0 +1,39 @@
+""
+"fo\"o"
+"foo\
+bar"
+"foo \(42)"
+"foo \(f("bar"))"
+
+----------------------------------------------------
+
+[
+	["string", ["\"\""]],
+	["string", ["\"fo\\\"o\""]],
+	["string", ["\"foo\\\r\nbar\""]],
+	["string", [
+		"\"foo ",
+		["interpolation", [
+			["delimiter", "\\("],
+			["number", "42"],
+			["delimiter", ")"]
+		]],
+		"\""
+	]],
+	["string", [
+		"\"foo ",
+		["interpolation", [
+			["delimiter", "\\("],
+			["function", "f"],
+			["punctuation", "("],
+			["string", ["\"bar\""]],
+			["punctuation", ")"],
+			["delimiter", ")"]
+		]],
+		"\""
+	]]
+]
+
+----------------------------------------------------
+
+Checks for strings and string interpolation.
\ No newline at end of file