travis-ci
4670 of 5656 branches covered (82.57%)
13 of 13 new or added lines in 2 files covered. (100.0%)
10412 of 11525 relevant lines covered (90.34%)
5850.54 hits per line
1 |
"use strict";
|
|
2 |
|
|
3 |
var Node = require("./Node"); |
19 only 2387.2 ✔ |
4 |
|
|
5 |
class Return extends Node { |
|
6 |
constructor(def) { |
|
7 |
super("Return"); |
2,047 only 2387.2 ✔ |
8 |
this.argument = def.argument;
|
2,047 only 2387.2 ✔ |
9 |
} |
|
10 |
|
|
11 |
generateCode(codegen) { |
|
12 |
if (!codegen.inFunction) {
|
|
13 |
throw new Error('"return" not allowed outside a function body'); |
1 only 2387.2 ✔ |
14 |
} |
|
15 |
|
|
16 |
this.argument = codegen.generateCode(this.argument); |
1,421 only 2387.2 ✔ |
17 |
return this; |
1,421 only 2387.2 ✔ |
18 |
} |
|
19 |
|
|
20 |
writeCode(writer) { |
|
21 |
var argument = this.argument; |
1,411 only 2387.2 ✔ |
22 |
|
|
23 |
if (argument) {
|
|
24 |
writer.write("return ");
|
1,409 only 2387.2 ✔ |
25 |
writer.write(argument); |
1,409 only 2387.2 ✔ |
26 |
} else {
|
|
27 |
writer.write("return");
|
2 only 2387.2 ✔ |
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
walk(walker) { |
|
32 |
this.argument = walker.walk(this.argument); |
× |
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
module.exports = Return; |
19 only 2387.2 ✔ |