Skip to content

Commit 23004ff

Browse files
committed
JS: Add underlyingType test
1 parent 5886a87 commit 23004ff

File tree

10 files changed

+83
-0
lines changed

10 files changed

+83
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from 'express';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Request, Response } from './expressBuilkExport';
2+
3+
function t1(req: Request) { // $ MISSING: hasUnderlyingType='express'.Request
4+
}
5+
6+
function t2(res: Response) { // $ MISSING: hasUnderlyingType='express'.Response
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Request } from 'express';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Request, Response } from './expressSelectiveExport';
2+
3+
function t1(req: Request) { // $ MISSING: hasUnderlyingType='express'.Request
4+
}
5+
6+
function t2(res: Response) { // none, not exported
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as wrapper from 'express';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Request, Response, wrapper } from './expressWrapperExport';
2+
import * as w from './expressWrapperExport';
3+
4+
function t1(req: Request) { // none
5+
}
6+
7+
function t2(res: Response) { // none
8+
}
9+
10+
function t3(req: wrapper.Request) { // $ MISSING: hasUnderlyingType='express'.Request
11+
}
12+
13+
function t4(res: wrapper.Response) { // $ MISSING: hasUnderlyingType='express'.Response
14+
}
15+
16+
function t5(req: w.wrapper.Request) { // $ MISSING: hasUnderlyingType='express'.Request
17+
}
18+
19+
function t6(res: w.wrapper.Response) { // $ MISSING: hasUnderlyingType='express'.Response
20+
}
21+
22+
function t7(req: w.Request) { // none
23+
}
24+
25+
function t8(res: w.Response) { // none
26+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Request } from 'express';
2+
3+
function t1(req: Request) { // $ hasUnderlyingType='express'.Request
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as express from 'express';
2+
3+
function t1(e: typeof express) { // $ MISSING: hasUnderlyingType='express'
4+
}
5+
6+
function t2(req: express.Request) { // $ hasUnderlyingType='express'.Request
7+
}
8+
9+
function t3(req: Request) { // none, not in scope
10+
}

javascript/ql/test/library-tests/UnderlyingTypes/test.expected

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import javascript
2+
private import utils.test.InlineExpectationsTest
3+
4+
bindingset[x, y]
5+
private string join(string x, string y) {
6+
if x = "" or y = "" then result = x + y else result = x + "." + y
7+
}
8+
9+
module TestConfig implements TestSig {
10+
string getARelevantTag() { result = "hasUnderlyingType" }
11+
12+
predicate hasActualResult(Location location, string element, string tag, string value) {
13+
element = "" and
14+
tag = "hasUnderlyingType" and
15+
exists(DataFlow::SourceNode sn | location = sn.getLocation() |
16+
sn.hasUnderlyingType(value)
17+
or
18+
exists(string mod, string name |
19+
sn.hasUnderlyingType(mod, name) and
20+
value = join("'" + mod + "'", name)
21+
)
22+
)
23+
}
24+
}
25+
26+
import MakeTest<TestConfig>

0 commit comments

Comments
 (0)