sidhant-guliani / script-cover

Automatically exported from code.google.com/p/script-cover
Apache License 2.0
0 stars 0 forks source link

Doesn't trace some class methods #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Classes generated by the CoffeeScript translator aren't traced, for example

class Foo
  constructor: (x, y) ->
    @z = x + y
  method: ->
    # some code
    @z
f = new Foo(1,2)
f.method()

generates

+  Foo = function(){
+    function Foo(x, y) {
-      this.z = x + y
+    }
+    Foo.prototype.method = function() {
-      ...
-      return this.z
+    }
+    return Foo
+  }();

The lines marked with "-" are not shown as covered even though they have been 
executed.

Original issue reported on code.google.com by funkycoder@gmail.com on 17 Nov 2011 at 8:38

GoogleCodeExporter commented 8 years ago
Hi,
have you called Foo constructor and method? Seems like the calls weren't 
generated.
Lines you marked with "-" aren't executed until these functions are called.

+  Foo = function(){
+    function Foo(x, y) {
-      this.z = x + y // will be executed when constructor is called
+    }
+    Foo.prototype.method = function() {
-      ...
-      return this.z // will be executed when method is called
+    }
+    return Foo // has been executed, as the anonymous function was called
+  }();
// calls of the constructor and the method should be here

Original comment by hellom...@gmail.com on 10 Dec 2011 at 6:19