Files
jasmine/spec/helpers/generator.js
2020-08-29 13:15:14 -07:00

23 lines
542 B
JavaScript

(function(env) {
function getGeneratorFuncCtor() {
try {
eval('var func = function*() {}');
} catch (e) {
return null;
}
return Object.getPrototypeOf(func).constructor;
}
env.makeGeneratorFunction = function(text) {
var GeneratorFunction = getGeneratorFuncCtor();
return new GeneratorFunction(text || '');
};
env.requireGeneratorFunctions = function() {
if (!getGeneratorFuncCtor()) {
env.pending('Environment does not support generator functions');
}
};
})(jasmine.getEnv());