22
spec/helpers/generator.js
Normal file
22
spec/helpers/generator.js
Normal file
@@ -0,0 +1,22 @@
|
||||
(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());
|
||||
Reference in New Issue
Block a user