Skip to content

Instantly share code, notes, and snippets.

@ckknight
Created June 19, 2013 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckknight/5812838 to your computer and use it in GitHub Desktop.
Save ckknight/5812838 to your computer and use it in GitHub Desktop.
GorillaScript coverage example
try {
if (typeof top === "object" && top !== null && typeof top.opener === "object" && top.opener !== null && !top.opener._$jscoverage) {
top.opener._$jscoverage = {};
}
} catch (e) {}
try {
if (typeof top === "object" && top !== null) {
try {
if (typeof top.opener === "object" && top.opener !== null && top.opener._$jscoverage) {
top._$jscoverage = top.opener._$jscoverage;
}
} catch (e) {}
if (!top._$jscoverage) {
top._$jscoverage = {};
}
}
} catch (e) {}
try {
if (typeof top === "object" && top !== null) {
top._$jscoverage;
}
} catch (e) {}
if (typeof _$jscoverage !== "object") {
_$jscoverage = {};
}
if (!_$jscoverage["test/tmp.gs"]) {
(function () {
var cov, i, lines;
_$jscoverage["test/tmp.gs"] = cov = [];
for (i = 0, lines = [
2,
3,
5,
7,
8
]; i < 5; ++i) {
cov[lines[i]] = 0;
}
cov.source = [
"let fun(value)",
" if value",
' console.log "We\'re having fun"',
" else",
' console.log "No fun for you!"',
"",
"fun(true)",
"fun(false)"
];
}());
}
(function () {
"use strict";
function fun(value) {
++_$jscoverage["test/tmp.gs"][2];
if (value) {
++_$jscoverage["test/tmp.gs"][3];
return console.log("We're having fun");
} else {
++_$jscoverage["test/tmp.gs"][5];
return console.log("No fun for you!");
}
}
++_$jscoverage["test/tmp.gs"][7];
fun(true);
++_$jscoverage["test/tmp.gs"][8];
fun(false);
}.call(this));
let fun(value)
if value
console.log "We're having fun"
else
console.log "No fun for you!"
fun(true)
fun(false)
(function () {
"use strict";
function fun(value) {
if (value) {
return console.log("We're having fun");
} else {
return console.log("No fun for you!");
}
}
fun(true);
fun(false);
}.call(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment