Nicolas Cellier uploaded a new version of VersionNumberTests to project The Trunk:
http://source.squeak.org/trunk/VersionNumberTests-nice.3.mcz ==================== Summary ==================== Name: VersionNumberTests-nice.3 Author: nice Time: 27 December 2009, 3:35:40 am UUID: 873b36f9-5e98-4980-8c78-cd6198742a72 Ancestors: VersionNumberTests-it.2 Cosmetic: move or remove a few temps inside closures =============== Diff against VersionNumberTests-it.2 =============== Item was changed: ----- Method: VersionNumberTest>>testFromString (in category 'Tests') ----- testFromString "note: a version number string '3 2 1' will only consider the first number as a version, ignoring the trailing '2 1'. Whether it is a desired feature or not should be determined." + | numbers | - | numbers version | numbers := { '' -> #(). '1 '-> #(1). '1.2' -> #(1 2). '3.4.5' -> #(3 4 5). '6.7.890' -> #(6 7 890). '9 8' -> #(9). '98 7 6' -> #(98). '54.3 2 1' -> #(54 3) }. + numbers do: [:item | | version | - numbers do: [:item | version := VersionNumber fromString: (item key). self assert: (VersionNumber = version class). self assert: ((item value) = version numbers). ]. self shouldnt: [VersionNumber fromString: '9999999999999999999'] raise: TestResult error. self should: [VersionNumber fromString: '-1'] raise: TestResult error. self should: [VersionNumber fromString: ' 1'] raise: TestResult error. "notice leading space!!" self should: [VersionNumber fromString: 'version'] raise: TestResult error. self should: [VersionNumber fromString: '1.2.10.20.-1.4'] raise: TestResult error. self should: [VersionNumber fromString: '1.2.10.20.R4'] raise: TestResult error. ! Item was changed: ----- Method: VersionNumberTest>>testAsVersion (in category 'Tests') ----- testAsVersion "note: a version number string '3 2 1' will only consider the first number as a version, ignoring the trailing '2 1'. Whether it is a desired feature or not should be determined." + | numbers | - | numbers version | numbers := { '' -> #(). '1 '-> #(1). '1.2' -> #(1 2). '3.4.5' -> #(3 4 5). '6.7.890' -> #(6 7 890). '9 8' -> #(9). '98 7 6' -> #(98). '54.3 2 1' -> #(54 3) }. + numbers do: [:item | | version | - numbers do: [:item | version := (item key) asVersion. self assert: (VersionNumber = version class). self assert: ((item value) = version numbers). ]. self shouldnt: ['9999999999999999999' asVersion] raise: TestResult error. self should: ['-1' asVersion] raise: TestResult error. self should: [' 1' asVersion] raise: TestResult error. "notice leading space!!" self should: ['version' asVersion] raise: TestResult error. self should: ['1.2.10.20.-1.4' asVersion] raise: TestResult error. self should: ['1.2.10.20.R4' asVersion] raise: TestResult error. ! Item was changed: ----- Method: VersionNumberTest>>testFromCollection (in category 'Tests') ----- testFromCollection + | numbers | - | numbers version | numbers := #(#(1) #(1 2) #(3 4 5) #(6 7 890)). + numbers do: [:item | | version | - numbers do: [:item | version := VersionNumber fromCollection: item. self assert: (VersionNumber = version class). self assert: (item = version numbers). ]. self shouldnt: [VersionNumber fromCollection: #()] raise: TestResult error. self shouldnt: [VersionNumber fromCollection: #(9999999999999999999)] raise: TestResult error. self should: [VersionNumber fromCollection: #(0)] raise: TestResult error. self should: [VersionNumber fromCollection: #(-1)] raise: TestResult error. self should: [VersionNumber fromCollection: #(1 2 10 20 -1 4)] raise: TestResult error. self should: [VersionNumber fromCollection: #(1 2 10 20 '1' 4)] raise: TestResult error. self should: [VersionNumber fromCollection: #('version')] raise: TestResult error. ! Item was changed: ----- Method: VersionNumberTest>>testNext (in category 'Tests') ----- testNext + | numbers | - | numbers version temp | numbers := #(#(1) #(9) #(1 2) #(1 9) #(1 9 1) #(1 9 9) #(1 1 1 1 1 99)). + numbers do: [:item | | version temp | - numbers do: [:item | version := VersionNumber fromCollection: item. temp := item copy. temp atLast: 1 put: (temp last + 1). self assert: (temp = version next numbers). ].! Item was changed: ----- Method: VersionNumberTest>>testBranchNext (in category 'Tests') ----- testBranchNext + | numbers | - | numbers version temp | numbers := #(#(1) #(9) #(1 2) #(1 9) #(1 9 1) #(1 9 9) #(1 1 1 1 1 99)). + numbers do: [:item | | temp version | - numbers do: [:item | version := VersionNumber fromCollection: item. temp := item asOrderedCollection. temp add: 1. self assert: (temp asArray = version branchNext numbers). ].! Item was changed: ----- Method: VersionNumberTest>>testInitializeNumbers (in category 'Tests') ----- testInitializeNumbers + | numbers | - | numbers version | numbers := #(#(1) #(1 2) #(3 4 5) #(6 7 890)). + numbers do: [:item | | version | - numbers do: [:item | version := VersionNumber new initializeNumbers: item. self assert: (VersionNumber = version class). self assert: (item = version numbers). ]. self shouldnt: [VersionNumber new initializeNumbers: #()] raise: TestResult error. self shouldnt: [VersionNumber new initializeNumbers: #(9999999999999999999)] raise: TestResult error. self should: [VersionNumber new initializeNumbers: #(0)] raise: TestResult error. self should: [VersionNumber new initializeNumbers: #(-1)] raise: TestResult error. self should: [VersionNumber new initializeNumbers: #(1 2 10 20 -1 4)] raise: TestResult error. self should: [VersionNumber new initializeNumbers: #(1 2 10 20 '1' 4)] raise: TestResult error. self should: [VersionNumber new initializeNumbers: #('version')] raise: TestResult error. ! Item was changed: ----- Method: VersionNumberTest>>testPrevious (in category 'Tests') ----- testPrevious + | numbers | - | numbers version | numbers := { #(1) -> #(). #(2) -> #(1). #(9) -> #(8). #(7 9) -> #(7 8). #(7 1) -> #(7). #(9 9 9 9 1) -> #(9 9 9 9). }. + numbers do: [:item | | version | - numbers do: [:item | version := VersionNumber fromCollection: (item key). self assert: ((item value) = version previous numbers). ].! |
Free forum by Nabble | Edit this page |