| 1 |
/*jslint nomen: true */ |
| 2 |
var helper = require('../helper'), |
| 3 |
code, |
| 4 |
verifier; |
| 5 |
|
| 6 |
if (require('../es6').isSuperAvailable()) { |
| 7 |
module.exports = { |
| 8 |
'should cover super in constructor': function (test) { |
| 9 |
code = [ |
| 10 |
'class A {', |
| 11 |
' constructor(x) {', |
| 12 |
' this.x = x;', |
| 13 |
' }', |
| 14 |
' getX() {', |
| 15 |
' return "x";', |
| 16 |
' }', |
| 17 |
'}', |
| 18 |
'class B extends A {', |
| 19 |
' constructor(x) {', |
| 20 |
' super(x);', |
| 21 |
' }', |
| 22 |
' getX() {', |
| 23 |
' return this.x;', |
| 24 |
' }', |
| 25 |
'}', |
| 26 |
'output = (new B("super")).getX();' |
| 27 |
]; |
| 28 |
verifier = helper.verifier(__filename, code); |
| 29 |
verifier.verify(test, ['super'], 'super', { |
| 30 |
lines: { 3: 1, 6: 0, 11: 1, 14: 1, 17: 1 }, |
| 31 |
branches: {}, |
| 32 |
functions: { 1: 1, 2: 0, 3: 1, 4: 1 }, |
| 33 |
statements: { 1: 1, 2: 0, 3: 1, 4: 1, 5: 1 } |
| 34 |
}); |
| 35 |
test.done(); |
| 36 |
}, |
| 37 |
'should cover super in method': function (test) { |
| 38 |
code = [ |
| 39 |
'class A {', |
| 40 |
' constructor(x) {', |
| 41 |
' this.x = x;', |
| 42 |
' }', |
| 43 |
' getX() {', |
| 44 |
' return "x";', |
| 45 |
' }', |
| 46 |
'}', |
| 47 |
'class B extends A {', |
| 48 |
' constructor(x) {', |
| 49 |
' super(x);', |
| 50 |
' }', |
| 51 |
' getX() {', |
| 52 |
' return super.getX();', |
| 53 |
' }', |
| 54 |
'}', |
| 55 |
'output = (new B("super")).getX();' |
| 56 |
]; |
| 57 |
verifier = helper.verifier(__filename, code); |
| 58 |
verifier.verify(test, ['super'], 'x', { |
| 59 |
lines: { 3: 1, 6: 1, 11: 1, 14: 1, 17: 1 }, |
| 60 |
branches: {}, |
| 61 |
functions: { 1: 1, 2: 1, 3: 1, 4: 1 }, |
| 62 |
statements: { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1 } |
| 63 |
}); |
| 64 |
test.done(); |
| 65 |
} |
| 66 |
}; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|