bsed / js-test-driver

Automatically exported from code.google.com/p/js-test-driver
0 stars 0 forks source link

get & set syntax in object initializers with coverage plugin #361

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
To reproduce, use this code:
       a = {
            get b(){ return _b+1;},
            set b(value){ _b = value;}
        };

the correct output in instrumented file must be something like:
LCOV_1d[1]++; a = {
    get b(){ LCOV_1d[2]++; return _b+1;},
    set b(value){ LCOV_1d[3]++;_b = value;}
};

instead of this we got a :

line 4:8 missing COLON at 'b'
line 4:11 mismatched input '{' expecting RBRACE
line 4:8 missing COLON at 'b'
line 4:11 mismatched input '{' expecting RBRACE

in colsole, and randomly placed LCOV_1d[x]++; somethimes it is after 'set' 
token, sometimes - after _b, sometimes it adds LCOV_1d[x]++; between 'this' and 
'_b', if we use setter like:
set b(value) {this._b=value}
sometimes it stop adding LCOV_1d[x]++; after getter at all;

The exact result depends on where object initializer with such getter-setter 
creation occurs - on top-level, inside function, inside another object and so 
on;

for example, if we put this on top-level just at beginning of the js-file, it 
produces this:
LCOV_1d[1]++; a = {
    get b(){ LCOV_1d[2]++; return _b+1;},
    set b(value){ _b = value;}
};
and completely stop adding new LCOV_1d[]++; in this file

this is for coverage plugin v 1.3.4.b

Original issue reported on code.google.com by aulyanov...@spotware.com on 12 Apr 2012 at 9:13

GoogleCodeExporter commented 9 years ago
this is because of use a ES3 grammar for generate instrumentor inside a 
coverage plugin, not ES5.
And, in general, it will be good to update it to ES5 at all - may be were are 
more issues.

Original comment by aulyanov...@spotware.com on 12 Apr 2012 at 10:01

GoogleCodeExporter commented 9 years ago
This is becoming a deal breaker for my team.

Original comment by garri...@gmail.com on 26 Apr 2013 at 3:14