Skip to content

Commit 9588e68

Browse files
committed
Swift: Add detail and spacing to the NoominalType tests.
1 parent 8438fb2 commit 9588e68

File tree

5 files changed

+58
-29
lines changed

5 files changed

+58
-29
lines changed
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
| nominaltype.swift:35:6:35:6 | a | A | A | |
2-
| nominaltype.swift:36:6:36:6 | a_alias | A_alias | A | getAliasedType:A |
3-
| nominaltype.swift:37:6:37:6 | a_optional_alias | A_optional_alias | A? | getAliasedType:A? |
4-
| nominaltype.swift:38:6:38:6 | b1 | B1 | B1 | getABaseType:A |
5-
| nominaltype.swift:39:6:39:6 | b2 | B2 | B2 | getABaseType:A_alias |
6-
| nominaltype.swift:40:6:40:6 | b1_alias | B1_alias | B1 | getABaseType:A, getAliasedType:B1 |
7-
| nominaltype.swift:41:6:41:6 | b2_alias | B2_alias | B2 | getABaseType:A_alias, getAliasedType:B2 |
8-
| nominaltype.swift:42:6:42:6 | p | P | P | |
9-
| nominaltype.swift:43:6:43:6 | p_alias | P_alias | P_alias | |
10-
| nominaltype.swift:44:6:44:6 | c1 | C1 | C1 | getABaseType:P |
11-
| nominaltype.swift:45:6:45:6 | c2 | C2 | C2 | getABaseType:P_alias |
12-
| nominaltype.swift:46:6:46:6 | c1_alias | C1_alias | C1 | getABaseType:P, getAliasedType:C1 |
13-
| nominaltype.swift:47:6:47:6 | c2_alias | C2_alias | C2 | getABaseType:P_alias, getAliasedType:C2 |
1+
| nominaltype.swift:54:6:54:6 | a | A | getFullName:A, getName:A, getUnderlyingType:A |
2+
| nominaltype.swift:55:6:55:6 | a_alias | A_alias | getAliasedType:A, getName:A_alias, getUnderlyingType:A |
3+
| nominaltype.swift:56:6:56:6 | a_optional_alias | A_optional_alias | getAliasedType:A?, getName:A_optional_alias, getUnderlyingType:A? |
4+
| nominaltype.swift:57:6:57:6 | b1 | B1 | getABaseType:A, getFullName:B1, getName:B1, getUnderlyingType:B1 |
5+
| nominaltype.swift:58:6:58:6 | b2 | B2 | getABaseType:A_alias, getFullName:B2, getName:B2, getUnderlyingType:B2 |
6+
| nominaltype.swift:59:6:59:6 | b1_alias | B1_alias | getABaseType:A, getAliasedType:B1, getName:B1_alias, getUnderlyingType:B1 |
7+
| nominaltype.swift:60:6:60:6 | b2_alias | B2_alias | getABaseType:A_alias, getAliasedType:B2, getName:B2_alias, getUnderlyingType:B2 |
8+
| nominaltype.swift:61:6:61:6 | p | P | getName:P, getUnderlyingType:P |
9+
| nominaltype.swift:62:6:62:6 | p_alias | P_alias | getName:P_alias, getUnderlyingType:P_alias |
10+
| nominaltype.swift:63:6:63:6 | c1 | C1 | getABaseType:P, getFullName:C1, getName:C1, getUnderlyingType:C1 |
11+
| nominaltype.swift:64:6:64:6 | c2 | C2 | getABaseType:P_alias, getFullName:C2, getName:C2, getUnderlyingType:C2 |
12+
| nominaltype.swift:65:6:65:6 | c1_alias | C1_alias | getABaseType:P, getAliasedType:C1, getName:C1_alias, getUnderlyingType:C1 |
13+
| nominaltype.swift:66:6:66:6 | c2_alias | C2_alias | getABaseType:P_alias, getAliasedType:C2, getName:C2_alias, getUnderlyingType:C2 |
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import swift
22

33
string describe(Type t) {
4-
result = "getAliasedType:" + t.(TypeAliasType).getAliasedType()
4+
result = "getName:" + t.getName()
55
or
6-
result = "getABaseType:" + t.getABaseType()
6+
result = "getFullName:" + t.(NominalType).getFullName()
7+
or
8+
result = "getUnderlyingType:" + t.getUnderlyingType().toString()
9+
or
10+
result = "getAliasedType:" + t.(TypeAliasType).getAliasedType().toString()
11+
or
12+
result = "getABaseType:" + t.getABaseType().toString()
713
}
814

915
from VarDecl v, Type t
1016
where
1117
v.getLocation().getFile().getBaseName() != "" and
1218
not v.getName() = "self" and
1319
t = v.getType()
14-
select v, t.toString(), t.getUnderlyingType(), concat(describe(t), ", ")
20+
select v, t.toString(), concat(describe(t), ", ")

swift/ql/test/library-tests/elements/type/nominaltype/nominaltype.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ typealias C1_alias = C1
3131

3232
typealias C2_alias = C2
3333

34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
3453
func test() {
3554
var a : A
3655
var a_alias : A_alias
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
| nominaltype.swift:35:6:35:6 | a | A | |
2-
| nominaltype.swift:36:6:36:6 | a_alias | A_alias | getAliasedType:A |
3-
| nominaltype.swift:37:6:37:6 | a_optional_alias | A_optional_alias | getAliasedType:A? |
4-
| nominaltype.swift:38:6:38:6 | b1 | B1 | getABaseType:A |
5-
| nominaltype.swift:39:6:39:6 | b2 | B2 | getABaseType:A_alias |
6-
| nominaltype.swift:40:6:40:6 | b1_alias | B1_alias | getAliasedType:B1 |
7-
| nominaltype.swift:41:6:41:6 | b2_alias | B2_alias | getAliasedType:B2 |
8-
| nominaltype.swift:44:6:44:6 | c1 | C1 | getABaseType:P |
9-
| nominaltype.swift:45:6:45:6 | c2 | C2 | getABaseType:P_alias |
10-
| nominaltype.swift:46:6:46:6 | c1_alias | C1_alias | getAliasedType:C1 |
11-
| nominaltype.swift:47:6:47:6 | c2_alias | C2_alias | getAliasedType:C2 |
1+
| nominaltype.swift:54:6:54:6 | a | A | getFullName:A, getName:A |
2+
| nominaltype.swift:55:6:55:6 | a_alias | A_alias | getAliasedType:A, getFullName:A_alias, getName:A_alias |
3+
| nominaltype.swift:56:6:56:6 | a_optional_alias | A_optional_alias | getAliasedType:A?, getFullName:A_optional_alias, getName:A_optional_alias |
4+
| nominaltype.swift:57:6:57:6 | b1 | B1 | getABaseType:A, getFullName:B1, getName:B1 |
5+
| nominaltype.swift:58:6:58:6 | b2 | B2 | getABaseType:A_alias, getFullName:B2, getName:B2 |
6+
| nominaltype.swift:59:6:59:6 | b1_alias | B1_alias | getAliasedType:B1, getFullName:B1_alias, getName:B1_alias |
7+
| nominaltype.swift:60:6:60:6 | b2_alias | B2_alias | getAliasedType:B2, getFullName:B2_alias, getName:B2_alias |
8+
| nominaltype.swift:63:6:63:6 | c1 | C1 | getABaseType:P, getFullName:C1, getName:C1 |
9+
| nominaltype.swift:64:6:64:6 | c2 | C2 | getABaseType:P_alias, getFullName:C2, getName:C2 |
10+
| nominaltype.swift:65:6:65:6 | c1_alias | C1_alias | getAliasedType:C1, getFullName:C1_alias, getName:C1_alias |
11+
| nominaltype.swift:66:6:66:6 | c2_alias | C2_alias | getAliasedType:C2, getFullName:C2_alias, getName:C2_alias |

swift/ql/test/library-tests/elements/type/nominaltype/nominaltypedecl.ql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import swift
22

33
string describe(TypeDecl td) {
4-
result = "getAliasedType:" + td.(TypeAliasDecl).getAliasedType()
4+
result = "getName:" + td.getName()
55
or
6-
result = "getABaseType:" + td.(NominalTypeDecl).getABaseType()
6+
result = "getFullName:" + td.getFullName()
7+
or
8+
result = "getAliasedType:" + td.(TypeAliasDecl).getAliasedType().toString()
9+
or
10+
result = "getABaseType:" + td.(NominalTypeDecl).getABaseType().toString()
711
}
812

913
from VarDecl v, TypeDecl td

0 commit comments

Comments
 (0)