Вход Регистрация
Файл: framework/thirdparty/jasmine-jstd-adapter/src/JasmineAdapter.js
Строк: 123
<?php
/**
 * @fileoverview Jasmine JsTestDriver Adapter.
 * @author ibolmo@gmail.com (Olmo Maldonado)
 * @author misko@hevery.com (Misko Hevery)
 */

(function(describeitbeforeEachafterEachaddResult){

var 
frame = function(parentname){
    var 
caseName '';
    if (
parent && parent.caseNamecaseName parent.caseName ' ';
    if (
namecaseName += name;

    var 
before = [],
        
after = [];

    return {
        
namename,
        
caseNamecaseName,
        
parentparent,
        
testCaseTestCase(caseName),
        
beforebefore,
        
afterafter,
        
runBefore: function(){
            if (
parentparent.runBefore.apply(this);
            for (var 
0before.lengthli++) before[i].apply(this);
        },
        
runAfter: function(){
            for (var 
0after.lengthli++) after[i].apply(this);
            if (
parentparent.runAfter.apply(this);
        }
    };
};

var 
currentFrame frame(nullnull);

jasmine.Env.prototype.describe = function(descriptioncontext){
    
currentFrame frame(currentFramedescription);
    var 
result describe.call(thisdescriptioncontext);
    
currentFrame currentFrame.parent;
    return 
result;
};
  
jasmine.Env.prototype.it = function(descriptionclosure){
    var 
result it.call(thisdescriptionclosure),
        
currentSpec this.currentSpec,
        
frame this.jstdFrame currentFrame,
        
name 'test that it ' description;

    if (
this.jstdFrame.testCase.prototype[name])
        throw 
"Spec with name '" description "' already exists.";
    
    
this.jstdFrame.testCase.prototype[name] = function(){
        
jasmine.getEnv().currentSpec currentSpec;
        
frame.runBefore.apply(currentSpec);
        try {
            
currentSpec.queue.start();
        } finally {
          
frame.runAfter.apply(currentSpec);
        }
    };
    return 
result;
};

jasmine.Env.prototype.beforeEach = function(closure) {
    
beforeEach.call(thisclosure);
    
currentFrame.before.push(closure);
};

jasmine.Env.prototype.afterEach = function(closure) {
    
afterEach.call(thisclosure);
    
currentFrame.after.push(closure);
};

jasmine.NestedResults.prototype.addResult = function(result) {
    
addResult.call(thisresult);
    if (
result.type != 'MessageResult' && !result.passed()) fail(result.message);
};

// @reesd - Disable the catch on exceptions when using JSTD, we want them to make it up to JSTD
jasmine.Block.prototype.execute = function(onComplete) {
    try {
        
this.func.apply(this.spec);
    } finally {
        
onComplete();
    }
};

// Reset environment with overriden methods.
jasmine.currentEnv_ null;
jasmine.getEnv();

})(
jasmine.Env.prototype.describejasmine.Env.prototype.itjasmine.Env.prototype.beforeEachjasmine.Env.prototype.afterEachjasmine.NestedResults.prototype.addResult);
?>
Онлайн: 0
Реклама