JS: Add more tests for implicit returns

This commit is contained in:
Asger Feldthaus
2020-05-01 08:39:48 +01:00
parent 6a63f5b677
commit eddbdffe62
5 changed files with 48 additions and 0 deletions

View File

@@ -168,6 +168,16 @@
| h.js:2:23:2:22 | default constructor of class C |
| h_import.js:1:1:3:0 | exports object of module h_import |
| h_import.js:1:1:3:0 | module object of module h_import |
| implicit-returns.js:1:1:27:0 | exports object of module implicit-returns |
| implicit-returns.js:1:1:27:0 | module object of module implicit-returns |
| implicit-returns.js:3:1:12:1 | function endWithLoop |
| implicit-returns.js:3:1:12:1 | instance of function endWithLoop |
| implicit-returns.js:14:1:16:1 | function useLoop |
| implicit-returns.js:14:1:16:1 | instance of function useLoop |
| implicit-returns.js:18:1:22:1 | function endWithShortIf |
| implicit-returns.js:18:1:22:1 | instance of function endWithShortIf |
| implicit-returns.js:24:1:26:1 | function useShortIf |
| implicit-returns.js:24:1:26:1 | instance of function useShortIf |
| import.js:1:1:13:0 | exports object of module import |
| import.js:1:1:13:0 | module object of module import |
| imports.ts:1:1:8:0 | exports object of module imports |

View File

@@ -142,6 +142,11 @@
| globals.html:26:52:26:53 | x2 | globals.html:26:57:26:66 | someGlobal | file://:0:0:0:0 | non-zero value |
| globals.html:26:52:26:53 | x2 | globals.html:26:57:26:66 | someGlobal | file://:0:0:0:0 | true |
| h_import.js:2:5:2:6 | ff | h_import.js:2:10:2:10 | f | h.js:1:8:1:22 | function f |
| implicit-returns.js:4:9:4:9 | i | implicit-returns.js:4:13:4:13 | 0 | file://:0:0:0:0 | 0 |
| implicit-returns.js:15:9:15:9 | x | implicit-returns.js:15:13:15:25 | endWithLoop() | file://:0:0:0:0 | true |
| implicit-returns.js:15:9:15:9 | x | implicit-returns.js:15:13:15:25 | endWithLoop() | file://:0:0:0:0 | undefined |
| implicit-returns.js:25:9:25:9 | x | implicit-returns.js:25:13:25:28 | endWithShortIf() | file://:0:0:0:0 | true |
| implicit-returns.js:25:9:25:9 | x | implicit-returns.js:25:13:25:28 | endWithShortIf() | file://:0:0:0:0 | undefined |
| import.js:2:5:2:5 | m | import.js:2:9:2:13 | mixin | mixins.js:1:16:1:32 | anonymous function |
| import.js:5:5:5:7 | myf | import.js:5:11:5:11 | f | n.js:1:1:1:15 | function f |
| import.js:8:5:8:11 | someVar | import.js:8:15:8:23 | someStuff | file://:0:0:0:0 | indefinite value (call) |

View File

@@ -30,6 +30,10 @@
| globals.html:22:7:22:21 | instance of function x | globals.html:22:7:22:21 | instance of function x |
| globals.html:26:23:26:69 | instance of anonymous function | globals.html:26:23:26:69 | instance of anonymous function |
| h.js:1:8:1:22 | instance of function f | h.js:1:8:1:22 | instance of function f |
| implicit-returns.js:3:1:12:1 | instance of function endWithLoop | implicit-returns.js:3:1:12:1 | instance of function endWithLoop |
| implicit-returns.js:14:1:16:1 | instance of function useLoop | implicit-returns.js:14:1:16:1 | instance of function useLoop |
| implicit-returns.js:18:1:22:1 | instance of function endWithShortIf | implicit-returns.js:18:1:22:1 | instance of function endWithShortIf |
| implicit-returns.js:24:1:26:1 | instance of function useShortIf | implicit-returns.js:24:1:26:1 | instance of function useShortIf |
| instances.js:1:1:4:1 | instance of function A | instances.js:1:1:4:1 | instance of function A |
| instances.js:3:14:3:26 | instance of anonymous function | instances.js:3:14:3:26 | instance of anonymous function |
| instances.js:6:19:6:31 | instance of anonymous function | instances.js:6:19:6:31 | instance of anonymous function |

View File

@@ -0,0 +1,26 @@
import 'dummy';
function endWithLoop() {
var i = 0;
while (i < 10) {
if (Math.random() * 10 < i) {
return true;
}
++i;
}
// Can fall over end
}
function useLoop() {
let x = endWithLoop(); // can be true or undefined
}
function endWithShortIf() {
if (something() < 10) {
return true;
}
}
function useShortIf() {
let x = endWithShortIf(); // true or undefined
}

View File

@@ -78,6 +78,9 @@
| globals.html:26:40:26:41 | x1 | globals.html:26:45:26:45 | x | boolean, class, date, function, null, number, object, regular expression,string or undefined |
| globals.html:26:52:26:53 | x2 | globals.html:26:57:26:66 | someGlobal | boolean, class, date, function, null, number, object, regular expression,string or undefined |
| h_import.js:2:5:2:6 | ff | h_import.js:2:10:2:10 | f | function |
| implicit-returns.js:4:9:4:9 | i | implicit-returns.js:4:13:4:13 | 0 | number |
| implicit-returns.js:15:9:15:9 | x | implicit-returns.js:15:13:15:25 | endWithLoop() | boolean or undefined |
| implicit-returns.js:25:9:25:9 | x | implicit-returns.js:25:13:25:28 | endWithShortIf() | boolean or undefined |
| import.js:2:5:2:5 | m | import.js:2:9:2:13 | mixin | function |
| import.js:5:5:5:7 | myf | import.js:5:11:5:11 | f | function |
| import.js:8:5:8:11 | someVar | import.js:8:15:8:23 | someStuff | boolean, class, date, function, null, number, object, regular expression,string or undefined |