|
@@ -77,6 +77,82 @@ messageSends: ["replace:with:", "innerHTML", "body", "assert:", ">=", "size", "a
|
|
}),
|
|
}),
|
|
$globals.SilkTest);
|
|
$globals.SilkTest);
|
|
|
|
|
|
|
|
+$core.addMethod(
|
|
|
|
+$core.method({
|
|
|
|
+selector: "assertBodyEndsWithOneOf:",
|
|
|
|
+protocol: 'fixture',
|
|
|
|
+fn: function (aStringArray){
|
|
|
|
+var self=this;
|
|
|
|
+var sanitizedBody,err;
|
|
|
|
+function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+var $2,$3,$1,$4,$5,$receiver;
|
|
|
|
+var $early={};
|
|
|
|
+try {
|
|
|
|
+sanitizedBody=$recv($recv($recv(document)._body())._innerHTML())._replace_with_("\x5cs*","");
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx1.sendIdx["replace:with:"]=1;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$recv(aStringArray)._do_((function(aString){
|
|
|
|
+var sanitizedAssertion;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+sanitizedAssertion=$recv(aString)._replace_with_("\x5cs*","");
|
|
|
|
+sanitizedAssertion;
|
|
|
|
+return $recv((function(){
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx3) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$2=$recv(sanitizedBody)._size();
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx3.sendIdx["size"]=1;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$3=$recv(sanitizedAssertion)._size();
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx3.sendIdx["size"]=2;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$1=$recv($2).__gt_eq($3);
|
|
|
|
+self._assert_($1);
|
|
|
|
+$4=self._assert_equals_($recv(sanitizedBody)._last_($recv(sanitizedAssertion)._size()),sanitizedAssertion);
|
|
|
|
+$4;
|
|
|
|
+throw $early=[self];
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+}))._on_do_($Error(),(function(e){
|
|
|
|
+err=e;
|
|
|
|
+return err;
|
|
|
|
+
|
|
|
|
+}));
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({aString:aString,sanitizedAssertion:sanitizedAssertion},$ctx1,1)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+}));
|
|
|
|
+$5=err;
|
|
|
|
+if(($receiver = $5) == null || $receiver.isNil){
|
|
|
|
+$5;
|
|
|
|
+} else {
|
|
|
|
+$recv(err)._signal();
|
|
|
|
+};
|
|
|
|
+return self;
|
|
|
|
+}
|
|
|
|
+catch(e) {if(e===$early)return e[0]; throw e}
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"assertBodyEndsWithOneOf:",{aStringArray:aStringArray,sanitizedBody:sanitizedBody,err:err},$globals.SilkTest)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+},
|
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
|
+args: ["aStringArray"],
|
|
|
|
+source: "assertBodyEndsWithOneOf: aStringArray\x0a\x09| sanitizedBody err |\x0a\x09sanitizedBody := document body innerHTML replace: '\x5cs*' with: ''.\x0a\x09aStringArray do: [ :aString |\x0a\x09\x09| sanitizedAssertion |\x0a\x09\x09sanitizedAssertion := aString replace: '\x5cs*' with: ''.\x0a\x09\x09[ self\x0a\x09\x09\x09assert: sanitizedBody size >= sanitizedAssertion size;\x0a\x09\x09\x09assert: (sanitizedBody last: sanitizedAssertion size)\x0a\x09\x09\x09equals: sanitizedAssertion. ^ self ] on: Error do: [ :e | err := e ]].\x0a\x09err ifNotNil: [ err signal ]",
|
|
|
|
+referencedClasses: ["Error"],
|
|
|
|
+//>>excludeEnd("ide");
|
|
|
|
+messageSends: ["replace:with:", "innerHTML", "body", "do:", "on:do:", "assert:", ">=", "size", "assert:equals:", "last:", "ifNotNil:", "signal"]
|
|
|
|
+}),
|
|
|
|
+$globals.SilkTest);
|
|
|
|
+
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "setUp",
|
|
selector: "setUp",
|
|
@@ -317,7 +393,7 @@ return $recv($Transcript())._show_("button pressed");
|
|
}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
}));
|
|
}));
|
|
-self._assertBodyEndsWith_(">sentinel<div class=\x22mySilkContainerClass\x22 id=\x22container\x22><div id=\x22contentarea\x22>here comes the content</div><div class=\x22myToolbarClass\x22 id=\x22toolbar\x22><button>do something</button></div></div></div>");
|
|
|
|
|
|
+self._assertBodyEndsWithOneOf_([">sentinel<div class=\x22mySilkContainerClass\x22 id=\x22container\x22><div id=\x22contentarea\x22>here comes the content</div><div class=\x22myToolbarClass\x22 id=\x22toolbar\x22><button>do something</button></div></div></div>", ">sentinel<div id=\x22container\x22 class=\x22mySilkContainerClass\x22><div id=\x22contentarea\x22>here comes the content</div><div id=\x22toolbar\x22 class=\x22myToolbarClass\x22><button>do something</button></div></div></div>"]);
|
|
return self;
|
|
return self;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
}, function($ctx1) {$ctx1.fill(self,"testNestedDIVsWithAttributes",{s:s},$globals.SilkTest)});
|
|
}, function($ctx1) {$ctx1.fill(self,"testNestedDIVsWithAttributes",{s:s},$globals.SilkTest)});
|
|
@@ -325,10 +401,10 @@ return self;
|
|
},
|
|
},
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
args: [],
|
|
args: [],
|
|
-source: "testNestedDIVsWithAttributes\x0a \x22demonstrates how DIVs are nested and given attributes\x22\x0a\x09| s |\x0a\x0a\x09s := '#fixture' asSilk.\x0a\x09\x0a\x09s := s DIV << ('id' -> 'container') << ('class' -> 'mySilkContainerClass').\x0a\x09s DIV << ('id' -> 'contentarea') << 'here comes the content'.\x0a\x09s := s DIV << ('id' -> 'toolbar') << ('class' -> 'myToolbarClass').\x0a\x09(s BUTTON: 'do something') on: 'click' bind: [Transcript show: 'button pressed'].\x0a\x09\x0a\x09self assertBodyEndsWith: '>sentinel<div class=\x22mySilkContainerClass\x22 id=\x22container\x22><div id=\x22contentarea\x22>here comes the content</div><div class=\x22myToolbarClass\x22 id=\x22toolbar\x22><button>do something</button></div></div></div>'",
|
|
|
|
|
|
+source: "testNestedDIVsWithAttributes\x0a \x22demonstrates how DIVs are nested and given attributes\x22\x0a\x09| s |\x0a\x0a\x09s := '#fixture' asSilk.\x0a\x09\x0a\x09s := s DIV << ('id' -> 'container') << ('class' -> 'mySilkContainerClass').\x0a\x09s DIV << ('id' -> 'contentarea') << 'here comes the content'.\x0a\x09s := s DIV << ('id' -> 'toolbar') << ('class' -> 'myToolbarClass').\x0a\x09(s BUTTON: 'do something') on: 'click' bind: [Transcript show: 'button pressed'].\x0a\x09\x0a\x09self assertBodyEndsWithOneOf: #(\x0a\x09\x09'>sentinel<div class=\x22mySilkContainerClass\x22 id=\x22container\x22><div id=\x22contentarea\x22>here comes the content</div><div class=\x22myToolbarClass\x22 id=\x22toolbar\x22><button>do something</button></div></div></div>'\x0a\x09\x09'>sentinel<div id=\x22container\x22 class=\x22mySilkContainerClass\x22><div id=\x22contentarea\x22>here comes the content</div><div id=\x22toolbar\x22 class=\x22myToolbarClass\x22><button>do something</button></div></div></div>'\x0a\x09)",
|
|
referencedClasses: ["Transcript"],
|
|
referencedClasses: ["Transcript"],
|
|
//>>excludeEnd("ide");
|
|
//>>excludeEnd("ide");
|
|
-messageSends: ["asSilk", "<<", "DIV", "->", "on:bind:", "BUTTON:", "show:", "assertBodyEndsWith:"]
|
|
|
|
|
|
+messageSends: ["asSilk", "<<", "DIV", "->", "on:bind:", "BUTTON:", "show:", "assertBodyEndsWithOneOf:"]
|
|
}),
|
|
}),
|
|
$globals.SilkTest);
|
|
$globals.SilkTest);
|
|
|
|
|