Skip to content

Commit 94cb09e

Browse files
committed
Swift: Add test cases.
1 parent 8be6aed commit 94cb09e

File tree

1 file changed

+34
-0
lines changed
  • swift/ql/test/library-tests/dataflow/flowsources

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
// --- stubs ---
3+
4+
struct URL {
5+
init?(string: String) {}
6+
}
7+
8+
class MyClass {
9+
init(contentsOfFile: String) { }
10+
init(contentsOfFile: String?, options: [Int]) { }
11+
init(contentsOf: URL, fileTypeHint: Int) { }
12+
13+
init(contentsOfPath: String) { }
14+
init(contentsOfDirectory: String) { }
15+
16+
func append(contentsOf: String) { }
17+
func appending(contentsOf: String) -> MyClass { return self }
18+
}
19+
20+
// --- tests ---
21+
22+
func testCustom() {
23+
let url = URL(string: "http://example.com/")!
24+
25+
let x = MyClass(contentsOfFile: "foo.txt") // $ MISSING: source=remote
26+
_ = MyClass(contentsOfFile: "foo.txt", options: []) // $ MISSING: source=remote
27+
_ = MyClass(contentsOf: url, fileTypeHint: 1) // $ MISSING: source=remote
28+
29+
_ = MyClass(contentsOfPath: "/foo/bar") // $ MISSING: source=remote
30+
_ = MyClass(contentsOfDirectory: "/foo/bar") // $ MISSING: source=remote
31+
32+
x.append(contentsOf: "abcdef") // (not a flow source)
33+
_ = x.appending(contentsOf: "abcdef") // (not a flow source)
34+
}

0 commit comments

Comments
 (0)