Browse Source

When tests are run do not loose commit paths set ups on loading

Laurent Laffont 13 years ago
parent
commit
25bb34a0e6
6 changed files with 95 additions and 54 deletions
  1. 15 14
      js/Kernel-Tests.deploy.js
  2. 21 20
      js/Kernel-Tests.js
  3. 14 2
      js/Kernel.deploy.js
  4. 23 6
      js/Kernel.js
  5. 13 10
      st/Kernel-Tests.st
  6. 9 2
      st/Kernel.st

+ 15 - 14
js/Kernel-Tests.deploy.js

@@ -355,13 +355,16 @@ smalltalk.JSObjectProxyTest);
 
 
 
-smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage'], 'Kernel-Tests');
+smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
 smalltalk.addMethod(
 '_setUp',
 smalltalk.method({
 selector: 'setUp',
 fn: function (){
 var self=this;
+self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []);
+self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []);
+smalltalk.send((smalltalk.Package || Package), "_resetCommitPaths", []);
 self['@zorkPackage']=smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_new", []), "_name_", ["Zork"]);
 self['@grulPackage']=(function($rec){smalltalk.send($rec, "_name_", ["Grul"]);smalltalk.send($rec, "_commitPathJs_", [unescape("server/grul/js")]);smalltalk.send($rec, "_commitPathSt_", [unescape("grul/st")]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Package || Package), "_new", []));
 return self;}
@@ -412,30 +415,28 @@ return self;}
 }),
 smalltalk.PackageTest);
 
-
-
-smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, ['backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
 smalltalk.addMethod(
-'_setUp',
+'_tearDown',
 smalltalk.method({
-selector: 'setUp',
+selector: 'tearDown',
 fn: function (){
 var self=this;
-smalltalk.send(self, "_setUp", [], smalltalk.PackageTest);
-self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []);
-self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []);
-(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [unescape("javascripts/")]);return smalltalk.send($rec, "_defaultCommitPathSt_", [unescape("smalltalk/")]);})((smalltalk.Package || Package));
+(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
 return self;}
 }),
-smalltalk.PackageWithDefaultCommitPathChangedTest);
+smalltalk.PackageTest);
 
+
+
+smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
 smalltalk.addMethod(
-'_tearDown',
+'_setUp',
 smalltalk.method({
-selector: 'tearDown',
+selector: 'setUp',
 fn: function (){
 var self=this;
-(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
+smalltalk.send(self, "_setUp", [], smalltalk.PackageTest);
+(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [unescape("javascripts/")]);return smalltalk.send($rec, "_defaultCommitPathSt_", [unescape("smalltalk/")]);})((smalltalk.Package || Package));
 return self;}
 }),
 smalltalk.PackageWithDefaultCommitPathChangedTest);

+ 21 - 20
js/Kernel-Tests.js

@@ -470,7 +470,7 @@ smalltalk.JSObjectProxyTest);
 
 
 
-smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage'], 'Kernel-Tests');
+smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
 smalltalk.addMethod(
 unescape('_setUp'),
 smalltalk.method({
@@ -478,12 +478,15 @@ selector: unescape('setUp'),
 category: 'running',
 fn: function (){
 var self=this;
+self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []);
+self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []);
+smalltalk.send((smalltalk.Package || Package), "_resetCommitPaths", []);
 self['@zorkPackage']=smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_new", []), "_name_", ["Zork"]);
 self['@grulPackage']=(function($rec){smalltalk.send($rec, "_name_", ["Grul"]);smalltalk.send($rec, "_commitPathJs_", [unescape("server/grul/js")]);smalltalk.send($rec, "_commitPathSt_", [unescape("grul/st")]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Package || Package), "_new", []));
 return self;},
 args: [],
-source: unescape('setUp%0A%09zorkPackage%20%3A%3D%20Package%20new%20name%3A%20%27Zork%27.%0A%09grulPackage%20%3A%3D%20Package%20new%20%0A%09%09%09%09%09name%3A%20%27Grul%27%3B%0A%09%09%09%09%09commitPathJs%3A%20%27server/grul/js%27%3B%0A%09%09%09%09%09commitPathSt%3A%20%27grul/st%27%3B%0A%09%09%09%09%09yourself'),
-messageSends: ["name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
+source: unescape('setUp%0A%09backUpCommitPathJs%20%3A%3D%20Package%20defaultCommitPathJs.%0A%09backUpCommitPathSt%20%3A%3D%20Package%20defaultCommitPathSt.%0A%0A%09Package%20resetCommitPaths.%0A%0A%09zorkPackage%20%3A%3D%20Package%20new%20name%3A%20%27Zork%27.%0A%09grulPackage%20%3A%3D%20Package%20new%20%0A%09%09%09%09%09name%3A%20%27Grul%27%3B%0A%09%09%09%09%09commitPathJs%3A%20%27server/grul/js%27%3B%0A%09%09%09%09%09commitPathSt%3A%20%27grul/st%27%3B%0A%09%09%09%09%09yourself'),
+messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
 referencedClasses: [smalltalk.Package]
 }),
 smalltalk.PackageTest);
@@ -552,40 +555,38 @@ referencedClasses: []
 }),
 smalltalk.PackageTest);
 
-
-
-smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, ['backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
 smalltalk.addMethod(
-unescape('_setUp'),
+unescape('_tearDown'),
 smalltalk.method({
-selector: unescape('setUp'),
+selector: unescape('tearDown'),
 category: 'running',
 fn: function (){
 var self=this;
-smalltalk.send(self, "_setUp", [], smalltalk.PackageTest);
-self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []);
-self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []);
-(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [unescape("javascripts/")]);return smalltalk.send($rec, "_defaultCommitPathSt_", [unescape("smalltalk/")]);})((smalltalk.Package || Package));
+(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
 return self;},
 args: [],
-source: unescape('setUp%0A%09super%20setUp.%0A%09backUpCommitPathJs%20%3A%3D%20Package%20defaultCommitPathJs.%0A%09backUpCommitPathSt%20%3A%3D%20Package%20defaultCommitPathSt.%0A%0A%09Package%0A%09%09defaultCommitPathJs%3A%20%27javascripts/%27%3B%0A%09%09defaultCommitPathSt%3A%20%27smalltalk/%27.'),
-messageSends: ["setUp", "defaultCommitPathJs", "defaultCommitPathSt", "defaultCommitPathJs:", "defaultCommitPathSt:"],
+source: unescape('tearDown%0A%09%20Package%20%0A%09%09defaultCommitPathJs%3A%20backUpCommitPathJs%3B%0A%09%09defaultCommitPathSt%3A%20backUpCommitPathSt'),
+messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
 referencedClasses: [smalltalk.Package]
 }),
-smalltalk.PackageWithDefaultCommitPathChangedTest);
+smalltalk.PackageTest);
+
 
+
+smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
 smalltalk.addMethod(
-unescape('_tearDown'),
+unescape('_setUp'),
 smalltalk.method({
-selector: unescape('tearDown'),
+selector: unescape('setUp'),
 category: 'running',
 fn: function (){
 var self=this;
-(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
+smalltalk.send(self, "_setUp", [], smalltalk.PackageTest);
+(function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [unescape("javascripts/")]);return smalltalk.send($rec, "_defaultCommitPathSt_", [unescape("smalltalk/")]);})((smalltalk.Package || Package));
 return self;},
 args: [],
-source: unescape('tearDown%0A%09%20Package%20%0A%09%09defaultCommitPathJs%3A%20backUpCommitPathJs%3B%0A%09%09defaultCommitPathSt%3A%20backUpCommitPathSt'),
-messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
+source: unescape('setUp%0A%09super%20setUp.%0A%0A%09Package%0A%09%09defaultCommitPathJs%3A%20%27javascripts/%27%3B%0A%09%09defaultCommitPathSt%3A%20%27smalltalk/%27.'),
+messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
 referencedClasses: [smalltalk.Package]
 }),
 smalltalk.PackageWithDefaultCommitPathChangedTest);

+ 14 - 2
js/Kernel.deploy.js

@@ -841,7 +841,7 @@ smalltalk.method({
 selector: 'commitPathJs',
 fn: function (){
 var self=this;
-return self['@commitPathJs']=smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathJs", []);
+return (($receiver = self['@commitPathJs']) == nil || $receiver == undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathJs", []);})() : $receiver;
 return self;}
 }),
 smalltalk.Package);
@@ -852,7 +852,7 @@ smalltalk.method({
 selector: 'commitPathSt',
 fn: function (){
 var self=this;
-return self['@commitPathSt']=smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathSt", []);
+return (($receiver = self['@commitPathSt']) == nil || $receiver == undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathSt", []);})() : $receiver;
 return self;}
 }),
 smalltalk.Package);
@@ -947,6 +947,18 @@ return self;}
 }),
 smalltalk.Package.klass);
 
+smalltalk.addMethod(
+'_resetCommitPaths',
+smalltalk.method({
+selector: 'resetCommitPaths',
+fn: function (){
+var self=this;
+self['@defaultCommitPathJs']=nil;
+self['@defaultCommitPathSt']=nil;
+return self;}
+}),
+smalltalk.Package.klass);
+
 
 smalltalk.addClass('Behavior', smalltalk.Object, [], 'Kernel');
 smalltalk.addMethod(

+ 23 - 6
js/Kernel.js

@@ -1198,11 +1198,11 @@ selector: unescape('commitPathJs'),
 category: 'accessing',
 fn: function (){
 var self=this;
-return self['@commitPathJs']=smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathJs", []);
+return (($receiver = self['@commitPathJs']) == nil || $receiver == undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathJs", []);})() : $receiver;
 return self;},
 args: [],
-source: unescape('commitPathJs%0A%09%5E%20commitPathJs%20%3A%3D%20self%20class%20defaultCommitPathJs'),
-messageSends: ["defaultCommitPathJs", "class"],
+source: unescape('commitPathJs%0A%09%5E%20commitPathJs%20ifNil%3A%20%5Bself%20class%20defaultCommitPathJs%5D'),
+messageSends: ["ifNil:", "defaultCommitPathJs", "class"],
 referencedClasses: []
 }),
 smalltalk.Package);
@@ -1214,11 +1214,11 @@ selector: unescape('commitPathSt'),
 category: 'accessing',
 fn: function (){
 var self=this;
-return self['@commitPathSt']=smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathSt", []);
+return (($receiver = self['@commitPathSt']) == nil || $receiver == undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultCommitPathSt", []);})() : $receiver;
 return self;},
 args: [],
-source: unescape('commitPathSt%0A%09%5E%20commitPathSt%20%3A%3D%20self%20class%20defaultCommitPathSt'),
-messageSends: ["defaultCommitPathSt", "class"],
+source: unescape('commitPathSt%0A%09%5E%20commitPathSt%20ifNil%3A%20%5Bself%20class%20defaultCommitPathSt%5D'),
+messageSends: ["ifNil:", "defaultCommitPathSt", "class"],
 referencedClasses: []
 }),
 smalltalk.Package);
@@ -1353,6 +1353,23 @@ referencedClasses: []
 }),
 smalltalk.Package.klass);
 
+smalltalk.addMethod(
+unescape('_resetCommitPaths'),
+smalltalk.method({
+selector: unescape('resetCommitPaths'),
+category: 'reset',
+fn: function (){
+var self=this;
+self['@defaultCommitPathJs']=nil;
+self['@defaultCommitPathSt']=nil;
+return self;},
+args: [],
+source: unescape('resetCommitPaths%0A%09defaultCommitPathJs%20%3A%3D%20nil.%0A%09defaultCommitPathSt%20%3A%3D%20nil.'),
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Package.klass);
+
 
 smalltalk.addClass('Behavior', smalltalk.Object, [], 'Kernel');
 smalltalk.addMethod(

+ 13 - 10
st/Kernel-Tests.st

@@ -279,18 +279,29 @@ testPropertyThatReturnsEmptyString
 ! !
 
 TestCase subclass: #PackageTest
-	instanceVariableNames: 'zorkPackage grulPackage'
+	instanceVariableNames: 'zorkPackage grulPackage backUpCommitPathJs backUpCommitPathSt'
 	category: 'Kernel-Tests'!
 
 !PackageTest methodsFor: 'running'!
 
 setUp
+	backUpCommitPathJs := Package defaultCommitPathJs.
+	backUpCommitPathSt := Package defaultCommitPathSt.
+
+	Package resetCommitPaths.
+
 	zorkPackage := Package new name: 'Zork'.
 	grulPackage := Package new 
 					name: 'Grul';
 					commitPathJs: 'server/grul/js';
 					commitPathSt: 'grul/st';
 					yourself
+!
+
+tearDown
+	 Package 
+		defaultCommitPathJs: backUpCommitPathJs;
+		defaultCommitPathSt: backUpCommitPathSt
 ! !
 
 !PackageTest methodsFor: 'tests'!
@@ -312,25 +323,17 @@ testGrulCommitPathJsShouldBeServerGrulJs
 ! !
 
 PackageTest subclass: #PackageWithDefaultCommitPathChangedTest
-	instanceVariableNames: 'backUpCommitPathJs backUpCommitPathSt'
+	instanceVariableNames: ''
 	category: 'Kernel-Tests'!
 
 !PackageWithDefaultCommitPathChangedTest methodsFor: 'running'!
 
 setUp
 	super setUp.
-	backUpCommitPathJs := Package defaultCommitPathJs.
-	backUpCommitPathSt := Package defaultCommitPathSt.
 
 	Package
 		defaultCommitPathJs: 'javascripts/';
 		defaultCommitPathSt: 'smalltalk/'.
-!
-
-tearDown
-	 Package 
-		defaultCommitPathJs: backUpCommitPathJs;
-		defaultCommitPathSt: backUpCommitPathSt
 ! !
 
 !PackageWithDefaultCommitPathChangedTest methodsFor: 'tests'!

+ 9 - 2
st/Kernel.st

@@ -408,11 +408,11 @@ name: aString
 !
 
 commitPathJs
-	^ commitPathJs := self class defaultCommitPathJs
+	^ commitPathJs ifNil: [self class defaultCommitPathJs]
 !
 
 commitPathSt
-	^ commitPathSt := self class defaultCommitPathSt
+	^ commitPathSt ifNil: [self class defaultCommitPathSt]
 !
 
 commitPathJs: aString
@@ -466,6 +466,13 @@ defaultCommitPathJs: aString
 	defaultCommitPathJs := aString
 ! !
 
+!Package class methodsFor: 'reset'!
+
+resetCommitPaths
+	defaultCommitPathJs := nil.
+	defaultCommitPathSt := nil.
+! !
+
 Object subclass: #Behavior
 	instanceVariableNames: ''
 	category: 'Kernel'!