aggregate the tests in library-tests/TypeScript/TypeVariableTypes into a single .ql file

This commit is contained in:
Erik Krogh Kristensen
2020-10-14 13:06:06 +02:00
parent a667b69d91
commit 1e76471791
16 changed files with 71 additions and 57 deletions

View File

@@ -1,2 +0,0 @@
| T | GenericMethods.T in global scope |
| T | Repeated.T in global scope |

View File

@@ -1,4 +0,0 @@
import javascript
from CanonicalTypeVariableType type
select type, type.getCanonicalName()

View File

@@ -1,3 +0,0 @@
| D | D |
| E | E |
| S | S |

View File

@@ -1,4 +0,0 @@
import javascript
from LexicalTypeVariableType type
select type, type.getName()

View File

@@ -1,7 +0,0 @@
| <D>(x: D): D | 1 | 0 | D | no bound |
| <E>(x: () => E): E | 1 | 0 | E | no bound |
| <E>(x: E[] \| (() => E)): E | 1 | 0 | E | no bound |
| <E>(x: E[]): E | 1 | 0 | E | no bound |
| <S extends any[]>(x: S, y: T[]): S | 1 | 0 | S | any[] |
| <S>(x: S, y: S): S | 1 | 0 | S | no bound |
| <S>(x: S, y: T): [S, T] | 1 | 0 | S | no bound |

View File

@@ -1,12 +0,0 @@
import javascript
string getBound(CallSignatureType sig, int n) {
result = sig.getTypeParameterBound(n).toString()
or
not exists(sig.getTypeParameterBound(n)) and
result = "no bound" and
n = [0 .. sig.getNumTypeParameter() - 1]
}
from CallSignatureType sig, int n
select sig, sig.getNumTypeParameter(), n, sig.getTypeParameterName(n), getBound(sig, n)

View File

@@ -1,2 +0,0 @@
| Apple.this | Apple |
| Banana.this | Banana |

View File

@@ -1,4 +0,0 @@
import javascript
from ThisType type
select type, type.getEnclosingType()

View File

@@ -1,2 +0,0 @@
| T | GenericMethods.T in global scope |
| T | Repeated.T in global scope |

View File

@@ -1,4 +0,0 @@
import javascript
from TypeVariableType type
select type, type.getCanonicalName()

View File

@@ -1,3 +0,0 @@
| T | GenericMethods.T in global scope | tst.ts:22:26:22:26 | T |
| T | Repeated.T in global scope | tst.ts:3:20:3:20 | T |
| T | Repeated.T in global scope | tst.ts:7:20:7:20 | T |

View File

@@ -1,4 +0,0 @@
import javascript
from TypeVariableType tv
select tv, tv.getCanonicalName(), tv.getADeclaration()

View File

@@ -1,2 +0,0 @@
| T | GenericMethods.T in global scope | GenericMethods in global scope |
| T | Repeated.T in global scope | Repeated in global scope |

View File

@@ -1,4 +0,0 @@
import javascript
from TypeVariableType type
select type, type.getCanonicalName(), type.getHostType()

View File

@@ -0,0 +1,28 @@
canonicalTypeVariableType
| T | GenericMethods.T in global scope |
| T | Repeated.T in global scope |
lexicalTypeVariableType
| D | D |
| E | E |
| S | S |
signatureTypeParameters
| <D>(x: D): D | 0 | 1 | D | no bound |
| <E>(x: () => E): E | 0 | 1 | E | no bound |
| <E>(x: E[] \| (() => E)): E | 0 | 1 | E | no bound |
| <E>(x: E[]): E | 0 | 1 | E | no bound |
| <S extends any[]>(x: S, y: T[]): S | 0 | 1 | S | any[] |
| <S>(x: S, y: S): S | 0 | 1 | S | no bound |
| <S>(x: S, y: T): [S, T] | 0 | 1 | S | no bound |
thisType
| Apple.this | Apple |
| Banana.this | Banana |
typeVariableCanonicalNames
| T | GenericMethods.T in global scope |
| T | Repeated.T in global scope |
typeVariableDecl
| T | GenericMethods.T in global scope | tst.ts:22:26:22:26 | T |
| T | Repeated.T in global scope | tst.ts:3:20:3:20 | T |
| T | Repeated.T in global scope | tst.ts:7:20:7:20 | T |
typeVariableHost
| T | GenericMethods.T in global scope | GenericMethods in global scope |
| T | Repeated.T in global scope | Repeated in global scope |

View File

@@ -0,0 +1,43 @@
import javascript
query predicate canonicalTypeVariableType(CanonicalTypeVariableType type, CanonicalName name) {
type.getCanonicalName() = name
}
query predicate lexicalTypeVariableType(LexicalTypeVariableType type, string name) {
type.getName() = name
}
string getBound(CallSignatureType sig, int n) {
result = sig.getTypeParameterBound(n).toString()
or
not exists(sig.getTypeParameterBound(n)) and
result = "no bound" and
n = [0 .. sig.getNumTypeParameter() - 1]
}
query predicate signatureTypeParameters(
CallSignatureType sig, int n, int numTypeParam, string paramName, string bound
) {
sig.getNumTypeParameter() = numTypeParam and
sig.getTypeParameterName(n) = paramName and
bound = getBound(sig, n)
}
query predicate thisType(ThisType type, TypeReference enclosing) {
type.getEnclosingType() = enclosing
}
query predicate typeVariableCanonicalNames(TypeVariableType type, CanonicalName name) {
type.getCanonicalName() = name
}
query predicate typeVariableDecl(TypeVariableType tv, CanonicalName name, TypeParameter decl) {
tv.getCanonicalName() = name and
tv.getADeclaration() = decl
}
query predicate typeVariableHost(TypeVariableType type, CanonicalName name, TypeName hostType) {
type.getCanonicalName() = name and
type.getHostType() = hostType
}