Skip to content

Instantly share code, notes, and snippets.

@hzr
Created August 13, 2012 12:18
Show Gist options
  • Select an option

  • Save hzr/3340118 to your computer and use it in GitHub Desktop.

Select an option

Save hzr/3340118 to your computer and use it in GitHub Desktop.

Revisions

  1. hzr revised this gist Aug 13, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ function test() {
    var g1 = f(function(){ this.x = 2; return {y: 3}; });
    for (var i = 0; i < 50; i++) {
    if ((new g1(2)).x !== undefined)
    throw i;
    throw Error();
    }
    }

  2. hzr created this gist Aug 13, 2012.
    20 changes: 20 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    function test() {
    function testApply() {
    function f(a) { return function() { return a.apply(this, arguments); }}
    var g1 = f(function(){ this.x = 2; return {y: 3}; });
    for (var i = 0; i < 50; i++) {
    if ((new g1(2)).x !== undefined)
    throw i;
    }
    }

    try {
    for (var c = 0; c < 100; c++) {
    testApply();
    }
    } catch(e) {
    return false;
    }

    return true;
    }