Added more tests for reported issues #2 & #3.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 18 Mar 2013 19:18:45 +0000
changeset 266 af2b7ccf99c3
parent 265 9a4e7514dba8
child 267 1bd4eaf81690
Added more tests for reported issues #2 & #3.
mercurial/HGStXTests.st
--- a/mercurial/HGStXTests.st	Mon Mar 18 17:24:29 2013 +0000
+++ b/mercurial/HGStXTests.st	Mon Mar 18 19:18:45 2013 +0000
@@ -75,8 +75,8 @@
         (cls package notNil and:[cls package startsWith:'mocks']) ifTrue:[
             classes add: cls
         ] ifFalse:[
-            cls methodsDo:[:m|(m package notNil and:[m package startsWith:'mocks']) ifTrue:[methods add: cls]].
-            cls class methodsDo:[:m|(m package notNil and:[m package startsWith:'mocks']) ifTrue:[methods add: cls]].
+            cls methodsDo:[:m|(m package notNil and:[m package startsWith:'mocks']) ifTrue:[methods add: m]].
+            cls class methodsDo:[:m|(m package notNil and:[m package startsWith:'mocks']) ifTrue:[methods add: m]].
         ]
     ].
     Class withoutUpdatingChangesDo:[
@@ -94,7 +94,7 @@
     ]
 
     "Created: / 16-11-2012 / 19:00:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 04-12-2012 / 02:14:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-03-2013 / 19:12:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 test_infrastructure
@@ -728,6 +728,184 @@
 "/    self assert: (Smalltalk at:#mocks_hg_p1) hgLogicalRevision revno = 2.
 
     "Created: / 18-03-2013 / 17:21:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_10a
+    "
+        Test if project definition class is automatically updated when committing.
+
+        Case a: add a new class
+    "
+
+    | repo cls pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    cls := Object subclass:#MockHGP1Baz instanceVariableNames:'' classVariableNames:'' poolDictionaries:''.
+    cls package: #'mocks:hg/p1'.
+    (cls compile:'zork ^ 1' classified:'test') package: #'mocks:hg/p1'.
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_10a'.
+    ct doPrepareWorkingCopy.
+
+    self assert: ((Smalltalk at: #'mocks_hg_p1') classNamesAndAttributes includes: #MockHGP1Baz).
+    "
+        repo workingCopy browse
+    "
+"/    self assert: (Smalltalk at:#mocks_hg_p1) hgLogicalRevision revno = 2.
+
+    "Created: / 18-03-2013 / 18:40:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_10b
+    "
+        Test if project definition class is automatically updated when committing.
+
+        Case b: remove a class
+    "
+
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    Smalltalk removeClass: (Smalltalk at: #MockHGP1Bar).
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_10b'.
+    ct doPrepareWorkingCopy.
+
+    self assert: ((Smalltalk at: #'mocks:hg/p1') classNamesAndAttributes includes: #MockHGP1Bar) not.
+
+    "Created: / 18-03-2013 / 18:41:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_10c
+    "
+        Test if project definition class is automatically updated when committing.
+
+        Case c: add an extension
+    "
+
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    (UndefinedObject compile:'zork ^ 1' classified:'test') package: #'mocks:hg/p1'.
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_10c'.
+    ct doPrepareWorkingCopy.
+
+    self assert: ((Smalltalk at: #'mocks:hg/p1') extensionMethodNames includes: #zork) not.
+
+    "Created: / 18-03-2013 / 18:42:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_11a
+    "
+        Test if commit task detects method protocol changes
+    "
+
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    ((Smalltalk at: #MockHGP1Bar) compiledMethodAt: #qux) category: 'new category'.
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_11a'.
+    ct do.
+
+    "
+        repo workingCopy browse
+    "
+    self assert: ((repo @ 2 / 'MockHGP1Bar.st') contents asString includesString:'new category').
+
+    "Created: / 18-03-2013 / 18:57:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_11b
+    "
+        Test if commit task detects class category changes
+    "
+
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    (Smalltalk at: #MockHGP1Bar) category:'new category'.
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_11b'.
+    ct do.
+
+    "
+        repo workingCopy browse
+    "
+    self assert: ((repo @ 2 / 'MockHGP1Bar.st') contents asString includesString:'new category').
+
+    "Created: / 18-03-2013 / 18:59:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_11c
+    "
+        Test if commit task detects class removal
+    "
+
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    Smalltalk removeClass: (Smalltalk at: #MockHGP1Bar).
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_11c'.
+    ct do.
+
+    "
+        repo workingCopy browse
+    "
+    self should:[(repo @ 2 / 'MockHGP1Bar.st')] raise: HGError
+
+    "Created: / 18-03-2013 / 19:00:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_commit_11d
+    "
+        Test if commit task detects method removal
+    "
+
+    | repo pm ct |
+
+    repo := self repositoryNamed: 'mocks/hg/p1'.
+    self assert: (Smalltalk loadPackage: 'mocks:hg/p1').
+
+    (Smalltalk at: #MockHGP1Bar) removeSelector: 'qux'.
+
+    pm := HGPackageModel named: #'mocks:hg/p1'.
+    ct := pm commitTask.
+    ct message:'test_commit_11b'.
+    ct do.
+
+    "
+        repo workingCopy browse
+    "
+    self assert: ((repo @ 2 / 'MockHGP1Bar.st') contents asString includesString:'qux') not
+
+    "Created: / 18-03-2013 / 19:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGStXTests methodsFor:'tests - manager API'!