12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070 |
- smalltalk.addPackage('SUnit', {});
- smalltalk.addClass('ResultAnnouncement', smalltalk.Object, ['result'], 'SUnit');
- smalltalk.addMethod(
- "_result",
- smalltalk.method({
- selector: "result",
- category: 'accessing',
- fn: function (){
- var self=this;
- return self["@result"];
- },
- args: [],
- source: "result\x0a\x09^result",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ResultAnnouncement);
- smalltalk.addMethod(
- "_result_",
- smalltalk.method({
- selector: "result:",
- category: 'accessing',
- fn: function (aTestResult){
- var self=this;
- self["@result"]=aTestResult;
- return self},
- args: ["aTestResult"],
- source: "result: aTestResult\x0a\x09result := aTestResult",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ResultAnnouncement);
- smalltalk.addClass('RunningTestContext', smalltalk.Object, ['finished', 'testCase', 'result', 'step'], 'SUnit');
- smalltalk.addMethod(
- "_exception_ifNotAsync_",
- smalltalk.method({
- selector: "exception:ifNotAsync:",
- category: 'private',
- fn: function (anException,aBlock){
- var self=this;
- var $1;
- $1=smalltalk.send(self["@testCase"],"_isAsync",[]);
- if(smalltalk.assert($1)){
- self["@step"]=(function(){
- smalltalk.send(self["@testCase"],"_finished",[]);
- return smalltalk.send(anException,"_signal",[]);
- });
- self["@step"];
- } else {
- smalltalk.send(aBlock,"_value",[]);
- };
- return self},
- args: ["anException", "aBlock"],
- source: "exception: anException ifNotAsync: aBlock\x0a\x09testCase isAsync\x0a\x09\x09ifTrue: [ step := [ testCase finished. anException signal ]]\x0a\x09\x09ifFalse: [ aBlock value ]\x0a",
- messageSends: ["ifTrue:ifFalse:", "finished", "signal", "value", "isAsync"],
- referencedClasses: []
- }),
- smalltalk.RunningTestContext);
- smalltalk.addMethod(
- "_execute_",
- smalltalk.method({
- selector: "execute:",
- category: 'running',
- fn: function (aBlock){
- var self=this;
- var $1,$2;
- self["@step"]=aBlock;
- smalltalk.send((function(){
- return smalltalk.send(self["@step"],"_isNil",[]);
- }),"_whileFalse_",[(function(){
- smalltalk.send(self["@testCase"],"_context_",[self]);
- return smalltalk.send((function(){
- return smalltalk.send((function(){
- return smalltalk.send((function(){
- return smalltalk.send(self["@step"],"_ensure_",[(function(){
- smalltalk.send(self["@testCase"],"_context_",[nil]);
- self["@step"]=nil;
- self["@step"];
- $1=smalltalk.send(self["@testCase"],"_isAsync",[]);
- if(! smalltalk.assert($1)){
- return smalltalk.send(self["@testCase"],"_tearDown",[]);
- };
- })]);
- }),"_on_do_",[(smalltalk.TestFailure || TestFailure),(function(ex){
- return smalltalk.send(self,"_exception_ifNotAsync_",[ex,(function(){
- return smalltalk.send(self["@result"],"_addFailure_",[self["@testCase"]]);
- })]);
- })]);
- }),"_on_do_",[(smalltalk.Error || Error),(function(ex){
- return smalltalk.send(self,"_exception_ifNotAsync_",[ex,(function(){
- return smalltalk.send(self["@result"],"_addError_",[self["@testCase"]]);
- })]);
- })]);
- }),"_ensure_",[(function(){
- $2=smalltalk.send(self["@testCase"],"_isAsync",[]);
- if(! smalltalk.assert($2)){
- smalltalk.send(self["@result"],"_increaseRuns",[]);
- return smalltalk.send(self["@finished"],"_value",[]);
- };
- })]);
- })]);
- return self},
- args: ["aBlock"],
- source: "execute: aBlock\x0a step := aBlock.\x0a\x09[ step isNil ] whileFalse: [\x0a\x09 testCase context: self.\x0a\x09\x09[[[\x09step\x0a \x09\x09ensure: [ testCase context: nil. step := nil. testCase isAsync ifFalse: [ testCase tearDown ]]]\x0a\x09\x09\x09\x09on: TestFailure do: [:ex | self exception: ex ifNotAsync: [ result addFailure: testCase]]]\x0a\x09\x09\x09\x09on: Error do: [:ex | self exception: ex ifNotAsync: [ result addError: testCase]]]\x0a\x09\x09\x09\x09ensure: [ testCase isAsync ifFalse: [ result increaseRuns. finished value ]]]",
- messageSends: ["whileFalse:", "context:", "ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "on:do:", "exception:ifNotAsync:", "addError:", "addFailure:", "tearDown", "isNil"],
- referencedClasses: ["Error", "TestFailure"]
- }),
- smalltalk.RunningTestContext);
- smalltalk.addMethod(
- "_finished_",
- smalltalk.method({
- selector: "finished:",
- category: 'accessing',
- fn: function (aBlock){
- var self=this;
- self["@finished"]=aBlock;
- return self},
- args: ["aBlock"],
- source: "finished: aBlock\x0a\x09finished := aBlock",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.RunningTestContext);
- smalltalk.addMethod(
- "_result_",
- smalltalk.method({
- selector: "result:",
- category: 'accessing',
- fn: function (aTestResult){
- var self=this;
- self["@result"]=aTestResult;
- return self},
- args: ["aTestResult"],
- source: "result: aTestResult\x0a\x09result := aTestResult",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.RunningTestContext);
- smalltalk.addMethod(
- "_start",
- smalltalk.method({
- selector: "start",
- category: 'running',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_execute_",[(function(){
- smalltalk.send(self["@testCase"],"_setUp",[]);
- return smalltalk.send(self["@testCase"],"_performTest",[]);
- })]);
- return self},
- args: [],
- source: "start\x0a\x09self execute: [ testCase setUp. testCase performTest ]",
- messageSends: ["execute:", "setUp", "performTest"],
- referencedClasses: []
- }),
- smalltalk.RunningTestContext);
- smalltalk.addMethod(
- "_testCase_",
- smalltalk.method({
- selector: "testCase:",
- category: 'accessing',
- fn: function (aTestCase){
- var self=this;
- self["@testCase"]=aTestCase;
- return self},
- args: ["aTestCase"],
- source: "testCase: aTestCase\x0a\x09testCase := aTestCase",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.RunningTestContext);
- smalltalk.addMethod(
- "_testCase_result_finished_",
- smalltalk.method({
- selector: "testCase:result:finished:",
- category: 'instance creation',
- fn: function (aTestCase,aTestResult,aBlock){
- var self=this;
- var $2,$3,$1;
- $2=smalltalk.send(self,"_new",[]);
- smalltalk.send($2,"_testCase_",[aTestCase]);
- smalltalk.send($2,"_result_",[aTestResult]);
- smalltalk.send($2,"_finished_",[aBlock]);
- $3=smalltalk.send($2,"_yourself",[]);
- $1=$3;
- return $1;
- },
- args: ["aTestCase", "aTestResult", "aBlock"],
- source: "testCase: aTestCase result: aTestResult finished: aBlock\x0a\x09^self new\x0a testCase: aTestCase;\x0a result: aTestResult;\x0a finished: aBlock;\x0a yourself",
- messageSends: ["testCase:", "new", "result:", "finished:", "yourself"],
- referencedClasses: []
- }),
- smalltalk.RunningTestContext.klass);
- smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector', 'asyncTimeout', 'context'], 'SUnit');
- smalltalk.addMethod(
- "_assert_",
- smalltalk.method({
- selector: "assert:",
- category: 'testing',
- fn: function (aBoolean) {
- var self = this;
- smalltalk.send(self, "_assert_description_", [aBoolean, "Assertion failed"]);
- return self;
- },
- args: ["aBoolean"],
- source: "assert: aBoolean\x0a\x09self assert: aBoolean description: 'Assertion failed'",
- messageSends: ["assert:description:"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_assert_description_",
- smalltalk.method({
- selector: "assert:description:",
- category: 'testing',
- fn: function (aBoolean, aString) {
- var self = this;
- if (!smalltalk.assert(aBoolean)) {
- smalltalk.send(self, "_signalFailure_", [aString]);
- }
- return self;
- },
- args: ["aBoolean", "aString"],
- source: "assert: aBoolean description: aString\x0a\x09aBoolean ifFalse: [self signalFailure: aString]",
- messageSends: ["ifFalse:", "signalFailure:"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_assert_equals_",
- smalltalk.method({
- selector: "assert:equals:",
- category: 'testing',
- fn: function (expected, actual) {
- var self = this;
- var $1;
- $1 = smalltalk.send(self, "_assert_description_", [smalltalk.send(expected, "__eq", [actual]), smalltalk.send(smalltalk.send(smalltalk.send("Expected: ", "__comma", [smalltalk.send(expected, "_asString", [])]), "__comma", [" but was: "]), "__comma", [smalltalk.send(actual, "_asString", [])])]);
- return $1;
- },
- args: ["expected", "actual"],
- source: "assert: expected equals: actual\x0a\x09^ self assert: (expected = actual) description: 'Expected: ', expected asString, ' but was: ', actual asString",
- messageSends: ["assert:description:", "=", ",", "asString"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_async_",
- smalltalk.method({
- selector: "async:",
- category: 'async',
- fn: function (aBlock){
- var self=this;
- var $2,$1;
- var c;
- smalltalk.send(self,"_mustBeAsync_",["#async"]);
- c=self["@context"];
- $1=(function(){
- $2=smalltalk.send(self,"_isAsync",[]);
- if(smalltalk.assert($2)){
- return smalltalk.send(c,"_execute_",[aBlock]);
- };
- });
- return $1;
- },
- args: ["aBlock"],
- source: "async: aBlock\x0a\x09| c |\x0a\x09self mustBeAsync: '#async'.\x0a c := context.\x0a ^[ self isAsync ifTrue: [ c execute: aBlock ]]",
- messageSends: ["mustBeAsync:", "ifTrue:", "execute:", "isAsync"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_context_",
- smalltalk.method({
- selector: "context:",
- category: 'accessing',
- fn: function (aRunningTestContext){
- var self=this;
- self["@context"]=aRunningTestContext;
- return self},
- args: ["aRunningTestContext"],
- source: "context: aRunningTestContext\x0a\x09context := aRunningTestContext",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_deny_",
- smalltalk.method({
- selector: "deny:",
- category: 'testing',
- fn: function (aBoolean) {
- var self = this;
- smalltalk.send(self, "_assert_", [smalltalk.send(aBoolean, "_not", [])]);
- return self;
- },
- args: ["aBoolean"],
- source: "deny: aBoolean\x0a\x09self assert: aBoolean not",
- messageSends: ["assert:", "not"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_finished",
- smalltalk.method({
- selector: "finished",
- category: 'async',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_mustBeAsync_",["#finished"]);
- self["@asyncTimeout"]=nil;
- return self},
- args: [],
- source: "finished\x0a\x09self mustBeAsync: '#finished'.\x0a\x09asyncTimeout := nil",
- messageSends: ["mustBeAsync:"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_graceTime_",
- smalltalk.method({
- selector: "graceTime:",
- category: 'async',
- fn: function (millis){
- var self=this;
- self["@asyncTimeout"]=true;
- return self},
- args: ["millis"],
- source: "graceTime: millis\x0a\x09asyncTimeout := true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_isAsync",
- smalltalk.method({
- selector: "isAsync",
- category: 'async',
- fn: function (){
- var self=this;
- var $1;
- $1=smalltalk.send(self["@asyncTimeout"],"_notNil",[]);
- return $1;
- },
- args: [],
- source: "isAsync\x0a\x09^asyncTimeout notNil",
- messageSends: ["notNil"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_mustBeAsync_",
- smalltalk.method({
- selector: "mustBeAsync:",
- category: 'async',
- fn: function (aString){
- var self=this;
- var $1;
- $1=smalltalk.send(self,"_isAsync",[]);
- if(! smalltalk.assert($1)){
- smalltalk.send(self,"_error_",[smalltalk.send(aString,"__comma",[" used without prior #graceTime:"])]);
- };
- return self},
- args: ["aString"],
- source: "mustBeAsync: aString\x0a\x09self isAsync ifFalse: [ self error: aString, ' used without prior #graceTime:' ]",
- messageSends: ["ifFalse:", "error:", ",", "isAsync"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_performTest",
- smalltalk.method({
- selector: "performTest",
- category: 'running',
- fn: function (){
- var self=this;
- self["@asyncTimeout"]=nil;
- smalltalk.send(self,"_perform_",[smalltalk.send(self,"_selector",[])]);
- return self},
- args: [],
- source: "performTest\x0a\x09asyncTimeout := nil.\x0a\x09self perform: self selector\x0a",
- messageSends: ["perform:", "selector"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_runCase",
- smalltalk.method({
- selector: "runCase",
- category: 'running',
- fn: function (){
- var self=this;
- smalltalk.send((function(){
- smalltalk.send(self,"_setUp",[]);
- return smalltalk.send(self,"_performTest",[]);
- }),"_ensure_",[(function(){
- return smalltalk.send(self,"_tearDown",[]);
- })]);
- return self},
- args: [],
- source: "runCase\x0a\x09[\x09self setUp.\x0a\x09\x09self performTest ] ensure: [\x0a\x09\x09self tearDown ]\x0a",
- messageSends: ["ensure:", "tearDown", "setUp", "performTest"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_selector",
- smalltalk.method({
- selector: "selector",
- category: 'accessing',
- fn: function () {
- var self = this;
- return self['@testSelector'];
- },
- args: [],
- source: "selector\x0a\x09^testSelector",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_setTestSelector_",
- smalltalk.method({
- selector: "setTestSelector:",
- category: 'accessing',
- fn: function (aSelector) {
- var self = this;
- self['@testSelector'] = aSelector;
- return self;
- },
- args: ["aSelector"],
- source: "setTestSelector: aSelector\x0a\x09testSelector := aSelector",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_setUp",
- smalltalk.method({
- selector: "setUp",
- category: 'running',
- fn: function () {
- var self = this;
- return self;
- },
- args: [],
- source: "setUp",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_should_",
- smalltalk.method({
- selector: "should:",
- category: 'testing',
- fn: function (aBlock) {
- var self = this;
- smalltalk.send(self, "_assert_", [smalltalk.send(aBlock, "_value", [])]);
- return self;
- },
- args: ["aBlock"],
- source: "should: aBlock\x0a\x09self assert: aBlock value",
- messageSends: ["assert:", "value"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_should_raise_",
- smalltalk.method({
- selector: "should:raise:",
- category: 'testing',
- fn: function (aBlock, anExceptionClass) {
- var self = this;
- smalltalk.send(self, "_assert_", [smalltalk.send(function () {smalltalk.send(aBlock, "_value", []);return false;}, "_on_do_", [anExceptionClass, function (ex) {return true;}])]);
- return self;
- },
- args: ["aBlock", "anExceptionClass"],
- source: "should: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. false] \x0a\x09\x09on: anExceptionClass \x0a\x09\x09do: [:ex | true])",
- messageSends: ["assert:", "on:do:", "value"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_shouldnt_raise_",
- smalltalk.method({
- selector: "shouldnt:raise:",
- category: 'testing',
- fn: function (aBlock, anExceptionClass) {
- var self = this;
- smalltalk.send(self, "_assert_", [smalltalk.send(function () {smalltalk.send(aBlock, "_value", []);return true;}, "_on_do_", [anExceptionClass, function (ex) {return false;}])]);
- return self;
- },
- args: ["aBlock", "anExceptionClass"],
- source: "shouldnt: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. true] \x0a\x09\x09on: anExceptionClass \x0a\x09\x09do: [:ex | false])",
- messageSends: ["assert:", "on:do:", "value"],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_signalFailure_",
- smalltalk.method({
- selector: "signalFailure:",
- category: 'private',
- fn: function (aString) {
- var self = this;
- var $1, $2;
- $1 = smalltalk.send(smalltalk.TestFailure || TestFailure, "_new", []);
- smalltalk.send($1, "_messageText_", [aString]);
- $2 = smalltalk.send($1, "_signal", []);
- return self;
- },
- args: ["aString"],
- source: "signalFailure: aString\x0a\x09TestFailure new\x0a\x09\x09messageText: aString;\x0a\x09\x09signal",
- messageSends: ["messageText:", "new", "signal"],
- referencedClasses: ["TestFailure"]
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_tearDown",
- smalltalk.method({
- selector: "tearDown",
- category: 'running',
- fn: function () {
- var self = this;
- return self;
- },
- args: [],
- source: "tearDown",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestCase);
- smalltalk.addMethod(
- "_allTestSelectors",
- smalltalk.method({
- selector: "allTestSelectors",
- category: 'accessing',
- fn: function () {
- var self = this;
- var $1;
- var selectors;
- selectors = smalltalk.send(self, "_testSelectors", []);
- $1 = smalltalk.send(self, "_shouldInheritSelectors", []);
- if (smalltalk.assert($1)) {
- smalltalk.send(selectors, "_addAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_allTestSelectors", [])]);
- }
- return selectors;
- },
- args: [],
- source: "allTestSelectors\x0a\x09| selectors |\x0a\x09selectors := self testSelectors.\x0a\x09self shouldInheritSelectors ifTrue: [\x0a\x09\x09selectors addAll: self superclass allTestSelectors].\x0a\x09^selectors",
- messageSends: ["testSelectors", "ifTrue:", "addAll:", "allTestSelectors", "superclass", "shouldInheritSelectors"],
- referencedClasses: []
- }),
- smalltalk.TestCase.klass);
- smalltalk.addMethod(
- "_buildSuite",
- smalltalk.method({
- selector: "buildSuite",
- category: 'accessing',
- fn: function () {
- var self = this;
- var $1;
- $1 = smalltalk.send(smalltalk.send(self, "_allTestSelectors", []), "_collect_", [function (each) {return smalltalk.send(self, "_selector_", [each]);}]);
- return $1;
- },
- args: [],
- source: "buildSuite\x0a\x09^self allTestSelectors collect: [:each | self selector: each]",
- messageSends: ["collect:", "selector:", "allTestSelectors"],
- referencedClasses: []
- }),
- smalltalk.TestCase.klass);
- smalltalk.addMethod(
- "_isAbstract",
- smalltalk.method({
- selector: "isAbstract",
- category: 'testing',
- fn: function () {
- var self = this;
- var $1;
- $1 = smalltalk.send(smalltalk.send(self, "_name", []), "__eq", ["TestCase"]);
- return $1;
- },
- args: [],
- source: "isAbstract\x0a\x09^ self name = 'TestCase'",
- messageSends: ["=", "name"],
- referencedClasses: []
- }),
- smalltalk.TestCase.klass);
- smalltalk.addMethod(
- "_lookupHierarchyRoot",
- smalltalk.method({
- selector: "lookupHierarchyRoot",
- category: 'accessing',
- fn: function () {
- var self = this;
- return smalltalk.TestCase || TestCase;
- },
- args: [],
- source: "lookupHierarchyRoot\x0a\x09^TestCase",
- messageSends: [],
- referencedClasses: ["TestCase"]
- }),
- smalltalk.TestCase.klass);
- smalltalk.addMethod(
- "_selector_",
- smalltalk.method({
- selector: "selector:",
- category: 'accessing',
- fn: function (aSelector) {
- var self = this;
- var $2, $3, $1;
- $2 = smalltalk.send(self, "_new", []);
- smalltalk.send($2, "_setTestSelector_", [aSelector]);
- $3 = smalltalk.send($2, "_yourself", []);
- $1 = $3;
- return $1;
- },
- args: ["aSelector"],
- source: "selector: aSelector\x0a\x09^self new\x0a\x09\x09setTestSelector: aSelector;\x0a\x09\x09yourself",
- messageSends: ["setTestSelector:", "new", "yourself"],
- referencedClasses: []
- }),
- smalltalk.TestCase.klass);
- smalltalk.addMethod(
- "_shouldInheritSelectors",
- smalltalk.method({
- selector: "shouldInheritSelectors",
- category: 'testing',
- fn: function () {
- var self = this;
- var $1;
- $1 = smalltalk.send(self, "_~_eq", [smalltalk.send(self, "_lookupHierarchyRoot", [])]);
- return $1;
- },
- args: [],
- source: "shouldInheritSelectors\x0a\x09^self ~= self lookupHierarchyRoot",
- messageSends: ["~=", "lookupHierarchyRoot"],
- referencedClasses: []
- }),
- smalltalk.TestCase.klass);
- smalltalk.addMethod(
- "_testSelectors",
- smalltalk.method({
- selector: "testSelectors",
- category: 'accessing',
- fn: function () {
- var self = this;
- var $1;
- $1 = smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_keys", []), "_select_", [function (each) {return smalltalk.send(each, "_match_", ["^test"]);}]);
- return $1;
- },
- args: [],
- source: "testSelectors\x0a\x09^self methodDictionary keys select: [:each | each match: '^test']",
- messageSends: ["select:", "match:", "keys", "methodDictionary"],
- referencedClasses: []
- }),
- smalltalk.TestCase.klass);
- smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
- smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
- smalltalk.addMethod(
- "_addError_",
- smalltalk.method({
- selector: "addError:",
- category: 'accessing',
- fn: function (anError) {
- var self = this;
- smalltalk.send(smalltalk.send(self, "_errors", []), "_add_", [anError]);
- return self;
- },
- args: ["anError"],
- source: "addError: anError\x0a\x09self errors add: anError",
- messageSends: ["add:", "errors"],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_addFailure_",
- smalltalk.method({
- selector: "addFailure:",
- category: 'accessing',
- fn: function (aFailure) {
- var self = this;
- smalltalk.send(smalltalk.send(self, "_failures", []), "_add_", [aFailure]);
- return self;
- },
- args: ["aFailure"],
- source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
- messageSends: ["add:", "failures"],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_errors",
- smalltalk.method({
- selector: "errors",
- category: 'accessing',
- fn: function () {
- var self = this;
- return self['@errors'];
- },
- args: [],
- source: "errors\x0a\x09^errors",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_failures",
- smalltalk.method({
- selector: "failures",
- category: 'accessing',
- fn: function () {
- var self = this;
- return self['@failures'];
- },
- args: [],
- source: "failures\x0a\x09^failures",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_increaseRuns",
- smalltalk.method({
- selector: "increaseRuns",
- category: 'accessing',
- fn: function () {
- var self = this;
- self['@runs'] = smalltalk.send(self['@runs'], "__plus", [1]);
- return self;
- },
- args: [],
- source: "increaseRuns\x0a\x09runs := runs + 1",
- messageSends: ["+"],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'initialization',
- fn: function () {
- var self = this;
- smalltalk.send(self, "_initialize", [], smalltalk.Object);
- self['@timestamp'] = smalltalk.send(smalltalk.Date || Date, "_now", []);
- self['@runs'] = 0;
- self['@errors'] = smalltalk.send(smalltalk.Array || Array, "_new", []);
- self['@failures'] = smalltalk.send(smalltalk.Array || Array, "_new", []);
- self['@total'] = 0;
- return self;
- },
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
- messageSends: ["initialize", "now", "new"],
- referencedClasses: ["Date", "Array"]
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_runs",
- smalltalk.method({
- selector: "runs",
- category: 'accessing',
- fn: function () {
- var self = this;
- return self['@runs'];
- },
- args: [],
- source: "runs\x0a\x09^runs",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_status",
- smalltalk.method({
- selector: "status",
- category: 'accessing',
- fn: function () {
- var self = this;
- var $2, $3, $1;
- $2 = smalltalk.send(smalltalk.send(self, "_errors", []), "_isEmpty", []);
- if (smalltalk.assert($2)) {
- $3 = smalltalk.send(smalltalk.send(self, "_failures", []), "_isEmpty", []);
- if (smalltalk.assert($3)) {
- $1 = "success";
- } else {
- $1 = "failure";
- }
- } else {
- $1 = "error";
- }
- return $1;
- },
- 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']",
- messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_timestamp",
- smalltalk.method({
- selector: "timestamp",
- category: 'accessing',
- fn: function () {
- var self = this;
- return self['@timestamp'];
- },
- args: [],
- source: "timestamp\x0a\x09^timestamp",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_total",
- smalltalk.method({
- selector: "total",
- category: 'accessing',
- fn: function () {
- var self = this;
- return self['@total'];
- },
- args: [],
- source: "total\x0a\x09^total",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addMethod(
- "_total_",
- smalltalk.method({
- selector: "total:",
- category: 'accessing',
- fn: function (aNumber) {
- var self = this;
- self['@total'] = aNumber;
- return self;
- },
- args: ["aNumber"],
- source: "total: aNumber\x0a\x09total := aNumber",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestResult);
- smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
- smalltalk.addMethod(
- "_announcer",
- smalltalk.method({
- selector: "announcer",
- category: 'accessing',
- fn: function (){
- var self=this;
- return self["@announcer"];
- },
- args: [],
- source: "announcer\x0a\x09^announcer",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_contextOf_",
- smalltalk.method({
- selector: "contextOf:",
- category: 'private',
- fn: function (anInteger){
- var self=this;
- var $1;
- $1=smalltalk.send((smalltalk.RunningTestContext || RunningTestContext),"_testCase_result_finished_",[smalltalk.send(self["@suite"],"_at_",[anInteger]),self["@result"],(function(){
- return smalltalk.send(self,"_resume",[]);
- })]);
- return $1;
- },
- args: ["anInteger"],
- source: "contextOf: anInteger\x0a \x09^RunningTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]\x0a",
- messageSends: ["testCase:result:finished:", "at:", "resume"],
- referencedClasses: ["RunningTestContext"]
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'initialization',
- fn: function (){
- var self=this;
- var $1;
- smalltalk.send(self,"_initialize",[],smalltalk.Object);
- self["@announcer"]=smalltalk.send((smalltalk.Announcer || Announcer),"_new",[]);
- self["@result"]=smalltalk.send((smalltalk.TestResult || TestResult),"_new",[]);
- self["@runNextTest"]=(function(){
- var runs;
- runs=smalltalk.send(self["@result"],"_runs",[]);
- runs;
- $1=smalltalk.send(runs,"__lt",[smalltalk.send(self["@result"],"_total",[])]);
- if(smalltalk.assert($1)){
- return smalltalk.send(smalltalk.send(self,"_contextOf_",[smalltalk.send(runs,"__plus",[(1)])]),"_start",[]);
- };
- });
- return self},
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a result := TestResult new.\x0a runNextTest := [ | runs | runs := result runs. runs < result total ifTrue: [ (self contextOf: runs + 1) start ]].\x0a",
- messageSends: ["initialize", "new", "runs", "ifTrue:", "start", "contextOf:", "+", "<", "total"],
- referencedClasses: ["Announcer", "TestResult"]
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_result",
- smalltalk.method({
- selector: "result",
- category: 'accessing',
- fn: function (){
- var self=this;
- return self["@result"];
- },
- args: [],
- source: "result\x0a\x09^result",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_resume",
- smalltalk.method({
- selector: "resume",
- category: 'actions',
- fn: function (){
- var self=this;
- smalltalk.send(self["@runNextTest"],"_fork",[]);
- smalltalk.send(self["@announcer"],"_announce_",[smalltalk.send(smalltalk.send((smalltalk.ResultAnnouncement || ResultAnnouncement),"_new",[]),"_result_",[self["@result"]])]);
- return self},
- args: [],
- source: "resume\x0a\x09runNextTest fork.\x0a announcer announce: (ResultAnnouncement new result: result)\x0a",
- messageSends: ["fork", "announce:", "result:", "new"],
- referencedClasses: ["ResultAnnouncement"]
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_run",
- smalltalk.method({
- selector: "run",
- category: 'actions',
- fn: function (){
- var self=this;
- smalltalk.send(self["@result"],"_total_",[smalltalk.send(self["@suite"],"_size",[])]);
- smalltalk.send(self,"_resume",[]);
- return self},
- args: [],
- source: "run\x0a\x09result total: suite size.\x0a\x09self resume",
- messageSends: ["total:", "size", "resume"],
- referencedClasses: []
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_suite_",
- smalltalk.method({
- selector: "suite:",
- category: 'accessing',
- fn: function (aCollection){
- var self=this;
- self["@suite"]=aCollection;
- return self},
- args: ["aCollection"],
- source: "suite: aCollection\x0a\x09suite := aCollection",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.TestSuiteRunner);
- smalltalk.addMethod(
- "_new",
- smalltalk.method({
- selector: "new",
- category: 'instance creation',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_shouldNotImplement",[]);
- return self},
- args: [],
- source: "new\x0a\x09self shouldNotImplement",
- messageSends: ["shouldNotImplement"],
- referencedClasses: []
- }),
- smalltalk.TestSuiteRunner.klass);
- smalltalk.addMethod(
- "_on_",
- smalltalk.method({
- selector: "on:",
- category: 'instance creation',
- fn: function (aCollection){
- var self=this;
- var $1;
- $1=smalltalk.send(smalltalk.send(self,"_new",[],smalltalk.Object.klass),"_suite_",[aCollection]);
- return $1;
- },
- args: ["aCollection"],
- source: "on: aCollection\x0a\x09^super new suite: aCollection",
- messageSends: ["suite:", "new"],
- referencedClasses: []
- }),
- smalltalk.TestSuiteRunner.klass);
|