|
@@ -2339,6 +2339,30 @@ $globals.ClassBuilderTest);
|
|
|
|
|
|
|
|
|
$core.addClass("ClassTest", $globals.TestCase, ["builder", "theClass"], "Kernel-Tests");
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "is:javaScriptInstanceOf:",
|
|
|
+protocol: "running",
|
|
|
+
|
|
|
+args: ["anObject", "aJavaScriptClass"],
|
|
|
+source: "is: anObject javaScriptInstanceOf: aJavaScriptClass\x0a\x09<inlineJS: 'return anObject instanceof aJavaScriptClass'>",
|
|
|
+referencedClasses: [],
|
|
|
+
|
|
|
+pragmas: [["inlineJS:", ["return anObject instanceof aJavaScriptClass"]]],
|
|
|
+messageSends: []
|
|
|
+}, function ($methodClass){ return function (anObject,aJavaScriptClass){
|
|
|
+var self=this,$self=this;
|
|
|
+
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+
|
|
|
+return anObject instanceof aJavaScriptClass;
|
|
|
+return self;
|
|
|
+
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"is:javaScriptInstanceOf:",{anObject:anObject,aJavaScriptClass:aJavaScriptClass})});
|
|
|
+
|
|
|
+}; }),
|
|
|
+$globals.ClassTest);
|
|
|
+
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "jsConstructor",
|
|
@@ -2484,6 +2508,106 @@ return self;
|
|
|
}; }),
|
|
|
$globals.ClassTest);
|
|
|
|
|
|
+$core.addMethod(
|
|
|
+$core.method({
|
|
|
+selector: "testBeJavaScriptSubclassOf",
|
|
|
+protocol: "tests",
|
|
|
+
|
|
|
+args: [],
|
|
|
+source: "testBeJavaScriptSubclassOf\x0a\x09| instance constructor |\x0a\x09theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09constructor := self jsConstructor.\x0a\x09theClass beJavaScriptSubclassOf: constructor.\x0a\x09\x22part took from copy class test\x22\x0a\x09self assert: theClass superclass == ObjectMock superclass.\x0a\x09self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.\x0a\x09self assert: theClass name equals: 'ObjectMock2'.\x0a\x09self assert: theClass package == ObjectMock package.\x0a\x09self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys.\x0a\x09\x22testing specific to late-coupled detached root class\x22\x0a\x09instance := theClass new.\x0a\x09self assert: instance class == theClass.\x0a\x09self assert: (self is: instance javaScriptInstanceOf: constructor).\x0a\x09self assert: instance value equals: 4.\x0a\x09self shouldnt: [ instance foo: 9 ] raise: Error.\x0a\x09self assert: instance foo equals: 9",
|
|
|
+referencedClasses: ["ObjectMock", "Error"],
|
|
|
+
|
|
|
+pragmas: [],
|
|
|
+messageSends: ["copyClass:named:", "jsConstructor", "beJavaScriptSubclassOf:", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary", "new", "class", "is:javaScriptInstanceOf:", "value", "shouldnt:raise:", "foo:", "foo"]
|
|
|
+}, function ($methodClass){ return function (){
|
|
|
+var self=this,$self=this;
|
|
|
+var instance,constructor;
|
|
|
+
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
+
|
|
|
+var $2,$1,$4,$3,$6,$5,$8,$7;
|
|
|
+$self.theClass=$recv($self.builder)._copyClass_named_($globals.ObjectMock,"ObjectMock2");
|
|
|
+constructor=$self._jsConstructor();
|
|
|
+$recv($self.theClass)._beJavaScriptSubclassOf_(constructor);
|
|
|
+$2=$recv($self.theClass)._superclass();
|
|
|
+
|
|
|
+$ctx1.sendIdx["superclass"]=1;
|
|
|
+
|
|
|
+$1=$recv($2).__eq_eq($recv($globals.ObjectMock)._superclass());
|
|
|
+
|
|
|
+$ctx1.sendIdx["=="]=1;
|
|
|
+
|
|
|
+$self._assert_($1);
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:"]=1;
|
|
|
+
|
|
|
+$4=$recv($self.theClass)._instanceVariableNames();
|
|
|
+
|
|
|
+$ctx1.sendIdx["instanceVariableNames"]=1;
|
|
|
+
|
|
|
+$3=$recv($4).__eq_eq($recv($globals.ObjectMock)._instanceVariableNames());
|
|
|
+
|
|
|
+$ctx1.sendIdx["=="]=2;
|
|
|
+
|
|
|
+$self._assert_($3);
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:"]=2;
|
|
|
+
|
|
|
+$self._assert_equals_($recv($self.theClass)._name(),"ObjectMock2");
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:equals:"]=1;
|
|
|
+
|
|
|
+$6=$recv($self.theClass)._package();
|
|
|
+
|
|
|
+$ctx1.sendIdx["package"]=1;
|
|
|
+
|
|
|
+$5=$recv($6).__eq_eq($recv($globals.ObjectMock)._package());
|
|
|
+
|
|
|
+$ctx1.sendIdx["=="]=3;
|
|
|
+
|
|
|
+$self._assert_($5);
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:"]=3;
|
|
|
+
|
|
|
+$8=$recv($self.theClass)._methodDictionary();
|
|
|
+
|
|
|
+$ctx1.sendIdx["methodDictionary"]=1;
|
|
|
+
|
|
|
+$7=$recv($8)._keys();
|
|
|
+
|
|
|
+$ctx1.sendIdx["keys"]=1;
|
|
|
+
|
|
|
+$self._assert_equals_($7,$recv($recv($globals.ObjectMock)._methodDictionary())._keys());
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:equals:"]=2;
|
|
|
+
|
|
|
+instance=$recv($self.theClass)._new();
|
|
|
+$self._assert_($recv($recv(instance)._class()).__eq_eq($self.theClass));
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:"]=4;
|
|
|
+
|
|
|
+$self._assert_($self._is_javaScriptInstanceOf_(instance,constructor));
|
|
|
+$self._assert_equals_($recv(instance)._value(),(4));
|
|
|
+
|
|
|
+$ctx1.sendIdx["assert:equals:"]=3;
|
|
|
+
|
|
|
+$self._shouldnt_raise_((function(){
|
|
|
+
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
+
|
|
|
+return $recv(instance)._foo_((9));
|
|
|
+
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
|
|
|
+
|
|
|
+}),$globals.Error);
|
|
|
+$self._assert_equals_($recv(instance)._foo(),(9));
|
|
|
+return self;
|
|
|
+
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"testBeJavaScriptSubclassOf",{instance:instance,constructor:constructor})});
|
|
|
+
|
|
|
+}; }),
|
|
|
+$globals.ClassTest);
|
|
|
+
|
|
|
$core.addMethod(
|
|
|
$core.method({
|
|
|
selector: "testMetaclassSubclasses",
|