123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800 |
- define("amber_core/SUnit", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Infrastructure", "amber_core/Kernel-Classes"], function($boot){"use strict";
- var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
- $core.addPackage('SUnit');
- $core.packages["SUnit"].innerEval = function (expr) { return eval(expr); };
- $core.packages["SUnit"].transport = {"type":"amd","amdNamespace":"amber_core"};
- $core.addClass('ResultAnnouncement', $globals.Object, ['result'], 'SUnit');
- $globals.ResultAnnouncement.comment="I get signaled when a `TestCase` has been run.\x0a\x0aMy instances hold the result (instance of `TestResult`) of the test run.";
- $core.addMethod(
- $core.method({
- selector: "result",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@result"];
- },
- args: [],
- source: "result\x0a\x09^ result",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.ResultAnnouncement);
- $core.addMethod(
- $core.method({
- selector: "result:",
- protocol: 'accessing',
- fn: function (aTestResult){
- var self=this;
- self["@result"]=aTestResult;
- return self;
- },
- args: ["aTestResult"],
- source: "result: aTestResult\x0a\x09result := aTestResult",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.ResultAnnouncement);
- $core.addClass('TestCase', $globals.Object, ['testSelector', 'asyncTimeout', 'context'], 'SUnit');
- $globals.TestCase.comment="I am an implementation of the command pattern to run a test.\x0a\x0a## API\x0a\x0aMy instances are created with the class method `#selector:`,\x0apassing the symbol that names the method to be executed when the test case runs.\x0a\x0aWhen you discover a new fixture, subclass `TestCase` and create a `#test...` method for the first test.\x0aAs that method develops and more `#test...` methods are added, you will find yourself refactoring temps\x0ainto instance variables for the objects in the fixture and overriding `#setUp` to initialize these variables.\x0aAs required, override `#tearDown` to nil references, release objects and deallocate.";
- $core.addMethod(
- $core.method({
- selector: "assert:",
- protocol: 'testing',
- fn: function (aBoolean){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._assert_description_(aBoolean,"Assertion failed");
- return self;
- }, function($ctx1) {$ctx1.fill(self,"assert:",{aBoolean:aBoolean},$globals.TestCase)});
- },
- args: ["aBoolean"],
- source: "assert: aBoolean\x0a\x09self assert: aBoolean description: 'Assertion failed'",
- referencedClasses: [],
- messageSends: ["assert:description:"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "assert:description:",
- protocol: 'testing',
- fn: function (aBoolean,aString){
- var self=this;
- return $core.withContext(function($ctx1) {
- if(!$core.assert(aBoolean)){
- self._signalFailure_(aString);
- };
- return self;
- }, function($ctx1) {$ctx1.fill(self,"assert:description:",{aBoolean:aBoolean,aString:aString},$globals.TestCase)});
- },
- args: ["aBoolean", "aString"],
- source: "assert: aBoolean description: aString\x0a\x09aBoolean ifFalse: [ self signalFailure: aString ]",
- referencedClasses: [],
- messageSends: ["ifFalse:", "signalFailure:"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "assert:equals:",
- protocol: 'testing',
- fn: function (actual,expected){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1,$5,$4,$3,$2;
- $1=$recv(actual).__eq(expected);
- $5=$recv(expected)._printString();
- $ctx1.sendIdx["printString"]=1;
- $4="Expected: ".__comma($5);
- $3=$recv($4).__comma(" but was: ");
- $ctx1.sendIdx[","]=2;
- $2=$recv($3).__comma($recv(actual)._printString());
- $ctx1.sendIdx[","]=1;
- return self._assert_description_($1,$2);
- }, function($ctx1) {$ctx1.fill(self,"assert:equals:",{actual:actual,expected:expected},$globals.TestCase)});
- },
- args: ["actual", "expected"],
- source: "assert: actual equals: expected\x0a\x09^ self assert: (actual = expected) description: 'Expected: ', expected printString, ' but was: ', actual printString",
- referencedClasses: [],
- messageSends: ["assert:description:", "=", ",", "printString"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "async:",
- protocol: 'async',
- fn: function (aBlock){
- var self=this;
- var c;
- return $core.withContext(function($ctx1) {
- var $1;
- self._errorIfNotAsync_("#async");
- c=self["@context"];
- return (function(){
- return $core.withContext(function($ctx2) {
- $1=self._isAsync();
- if($core.assert($1)){
- return $recv(c)._execute_(aBlock);
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- });
- }, function($ctx1) {$ctx1.fill(self,"async:",{aBlock:aBlock,c:c},$globals.TestCase)});
- },
- args: ["aBlock"],
- source: "async: aBlock\x0a\x09| c |\x0a\x09self errorIfNotAsync: '#async'.\x0a\x09c := context.\x0a\x09^ [ self isAsync ifTrue: [ c execute: aBlock ] ]",
- referencedClasses: [],
- messageSends: ["errorIfNotAsync:", "ifTrue:", "isAsync", "execute:"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "context:",
- protocol: 'accessing',
- fn: function (aRunningTestContext){
- var self=this;
- self["@context"]=aRunningTestContext;
- return self;
- },
- args: ["aRunningTestContext"],
- source: "context: aRunningTestContext\x0a\x09context := aRunningTestContext",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "deny:",
- protocol: 'testing',
- fn: function (aBoolean){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._assert_($recv(aBoolean)._not());
- return self;
- }, function($ctx1) {$ctx1.fill(self,"deny:",{aBoolean:aBoolean},$globals.TestCase)});
- },
- args: ["aBoolean"],
- source: "deny: aBoolean\x0a\x09self assert: aBoolean not",
- referencedClasses: [],
- messageSends: ["assert:", "not"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "errorIfNotAsync:",
- protocol: 'error handling',
- fn: function (aString){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $1=self._isAsync();
- if(!$core.assert($1)){
- self._error_($recv(aString).__comma(" used without prior #timeout:"));
- };
- return self;
- }, function($ctx1) {$ctx1.fill(self,"errorIfNotAsync:",{aString:aString},$globals.TestCase)});
- },
- args: ["aString"],
- source: "errorIfNotAsync: aString\x0a\x09self isAsync ifFalse: [\x0a\x09\x09self error: aString, ' used without prior #timeout:' ]",
- referencedClasses: [],
- messageSends: ["ifFalse:", "isAsync", "error:", ","]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "finished",
- protocol: 'async',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._errorIfNotAsync_("#finished");
- self["@asyncTimeout"]=nil;
- return self;
- }, function($ctx1) {$ctx1.fill(self,"finished",{},$globals.TestCase)});
- },
- args: [],
- source: "finished\x0a\x09self errorIfNotAsync: '#finished'.\x0a\x09asyncTimeout := nil",
- referencedClasses: [],
- messageSends: ["errorIfNotAsync:"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "isAsync",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv(self["@asyncTimeout"])._notNil();
- }, function($ctx1) {$ctx1.fill(self,"isAsync",{},$globals.TestCase)});
- },
- args: [],
- source: "isAsync\x0a\x09^ asyncTimeout notNil",
- referencedClasses: [],
- messageSends: ["notNil"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "performTest",
- protocol: 'running',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- self["@asyncTimeout"]=nil;
- self._perform_(self._selector());
- return self;
- }, function($ctx1) {$ctx1.fill(self,"performTest",{},$globals.TestCase)});
- },
- args: [],
- source: "performTest\x0a\x09asyncTimeout := nil.\x0a\x09self perform: self selector",
- referencedClasses: [],
- messageSends: ["perform:", "selector"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "runCase",
- protocol: 'running',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv($recv($globals.TestContext)._testCase_(self))._start();
- return self;
- }, function($ctx1) {$ctx1.fill(self,"runCase",{},$globals.TestCase)});
- },
- args: [],
- source: "runCase\x0a\x09\x22Runs a test case in isolated context, leaking all errors.\x22\x0a\x0a\x09(TestContext testCase: self) start",
- referencedClasses: ["TestContext"],
- messageSends: ["start", "testCase:"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "selector",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@testSelector"];
- },
- args: [],
- source: "selector\x0a\x09^ testSelector",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "setTestSelector:",
- protocol: 'accessing',
- fn: function (aSelector){
- var self=this;
- self["@testSelector"]=aSelector;
- return self;
- },
- args: ["aSelector"],
- source: "setTestSelector: aSelector\x0a\x09testSelector := aSelector",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "setUp",
- protocol: 'running',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "setUp",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "should:",
- protocol: 'testing',
- fn: function (aBlock){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._assert_($recv(aBlock)._value());
- return self;
- }, function($ctx1) {$ctx1.fill(self,"should:",{aBlock:aBlock},$globals.TestCase)});
- },
- args: ["aBlock"],
- source: "should: aBlock\x0a\x09self assert: aBlock value",
- referencedClasses: [],
- messageSends: ["assert:", "value"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "should:raise:",
- protocol: 'testing',
- fn: function (aBlock,anExceptionClass){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._assert_($recv((function(){
- return $core.withContext(function($ctx2) {
- $recv(aBlock)._value();
- return false;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }))._on_do_(anExceptionClass,(function(ex){
- return true;
- })));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"should:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass},$globals.TestCase)});
- },
- args: ["aBlock", "anExceptionClass"],
- source: "should: aBlock raise: anExceptionClass\x0a\x09self assert: ([ aBlock value. false ]\x0a\x09\x09on: anExceptionClass\x0a\x09\x09do: [ :ex | true ])",
- referencedClasses: [],
- messageSends: ["assert:", "on:do:", "value"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "shouldnt:raise:",
- protocol: 'testing',
- fn: function (aBlock,anExceptionClass){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._assert_($recv((function(){
- return $core.withContext(function($ctx2) {
- $recv(aBlock)._value();
- return true;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }))._on_do_(anExceptionClass,(function(ex){
- return false;
- })));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"shouldnt:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass},$globals.TestCase)});
- },
- args: ["aBlock", "anExceptionClass"],
- source: "shouldnt: aBlock raise: anExceptionClass\x0a\x09self assert: ([ aBlock value. true ]\x0a\x09\x09on: anExceptionClass\x0a\x09\x09do: [ :ex | false ])",
- referencedClasses: [],
- messageSends: ["assert:", "on:do:", "value"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "signalFailure:",
- protocol: 'private',
- fn: function (aString){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $1=$recv($globals.TestFailure)._new();
- $recv($1)._messageText_(aString);
- $recv($1)._signal();
- return self;
- }, function($ctx1) {$ctx1.fill(self,"signalFailure:",{aString:aString},$globals.TestCase)});
- },
- args: ["aString"],
- source: "signalFailure: aString\x0a\x09TestFailure new\x0a\x09\x09messageText: aString;\x0a\x09\x09signal",
- referencedClasses: ["TestFailure"],
- messageSends: ["messageText:", "new", "signal"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "tearDown",
- protocol: 'running',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "tearDown",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "timeout:",
- protocol: 'async',
- fn: function (aNumber){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1,$receiver;
- $1=self["@asyncTimeout"];
- if(($receiver = $1) == null || $receiver.isNil){
- $1;
- } else {
- $recv(self["@asyncTimeout"])._clearTimeout();
- };
- self["@asyncTimeout"]=(0);
- self["@asyncTimeout"]=$recv(self._async_((function(){
- return $core.withContext(function($ctx2) {
- return self._assert_description_(false,"SUnit grace time exhausted");
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- })))._valueWithTimeout_(aNumber);
- return self;
- }, function($ctx1) {$ctx1.fill(self,"timeout:",{aNumber:aNumber},$globals.TestCase)});
- },
- args: ["aNumber"],
- source: "timeout: aNumber\x0a\x09\x22Set a grace time timeout in milliseconds to run the test asynchronously\x22\x0a\x09\x0a\x09asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].\x0a\x09\x0a\x09\x22to allow #async: message send without throwing an error\x22\x0a\x09asyncTimeout := 0.\x0a\x09\x0a\x09asyncTimeout := (self async: [\x0a\x09\x09self assert: false description: 'SUnit grace time exhausted' ])\x0a\x09\x09\x09valueWithTimeout: aNumber",
- referencedClasses: [],
- messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"]
- }),
- $globals.TestCase);
- $core.addMethod(
- $core.method({
- selector: "allTestSelectors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- var selectors;
- return $core.withContext(function($ctx1) {
- var $1;
- selectors=self._testSelectors();
- $1=self._shouldInheritSelectors();
- if($core.assert($1)){
- $recv(selectors)._addAll_($recv(self._superclass())._allTestSelectors());
- };
- return selectors;
- }, function($ctx1) {$ctx1.fill(self,"allTestSelectors",{selectors:selectors},$globals.TestCase.klass)});
- },
- args: [],
- source: "allTestSelectors\x0a\x09| selectors |\x0a\x09selectors := self testSelectors.\x0a\x09self shouldInheritSelectors ifTrue: [\x0a\x09\x09selectors addAll: self superclass allTestSelectors ].\x0a\x09^ selectors",
- referencedClasses: [],
- messageSends: ["testSelectors", "ifTrue:", "shouldInheritSelectors", "addAll:", "allTestSelectors", "superclass"]
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "buildSuite",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv(self._allTestSelectors())._collect_((function(each){
- return $core.withContext(function($ctx2) {
- return self._selector_(each);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- }));
- }, function($ctx1) {$ctx1.fill(self,"buildSuite",{},$globals.TestCase.klass)});
- },
- args: [],
- source: "buildSuite\x0a\x09^ self allTestSelectors collect: [ :each | self selector: each ]",
- referencedClasses: [],
- messageSends: ["collect:", "allTestSelectors", "selector:"]
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "classTag",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return "test";
- },
- args: [],
- source: "classTag\x0a\x09\x22Returns a tag or general category for this class.\x0a\x09Typically used to help tools do some reflection.\x0a\x09Helios, for example, uses this to decide what icon the class should display.\x22\x0a\x09\x0a\x09^ 'test'",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "isAbstract",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv(self._name()).__eq("TestCase");
- }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},$globals.TestCase.klass)});
- },
- args: [],
- source: "isAbstract\x0a\x09^ self name = 'TestCase'",
- referencedClasses: [],
- messageSends: ["=", "name"]
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "lookupHierarchyRoot",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return $globals.TestCase;
- },
- args: [],
- source: "lookupHierarchyRoot\x0a\x09^ TestCase",
- referencedClasses: ["TestCase"],
- messageSends: []
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "selector:",
- protocol: 'accessing',
- fn: function (aSelector){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $1=self._new();
- $recv($1)._setTestSelector_(aSelector);
- return $recv($1)._yourself();
- }, function($ctx1) {$ctx1.fill(self,"selector:",{aSelector:aSelector},$globals.TestCase.klass)});
- },
- args: ["aSelector"],
- source: "selector: aSelector\x0a\x09^ self new\x0a\x09\x09setTestSelector: aSelector;\x0a\x09\x09yourself",
- referencedClasses: [],
- messageSends: ["setTestSelector:", "new", "yourself"]
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "shouldInheritSelectors",
- protocol: 'testing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return self.__tild_eq(self._lookupHierarchyRoot());
- }, function($ctx1) {$ctx1.fill(self,"shouldInheritSelectors",{},$globals.TestCase.klass)});
- },
- args: [],
- source: "shouldInheritSelectors\x0a\x09^ self ~= self lookupHierarchyRoot",
- referencedClasses: [],
- messageSends: ["~=", "lookupHierarchyRoot"]
- }),
- $globals.TestCase.klass);
- $core.addMethod(
- $core.method({
- selector: "testSelectors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv($recv(self._methodDictionary())._keys())._select_((function(each){
- return $core.withContext(function($ctx2) {
- return $recv(each)._match_("^test");
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- }));
- }, function($ctx1) {$ctx1.fill(self,"testSelectors",{},$globals.TestCase.klass)});
- },
- args: [],
- source: "testSelectors\x0a\x09^ self methodDictionary keys select: [ :each | each match: '^test' ]",
- referencedClasses: [],
- messageSends: ["select:", "keys", "methodDictionary", "match:"]
- }),
- $globals.TestCase.klass);
- $core.addClass('TestContext', $globals.Object, ['testCase'], 'SUnit');
- $globals.TestContext.comment="I govern running a particular test case.\x0a\x0aMy main added value is `#execute:` method which runs a block as a part of test case (restores context, nilling it afterwards, cleaning/calling `#tearDown` as appropriate for sync/async scenario).";
- $core.addMethod(
- $core.method({
- selector: "execute:",
- protocol: 'running',
- fn: function (aBlock){
- var self=this;
- var failed;
- return $core.withContext(function($ctx1) {
- var $1,$2;
- $recv(self["@testCase"])._context_(self);
- $ctx1.sendIdx["context:"]=1;
- $recv((function(){
- return $core.withContext(function($ctx2) {
- failed=true;
- failed;
- $recv(aBlock)._value();
- failed=false;
- return failed;
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }))._ensure_((function(){
- return $core.withContext(function($ctx2) {
- $recv(self["@testCase"])._context_(nil);
- $1=$recv(failed)._and_((function(){
- return $core.withContext(function($ctx3) {
- return $recv(self["@testCase"])._isAsync();
- $ctx3.sendIdx["isAsync"]=1;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
- }));
- if($core.assert($1)){
- $recv(self["@testCase"])._finished();
- };
- $2=$recv(self["@testCase"])._isAsync();
- if(!$core.assert($2)){
- return $recv(self["@testCase"])._tearDown();
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- }));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed},$globals.TestContext)});
- },
- args: ["aBlock"],
- source: "execute: aBlock\x0a\x09| failed |\x0a\x09\x0a\x09testCase context: self.\x0a\x09[\x0a\x09\x09failed := true.\x0a\x09\x09aBlock value.\x0a\x09\x09failed := false\x0a\x09]\x0a\x09\x09ensure: [\x0a\x09\x09\x09testCase context: nil.\x0a\x09\x09\x09\x0a\x09\x09\x09(failed and: [ testCase isAsync ]) ifTrue: [\x0a\x09\x09\x09\x09testCase finished ].\x0a\x09\x09\x09testCase isAsync ifFalse: [\x0a\x09\x09\x09\x09testCase tearDown ] ]",
- referencedClasses: [],
- messageSends: ["context:", "ensure:", "value", "ifTrue:", "and:", "isAsync", "finished", "ifFalse:", "tearDown"]
- }),
- $globals.TestContext);
- $core.addMethod(
- $core.method({
- selector: "start",
- protocol: 'running',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._execute_((function(){
- return $core.withContext(function($ctx2) {
- $recv(self["@testCase"])._setUp();
- return $recv(self["@testCase"])._performTest();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"start",{},$globals.TestContext)});
- },
- args: [],
- source: "start\x0a\x09self execute: [\x0a\x09\x09testCase setUp.\x0a\x09\x09testCase performTest ]",
- referencedClasses: [],
- messageSends: ["execute:", "setUp", "performTest"]
- }),
- $globals.TestContext);
- $core.addMethod(
- $core.method({
- selector: "testCase:",
- protocol: 'accessing',
- fn: function (aTestCase){
- var self=this;
- self["@testCase"]=aTestCase;
- return self;
- },
- args: ["aTestCase"],
- source: "testCase: aTestCase\x0a\x09testCase := aTestCase",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestContext);
- $core.addMethod(
- $core.method({
- selector: "testCase:",
- protocol: 'instance creation',
- fn: function (aTestCase){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $1=self._new();
- $recv($1)._testCase_(aTestCase);
- return $recv($1)._yourself();
- }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase},$globals.TestContext.klass)});
- },
- args: ["aTestCase"],
- source: "testCase: aTestCase\x0a\x09^ self new\x0a\x09\x09testCase: aTestCase;\x0a\x09\x09yourself",
- referencedClasses: [],
- messageSends: ["testCase:", "new", "yourself"]
- }),
- $globals.TestContext.klass);
- $core.addClass('ReportingTestContext', $globals.TestContext, ['finished', 'result'], 'SUnit');
- $globals.ReportingTestContext.comment="I add `TestResult` reporting to `TestContext`.\x0a\x0aErrors are caught and save into a `TestResult`,\x0aWhen test case is finished (which can be later for async tests), a callback block is executed; this is used by a `TestSuiteRunner`.";
- $core.addMethod(
- $core.method({
- selector: "execute:",
- protocol: 'running',
- fn: function (aBlock){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $recv((function(){
- return $core.withContext(function($ctx2) {
- return self._withErrorReporting_((function(){
- return $core.withContext(function($ctx3) {
- return (
- $ctx3.supercall = true,
- ($globals.ReportingTestContext.superclass||$boot.nilAsClass).fn.prototype._execute_.apply($recv(self), [aBlock]));
- $ctx3.supercall = false;
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
- }));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }))._ensure_((function(){
- return $core.withContext(function($ctx2) {
- $1=$recv(self["@testCase"])._isAsync();
- if(!$core.assert($1)){
- $recv(self["@result"])._increaseRuns();
- return $recv(self["@finished"])._value();
- };
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
- }));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock},$globals.ReportingTestContext)});
- },
- args: ["aBlock"],
- source: "execute: aBlock\x0a\x09[\x0a\x09\x09self withErrorReporting: [ super execute: aBlock ]\x0a\x09]\x0a\x09\x09ensure: [\x0a\x09\x09\x09testCase isAsync ifFalse: [\x0a\x09\x09\x09\x09result increaseRuns. finished value ] ]",
- referencedClasses: [],
- messageSends: ["ensure:", "withErrorReporting:", "execute:", "ifFalse:", "isAsync", "increaseRuns", "value"]
- }),
- $globals.ReportingTestContext);
- $core.addMethod(
- $core.method({
- selector: "finished:",
- protocol: 'accessing',
- fn: function (aBlock){
- var self=this;
- self["@finished"]=aBlock;
- return self;
- },
- args: ["aBlock"],
- source: "finished: aBlock\x0a\x09finished := aBlock",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.ReportingTestContext);
- $core.addMethod(
- $core.method({
- selector: "result:",
- protocol: 'accessing',
- fn: function (aTestResult){
- var self=this;
- self["@result"]=aTestResult;
- return self;
- },
- args: ["aTestResult"],
- source: "result: aTestResult\x0a\x09result := aTestResult",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.ReportingTestContext);
- $core.addMethod(
- $core.method({
- selector: "withErrorReporting:",
- protocol: 'private',
- fn: function (aBlock){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv((function(){
- return $core.withContext(function($ctx2) {
- return $recv(aBlock)._on_do_($globals.TestFailure,(function(ex){
- return $core.withContext(function($ctx3) {
- return $recv(self["@result"])._addFailure_(self["@testCase"]);
- }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx2,2)});
- }));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }))._on_do_($globals.Error,(function(ex){
- return $core.withContext(function($ctx2) {
- return $recv(self["@result"])._addError_(self["@testCase"]);
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,3)});
- }));
- $ctx1.sendIdx["on:do:"]=1;
- return self;
- }, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock},$globals.ReportingTestContext)});
- },
- args: ["aBlock"],
- source: "withErrorReporting: aBlock\x0a\x09[ aBlock\x0a\x09\x09on: TestFailure\x0a\x09\x09do: [ :ex | result addFailure: testCase ]\x0a\x09]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :ex | result addError: testCase ]",
- referencedClasses: ["TestFailure", "Error"],
- messageSends: ["on:do:", "addFailure:", "addError:"]
- }),
- $globals.ReportingTestContext);
- $core.addMethod(
- $core.method({
- selector: "testCase:result:finished:",
- protocol: 'instance creation',
- fn: function (aTestCase,aTestResult,aBlock){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $1=(
- $ctx1.supercall = true,
- ($globals.ReportingTestContext.klass.superclass||$boot.nilAsClass).fn.prototype._testCase_.apply($recv(self), [aTestCase]));
- $ctx1.supercall = false;
- $recv($1)._result_(aTestResult);
- $recv($1)._finished_(aBlock);
- return $recv($1)._yourself();
- }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock},$globals.ReportingTestContext.klass)});
- },
- args: ["aTestCase", "aTestResult", "aBlock"],
- source: "testCase: aTestCase result: aTestResult finished: aBlock\x0a\x09^ (super testCase: aTestCase)\x0a\x09\x09result: aTestResult;\x0a\x09\x09finished: aBlock;\x0a\x09\x09yourself",
- referencedClasses: [],
- messageSends: ["result:", "testCase:", "finished:", "yourself"]
- }),
- $globals.ReportingTestContext.klass);
- $core.addClass('TestFailure', $globals.Error, [], 'SUnit');
- $globals.TestFailure.comment="I am raised when the boolean parameter of an #`assert:` or `#deny:` call is the opposite of what the assertion claims.\x0a\x0aThe test framework distinguishes between failures and errors.\x0aA failure is an event whose possibiity is explicitly anticipated and checked for in an assertion,\x0awhereas an error is an unanticipated problem like a division by 0 or an index out of bounds.";
- $core.addClass('TestResult', $globals.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
- $globals.TestResult.comment="I implement the collecting parameter pattern for running a bunch of tests.\x0a\x0aMy instances hold tests that have run, sorted into the result categories of passed, failures and errors.\x0a\x0a`TestResult` is an interesting object to subclass or substitute. `#runCase:` is the external protocol you need to reproduce";
- $core.addMethod(
- $core.method({
- selector: "addError:",
- protocol: 'accessing',
- fn: function (anError){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv(self._errors())._add_(anError);
- return self;
- }, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError},$globals.TestResult)});
- },
- args: ["anError"],
- source: "addError: anError\x0a\x09self errors add: anError",
- referencedClasses: [],
- messageSends: ["add:", "errors"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "addFailure:",
- protocol: 'accessing',
- fn: function (aFailure){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv(self._failures())._add_(aFailure);
- return self;
- }, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure},$globals.TestResult)});
- },
- args: ["aFailure"],
- source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
- referencedClasses: [],
- messageSends: ["add:", "failures"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "errors",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@errors"];
- },
- args: [],
- source: "errors\x0a\x09^ errors",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "failures",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@failures"];
- },
- args: [],
- source: "failures\x0a\x09^ failures",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "increaseRuns",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- self["@runs"]=$recv(self["@runs"]).__plus((1));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"increaseRuns",{},$globals.TestResult)});
- },
- args: [],
- source: "increaseRuns\x0a\x09runs := runs + 1",
- referencedClasses: [],
- messageSends: ["+"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- (
- $ctx1.supercall = true,
- ($globals.TestResult.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($recv(self), []));
- $ctx1.supercall = false;
- self["@timestamp"]=$recv($globals.Date)._now();
- self["@runs"]=(0);
- self["@errors"]=$recv($globals.Array)._new();
- $ctx1.sendIdx["new"]=1;
- self["@failures"]=$recv($globals.Array)._new();
- self["@total"]=(0);
- return self;
- }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.TestResult)});
- },
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
- referencedClasses: ["Date", "Array"],
- messageSends: ["initialize", "now", "new"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "nextRunDo:",
- protocol: 'running',
- fn: function (aBlock){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $2,$1;
- $2=self._runs();
- $ctx1.sendIdx["runs"]=1;
- $1=$recv($2).__eq_eq(self._total());
- if(!$core.assert($1)){
- return $recv(aBlock)._value_($recv(self._runs()).__plus((1)));
- };
- }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock},$globals.TestResult)});
- },
- args: ["aBlock"],
- source: "nextRunDo: aBlock\x0a\x09\x22Runs aBlock with index of next run or does nothing if no more runs\x22\x0a\x09^ self runs == self total\x0a\x09\x09ifFalse: [ aBlock value: self runs + 1 ]",
- referencedClasses: [],
- messageSends: ["ifFalse:", "==", "runs", "total", "value:", "+"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "runCase:",
- protocol: 'running',
- fn: function (aTestCase){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv((function(){
- return $core.withContext(function($ctx2) {
- return $recv((function(){
- return $core.withContext(function($ctx3) {
- self._increaseRuns();
- return $recv(aTestCase)._runCase();
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
- }))._on_do_($globals.TestFailure,(function(ex){
- return $core.withContext(function($ctx3) {
- return self._addFailure_(aTestCase);
- }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx2,3)});
- }));
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }))._on_do_($globals.Error,(function(ex){
- return $core.withContext(function($ctx2) {
- return self._addError_(aTestCase);
- }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,4)});
- }));
- $ctx1.sendIdx["on:do:"]=1;
- return self;
- }, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase},$globals.TestResult)});
- },
- args: ["aTestCase"],
- source: "runCase: aTestCase\x0a\x09[ [ self increaseRuns.\x0a\x09\x09aTestCase runCase ]\x0a\x09on: TestFailure do: [ :ex | self addFailure: aTestCase ]]\x0a\x09on: Error do: [ :ex | self addError: aTestCase ]",
- referencedClasses: ["TestFailure", "Error"],
- messageSends: ["on:do:", "increaseRuns", "runCase", "addFailure:", "addError:"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "runs",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@runs"];
- },
- args: [],
- source: "runs\x0a\x09^ runs",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "status",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $2,$3,$1;
- $2=$recv(self._errors())._isEmpty();
- $ctx1.sendIdx["isEmpty"]=1;
- if($core.assert($2)){
- $3=$recv(self._failures())._isEmpty();
- if($core.assert($3)){
- $1="success";
- } else {
- $1="failure";
- };
- } else {
- $1="error";
- };
- return $1;
- }, function($ctx1) {$ctx1.fill(self,"status",{},$globals.TestResult)});
- },
- args: [],
- source: "status\x0a\x09^ self errors isEmpty\x0a\x09\x09ifTrue: [\x0a\x09\x09\x09self failures isEmpty\x0a\x09\x09\x09\x09ifTrue: [ 'success' ]\x0a\x09\x09\x09\x09ifFalse: [ 'failure' ]]\x0a\x09\x09ifFalse: [ 'error' ]",
- referencedClasses: [],
- messageSends: ["ifTrue:ifFalse:", "isEmpty", "errors", "failures"]
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "timestamp",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@timestamp"];
- },
- args: [],
- source: "timestamp\x0a\x09^ timestamp",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "total",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@total"];
- },
- args: [],
- source: "total\x0a\x09^ total",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestResult);
- $core.addMethod(
- $core.method({
- selector: "total:",
- protocol: 'accessing',
- fn: function (aNumber){
- var self=this;
- self["@total"]=aNumber;
- return self;
- },
- args: ["aNumber"],
- source: "total: aNumber\x0a\x09total := aNumber",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestResult);
- $core.addClass('TestSuiteRunner', $globals.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
- $globals.TestSuiteRunner.comment="I am responsible for running a collection (`suite`) of tests.\x0a\x0a## API\x0a\x0aInstances should be created using the class-side `#on:` method, taking a collection of tests to run as parameter.\x0aTo run the test suite, use `#run`.";
- $core.addMethod(
- $core.method({
- selector: "announcer",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@announcer"];
- },
- args: [],
- source: "announcer\x0a\x09^ announcer",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "contextOf:",
- protocol: 'private',
- fn: function (anInteger){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv($globals.ReportingTestContext)._testCase_result_finished_($recv(self["@suite"])._at_(anInteger),self["@result"],(function(){
- return $core.withContext(function($ctx2) {
- return self._resume();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }));
- }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger},$globals.TestSuiteRunner)});
- },
- args: ["anInteger"],
- source: "contextOf: anInteger\x0a\x09^ ReportingTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]",
- referencedClasses: ["ReportingTestContext"],
- messageSends: ["testCase:result:finished:", "at:", "resume"]
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "initialize",
- protocol: 'initialization',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- (
- $ctx1.supercall = true,
- ($globals.TestSuiteRunner.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($recv(self), []));
- $ctx1.supercall = false;
- self["@announcer"]=$recv($globals.Announcer)._new();
- $ctx1.sendIdx["new"]=1;
- self["@result"]=$recv($globals.TestResult)._new();
- self["@runNextTest"]=(function(){
- var runs;
- return $core.withContext(function($ctx2) {
- runs=$recv(self["@result"])._runs();
- runs;
- $1=$recv(runs).__lt($recv(self["@result"])._total());
- if($core.assert($1)){
- return $recv(self._contextOf_($recv(runs).__plus((1))))._start();
- };
- }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1,1)});
- });
- return self;
- }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.TestSuiteRunner)});
- },
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a\x09result := TestResult new.\x0a\x09runNextTest := [ | runs | runs := result runs. runs < result total ifTrue: [ (self contextOf: runs + 1) start ] ].",
- referencedClasses: ["Announcer", "TestResult"],
- messageSends: ["initialize", "new", "runs", "ifTrue:", "<", "total", "start", "contextOf:", "+"]
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "result",
- protocol: 'accessing',
- fn: function (){
- var self=this;
- return self["@result"];
- },
- args: [],
- source: "result\x0a\x09^ result",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "resume",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv(self["@runNextTest"])._fork();
- $recv(self["@announcer"])._announce_($recv($recv($globals.ResultAnnouncement)._new())._result_(self["@result"]));
- return self;
- }, function($ctx1) {$ctx1.fill(self,"resume",{},$globals.TestSuiteRunner)});
- },
- args: [],
- source: "resume\x0a\x09runNextTest fork.\x0a\x09announcer announce: (ResultAnnouncement new result: result)",
- referencedClasses: ["ResultAnnouncement"],
- messageSends: ["fork", "announce:", "result:", "new"]
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "run",
- protocol: 'actions',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- $recv(self["@result"])._total_($recv(self["@suite"])._size());
- self._resume();
- return self;
- }, function($ctx1) {$ctx1.fill(self,"run",{},$globals.TestSuiteRunner)});
- },
- args: [],
- source: "run\x0a\x09result total: suite size.\x0a\x09self resume",
- referencedClasses: [],
- messageSends: ["total:", "size", "resume"]
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "suite:",
- protocol: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@suite"]=aCollection;
- return self;
- },
- args: ["aCollection"],
- source: "suite: aCollection\x0a\x09suite := aCollection",
- referencedClasses: [],
- messageSends: []
- }),
- $globals.TestSuiteRunner);
- $core.addMethod(
- $core.method({
- selector: "new",
- protocol: 'instance creation',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- self._shouldNotImplement();
- return self;
- }, function($ctx1) {$ctx1.fill(self,"new",{},$globals.TestSuiteRunner.klass)});
- },
- args: [],
- source: "new\x0a\x09self shouldNotImplement",
- referencedClasses: [],
- messageSends: ["shouldNotImplement"]
- }),
- $globals.TestSuiteRunner.klass);
- $core.addMethod(
- $core.method({
- selector: "on:",
- protocol: 'instance creation',
- fn: function (aCollection){
- var self=this;
- return $core.withContext(function($ctx1) {
- var $1;
- $1=(
- $ctx1.supercall = true,
- ($globals.TestSuiteRunner.klass.superclass||$boot.nilAsClass).fn.prototype._new.apply($recv(self), []));
- $ctx1.supercall = false;
- return $recv($1)._suite_(aCollection);
- }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection},$globals.TestSuiteRunner.klass)});
- },
- args: ["aCollection"],
- source: "on: aCollection\x0a\x09^ super new suite: aCollection",
- referencedClasses: [],
- messageSends: ["suite:", "new"]
- }),
- $globals.TestSuiteRunner.klass);
- $core.addMethod(
- $core.method({
- selector: "isTestClass",
- protocol: '*SUnit',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv(self._includesBehavior_($globals.TestCase))._and_((function(){
- return $core.withContext(function($ctx2) {
- return $recv(self._isAbstract())._not();
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- }));
- }, function($ctx1) {$ctx1.fill(self,"isTestClass",{},$globals.Behavior)});
- },
- args: [],
- source: "isTestClass\x0a\x09^(self includesBehavior: TestCase) and: [ \x0a\x09\x09\x09self isAbstract not ]",
- referencedClasses: ["TestCase"],
- messageSends: ["and:", "includesBehavior:", "not", "isAbstract"]
- }),
- $globals.Behavior);
- $core.addMethod(
- $core.method({
- selector: "isTestPackage",
- protocol: '*SUnit',
- fn: function (){
- var self=this;
- return $core.withContext(function($ctx1) {
- return $recv(self._classes())._anySatisfy_((function(each){
- return $core.withContext(function($ctx2) {
- return $recv(each)._isTestClass();
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- }));
- }, function($ctx1) {$ctx1.fill(self,"isTestPackage",{},$globals.Package)});
- },
- args: [],
- source: "isTestPackage\x0a\x09^ self classes anySatisfy: [ :each | each isTestClass ]",
- referencedClasses: [],
- messageSends: ["anySatisfy:", "classes", "isTestClass"]
- }),
- $globals.Package);
- });
|