123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 |
- define(["amber/boot", "require", "amber/core/SUnit"], function($boot,requirejs){"use strict";
- var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
- var $pkg = $core.addPackage("SUnit-Tests");
- $pkg.innerEval = function (expr) { return eval(expr); };
- $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
- $core.addClass("ExampleSetTest", $globals.TestCase, ["empty", "full"], "SUnit-Tests");
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.ExampleSetTest.comment="ExampleSetTest is taken from Pharo 1.4.\x0a\x0aTHe purpose of this class is to demonstrate a simple use case of the test framework.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "setUp",
- protocol: "running",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "setUp\x0a\x09empty := Set new.\x0a\x09full := Set with: 5 with: #abc",
- referencedClasses: ["Set"],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["new", "with:with:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self.empty=$recv($globals.Set)._new();
- $self.full=$recv($globals.Set)._with_with_((5),"abc");
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"setUp",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addMethod(
- $core.method({
- selector: "testAdd",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testAdd\x0a\x09empty add: 5.\x0a\x09self assert: (empty includes: 5)",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["add:", "assert:", "includes:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $recv($self.empty)._add_((5));
- $self._assert_($recv($self.empty)._includes_((5)));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testAdd",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addMethod(
- $core.method({
- selector: "testGrow",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testGrow\x0a\x09empty addAll: (1 to: 100).\x0a\x09self assert: empty size equals: 100",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["addAll:", "to:", "assert:equals:", "size"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $recv($self.empty)._addAll_((1)._to_((100)));
- $self._assert_equals_($recv($self.empty)._size(),(100));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testGrow",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addMethod(
- $core.method({
- selector: "testIllegal",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testIllegal\x0a\x09self\x0a\x09\x09should: [ empty at: 5 ]\x0a\x09\x09raise: Error.\x0a\x09self\x0a\x09\x09should: [ empty at: 5 put: #abc ]\x0a\x09\x09raise: Error",
- referencedClasses: ["Error"],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["should:raise:", "at:", "at:put:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- [$self._should_raise_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $recv($self.empty)._at_((5));
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }),$globals.Error)
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["should:raise:"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self._should_raise_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $recv($self.empty)._at_put_((5),"abc");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- //>>excludeEnd("ctx");
- }),$globals.Error);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testIllegal",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addMethod(
- $core.method({
- selector: "testIncludes",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testIncludes\x0a\x09self assert: (full includes: 5).\x0a\x09self assert: (full includes: #abc)",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["assert:", "includes:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- [$self._assert_([$recv($self.full)._includes_((5))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["includes:"]=1
- //>>excludeEnd("ctx");
- ][0])
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["assert:"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self._assert_($recv($self.full)._includes_("abc"));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testIncludes",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addMethod(
- $core.method({
- selector: "testOccurrences",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testOccurrences\x0a\x09self assert: (empty occurrencesOf: 0) equals: 0.\x0a\x09self assert: (full occurrencesOf: 5) equals: 1.\x0a\x09full add: 5.\x0a\x09self assert: (full occurrencesOf: 5) equals: 1",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["assert:equals:", "occurrencesOf:", "add:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- [$self._assert_equals_([$recv($self.empty)._occurrencesOf_((0))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["occurrencesOf:"]=1
- //>>excludeEnd("ctx");
- ][0],(0))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["assert:equals:"]=1
- //>>excludeEnd("ctx");
- ][0];
- [$self._assert_equals_([$recv($self.full)._occurrencesOf_((5))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["occurrencesOf:"]=2
- //>>excludeEnd("ctx");
- ][0],(1))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["assert:equals:"]=2
- //>>excludeEnd("ctx");
- ][0];
- $recv($self.full)._add_((5));
- $self._assert_equals_($recv($self.full)._occurrencesOf_((5)),(1));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testOccurrences",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addMethod(
- $core.method({
- selector: "testRemove",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testRemove\x0a\x09full remove: 5.\x0a\x09self assert: (full includes: #abc).\x0a\x09self deny: (full includes: 5)",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["remove:", "assert:", "includes:", "deny:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $recv($self.full)._remove_((5));
- $self._assert_([$recv($self.full)._includes_("abc")
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["includes:"]=1
- //>>excludeEnd("ctx");
- ][0]);
- $self._deny_($recv($self.full)._includes_((5)));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testRemove",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.ExampleSetTest);
- $core.addClass("SUnitAsyncTest", $globals.TestCase, ["flag"], "SUnit-Tests");
- $core.addMethod(
- $core.method({
- selector: "fakeError",
- protocol: "helpers",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "fakeError\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 20",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self.flag="bad";
- $self._timeout_((30));
- $self.flag=$recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $self.flag="ok";
- return $self._error_("Intentional");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((20));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"fakeError",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "fakeErrorFailingInTearDown",
- protocol: "helpers",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "fakeErrorFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 20",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self.flag="bad";
- $self._timeout_((30));
- $self.flag=$recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $self._error_("Intentional");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((20));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"fakeErrorFailingInTearDown",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "fakeFailure",
- protocol: "helpers",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "fakeFailure\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 20",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self.flag="bad";
- $self._timeout_((30));
- $self.flag=$recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $self.flag="ok";
- return $self._assert_(false);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((20));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"fakeFailure",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "fakeMultipleTimeoutFailing",
- protocol: "helpers",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "fakeMultipleTimeoutFailing\x0a\x09self timeout: 100.\x0a\x09(self async: [ \x0a\x09\x09self timeout: 20.\x0a\x09\x09(self async: [ self finished ]) valueWithTimeout: 30\x0a\x09]) valueWithTimeout: 20",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- [$self._timeout_((100))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["timeout:"]=1
- //>>excludeEnd("ctx");
- ][0];
- [$recv([$self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $self._timeout_((20));
- return $recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx3) {
- //>>excludeEnd("ctx");
- return $self._finished();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((30));
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["async:"]=1
- //>>excludeEnd("ctx");
- ][0])._valueWithTimeout_((20))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["valueWithTimeout:"]=1
- //>>excludeEnd("ctx");
- ][0];
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutFailing",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "fakeMultipleTimeoutPassing",
- protocol: "helpers",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "fakeMultipleTimeoutPassing\x0a\x09self timeout: 20.\x0a\x09(self async: [\x0a\x09\x09self timeout: 40.\x0a\x09\x09(self async: [ self finished ]) valueWithTimeout: 20\x0a\x09]) valueWithTimeout: 10",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- [$self._timeout_((20))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["timeout:"]=1
- //>>excludeEnd("ctx");
- ][0];
- [$recv([$self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $self._timeout_((40));
- return $recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx3) {
- //>>excludeEnd("ctx");
- return $self._finished();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((20));
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["async:"]=1
- //>>excludeEnd("ctx");
- ][0])._valueWithTimeout_((10))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["valueWithTimeout:"]=1
- //>>excludeEnd("ctx");
- ][0];
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutPassing",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "fakeTimeout",
- protocol: "helpers",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "fakeTimeout\x0a\x09self timeout: 10.\x0a\x09(self async: [ self finished ]) valueWithTimeout: 20",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self._timeout_((10));
- $recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $self._finished();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((20));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"fakeTimeout",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "selectorSetOf:",
- protocol: "private",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aCollection"],
- source: "selectorSetOf: aCollection\x0a\x09^ (aCollection collect: [ :each | each selector ]) asSet",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["asSet", "collect:", "selector"]
- }, function ($methodClass){ return function (aCollection){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return $recv($recv(aCollection)._collect_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $recv(each)._selector();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- })))._asSet();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"selectorSetOf:",{aCollection:aCollection})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "setUp",
- protocol: "running",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "setUp\x0a\x09flag := 'ok'",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: []
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- $self.flag="ok";
- return self;
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "tearDown",
- protocol: "running",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "tearDown\x0a\x09self assert: 'ok' equals: flag",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["assert:equals:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self._assert_equals_("ok",$self.flag);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"tearDown",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testAsyncErrorsAndFailures",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testAsyncErrorsAndFailures\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeError' 'fakeErrorFailingInTearDown' 'fakeFailure' 'testPass') collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09assertBlock := self async: [\x0a\x09\x09self assert: (self selectorSetOf: result errors) equals: #('fakeError') asSet.\x0a\x09\x09self assert: (self selectorSetOf: result failures) equals: #('fakeErrorFailingInTearDown' 'fakeFailure') asSet.\x0a\x09\x09self finished\x0a\x09].\x0a\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09ann result == result ifTrue: [ result runs = result total ifTrue: assertBlock ] ].\x0a\x09runner run",
- referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "finished", "on:do:", "announcer", "ifTrue:", "==", "=", "runs", "total", "run"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- var suite,runner,result,assertBlock;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- suite=["fakeError", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"]._collect_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $recv($self._class())._selector_(each);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- }));
- runner=$recv($globals.TestSuiteRunner)._on_(suite);
- $self._timeout_((200));
- result=[$recv(runner)._result()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["result"]=1
- //>>excludeEnd("ctx");
- ][0];
- assertBlock=$self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["selectorSetOf:"]=1
- //>>excludeEnd("ctx");
- ][0],[["fakeError"]._asSet()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["asSet"]=1
- //>>excludeEnd("ctx");
- ][0])
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["assert:equals:"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),["fakeErrorFailingInTearDown", "fakeFailure"]._asSet());
- return $self._finished();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- //>>excludeEnd("ctx");
- }));
- $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
- return $recv($recv($recv(result)._runs()).__eq($recv(result)._total()))._ifTrue_(assertBlock);
- }
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
- //>>excludeEnd("ctx");
- }));
- $recv(runner)._run();
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testAsyncErrorsAndFailures",{suite:suite,runner:runner,result:result,assertBlock:assertBlock})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testAsyncNeedsTimeout",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testAsyncNeedsTimeout\x0a\x09self should: [ self async: [ ] ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self async: [ ] ] raise: Error.\x0a\x09self finished",
- referencedClasses: ["Error"],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["should:raise:", "async:", "timeout:", "shouldnt:raise:", "finished"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self._should_raise_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return [$self._async_((function(){
- }))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["async:"]=1
- //>>excludeEnd("ctx");
- ][0];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }),$globals.Error);
- $self._timeout_((0));
- $self._shouldnt_raise_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $self._async_((function(){
- }));
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
- //>>excludeEnd("ctx");
- }),$globals.Error);
- $self._finished();
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testAsyncNeedsTimeout",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testFinishedNeedsTimeout",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testFinishedNeedsTimeout\x0a\x09self should: [ self finished ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self finished ] raise: Error.",
- referencedClasses: ["Error"],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["should:raise:", "finished", "timeout:", "shouldnt:raise:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self._should_raise_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return [$self._finished()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["finished"]=1
- //>>excludeEnd("ctx");
- ][0];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }),$globals.Error);
- $self._timeout_((0));
- $self._shouldnt_raise_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $self._finished();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- //>>excludeEnd("ctx");
- }),$globals.Error);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testFinishedNeedsTimeout",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testIsAsyncReturnsCorrectValues",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testIsAsyncReturnsCorrectValues\x0a\x09self deny: self isAsync.\x0a\x09self timeout: 0.\x0a\x09self assert: self isAsync.\x0a\x09self finished.\x0a\x09self deny: self isAsync",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["deny:", "isAsync", "timeout:", "assert:", "finished"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- [$self._deny_([$self._isAsync()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["isAsync"]=1
- //>>excludeEnd("ctx");
- ][0])
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["deny:"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self._timeout_((0));
- $self._assert_([$self._isAsync()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["isAsync"]=2
- //>>excludeEnd("ctx");
- ][0]);
- $self._finished();
- $self._deny_($self._isAsync());
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testIsAsyncReturnsCorrectValues",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testPass",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:", "finished"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self.flag="bad";
- $self._timeout_((10));
- $self.flag=$recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $self._assert_(true);
- $self._finished();
- $self.flag="ok";
- return $self.flag;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((5));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testPass",{})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testTimeouts",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testTimeouts\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeTimeout' 'fakeMultipleTimeoutFailing' 'fakeMultipleTimeoutPassing' 'testPass') collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09assertBlock := self async: [\x0a\x09\x09self assert: (self selectorSetOf: result errors) equals: Set new.\x0a\x09\x09self assert: (self selectorSetOf: result failures) equals: #('fakeMultipleTimeoutFailing' 'fakeTimeout') asSet.\x0a\x09\x09self finished\x0a\x09].\x0a\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09ann result == result ifTrue: [ result runs = result total ifTrue: assertBlock ] ].\x0a\x09runner run",
- referencedClasses: ["TestSuiteRunner", "Set", "ResultAnnouncement"],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "new", "failures", "asSet", "finished", "on:do:", "announcer", "ifTrue:", "==", "=", "runs", "total", "run"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- var suite,runner,result,assertBlock;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- suite=["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"]._collect_((function(each){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- return $recv($self._class())._selector_(each);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
- //>>excludeEnd("ctx");
- }));
- runner=$recv($globals.TestSuiteRunner)._on_(suite);
- $self._timeout_((200));
- result=[$recv(runner)._result()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["result"]=1
- //>>excludeEnd("ctx");
- ][0];
- assertBlock=$self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["selectorSetOf:"]=1
- //>>excludeEnd("ctx");
- ][0],$recv($globals.Set)._new())
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["assert:equals:"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),["fakeMultipleTimeoutFailing", "fakeTimeout"]._asSet());
- return $self._finished();
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- //>>excludeEnd("ctx");
- }));
- $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
- return $recv($recv($recv(result)._runs()).__eq($recv(result)._total()))._ifTrue_(assertBlock);
- }
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
- //>>excludeEnd("ctx");
- }));
- $recv(runner)._run();
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testTimeouts",{suite:suite,runner:runner,result:result,assertBlock:assertBlock})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- $core.addMethod(
- $core.method({
- selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
- protocol: "tests",
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "testTwoAsyncPassesWithFinishedOnlyOneIsRun\x0a\x09| x |\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09x := 0.\x0a\x09flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: x equals: 1 ]) valueWithTimeout: 0.\x0a\x09flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: x equals: 1 ]) valueWithTimeout: 0.",
- referencedClasses: [],
- //>>excludeEnd("ide");
- pragmas: [],
- messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished", "+", "assert:equals:"]
- }, function ($methodClass){ return function (){
- var self=this,$self=this;
- var x;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- $self.flag="bad";
- $self._timeout_((10));
- x=(0);
- $self.flag=[$recv([$self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- [$self._finished()
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["finished"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self.flag="ok";
- x=[$recv(x).__plus((1))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["+"]=1
- //>>excludeEnd("ctx");
- ][0];
- return [$self._assert_equals_(x,(1))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx2.sendIdx["assert:equals:"]=1
- //>>excludeEnd("ctx");
- ][0];
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
- //>>excludeEnd("ctx");
- }))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["async:"]=1
- //>>excludeEnd("ctx");
- ][0])._valueWithTimeout_((0))
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- ,$ctx1.sendIdx["valueWithTimeout:"]=1
- //>>excludeEnd("ctx");
- ][0];
- $self.flag=$recv($self._async_((function(){
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx2) {
- //>>excludeEnd("ctx");
- $self._finished();
- $self.flag="ok";
- x=$recv(x).__plus((1));
- return $self._assert_equals_(x,(1));
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
- //>>excludeEnd("ctx");
- })))._valueWithTimeout_((0));
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"testTwoAsyncPassesWithFinishedOnlyOneIsRun",{x:x})});
- //>>excludeEnd("ctx");
- }; }),
- $globals.SUnitAsyncTest);
- });
|