Nicolas Cellier uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-nice.323.mcz ==================== Summary ==================== Name: CollectionsTests-nice.323 Author: nice Time: 17 November 2019, 12:46:56.171035 pm UUID: e817d369-4c05-4944-9033-86aabc522ac6 Ancestors: CollectionsTests-pre.322 Test a few CharacterSet union:/intersection: edge cases =============== Diff against CollectionsTests-pre.322 =============== Item was added: + ----- Method: CharacterSetTest>>testIntersectionOfComplement (in category 'tests') ----- + testIntersectionOfComplement + | intersection | + intersection := ('abcd' as: CharacterSet) complement intersection: ('cdef' as: CharacterSet) complement. + self assert: intersection = ('abcdef' as: CharacterSet) complement.! Item was added: + ----- Method: CharacterSetTest>>testIntersectionOfLazy (in category 'tests') ----- + testIntersectionOfLazy + | digits intersection1 intersection2 az lazyNonDigitNonSeparator lazyNotazNotUppercase | + digits := ($0 to: $9) as: CharacterSet. + az := ($a to: $z) as: CharacterSet. + lazyNonDigitNonSeparator := digits complement reject: #isSeparator. + lazyNotazNotUppercase := az complement reject: #isUppercase. + intersection1 := lazyNotazNotUppercase intersection: lazyNonDigitNonSeparator. + intersection2 := lazyNonDigitNonSeparator intersection: lazyNotazNotUppercase. + self assert: (digits noneSatisfy: [:d | intersection1 includes: d]). + self assert: (digits noneSatisfy: [:d | intersection2 includes: d]). + self assert: ('abc' noneSatisfy: [:d | intersection1 includes: d]). + self assert: ('abc' noneSatisfy: [:d | intersection2 includes: d]). + self assert: ('ABC' noneSatisfy: [:d | intersection1 includes: d]). + self assert: ('ABC' noneSatisfy: [:d | intersection2 includes: d]). + self assert: (Character separators noneSatisfy: [:d | intersection1 includes: d]). + self assert: (Character separators noneSatisfy: [:d | intersection2 includes: d]). + self assert: ('()[]{}' allSatisfy: [:d | intersection1 includes: d]). + self assert: ('()[]{}' allSatisfy: [:d | intersection2 includes: d]).! Item was added: + ----- Method: CharacterSetTest>>testIntersectionOfNonLazyWithLazyIsNotLazy (in category 'tests') ----- + testIntersectionOfNonLazyWithLazyIsNotLazy + | nonDigit az lazyLetters | + nonDigit := (($0 to: $9) as: CharacterSet) complement. + lazyLetters := nonDigit select: #isLetter. + az := ($a to: $z) asCharacterSet. + self assert: (az intersection: lazyLetters) equals: az. + self assert: (lazyLetters intersection: az) equals: az.! Item was added: + ----- Method: CharacterSetTest>>testUnionOfComplement (in category 'tests') ----- + testUnionOfComplement + | union | + union := ('abcd' as: CharacterSet) complement union: ('cdef' as: CharacterSet) complement. + self assert: union = ('cd' as: CharacterSet) complement.! Item was added: + ----- Method: CharacterSetTest>>testUnionOfLazy (in category 'tests') ----- + testUnionOfLazy + | digits nonDigit lazyLetters lazyNonLetters union1 union2 | + digits := ($0 to: $9) as: CharacterSet. + nonDigit := digits complement. + lazyLetters := nonDigit select: #isLetter. + lazyNonLetters := nonDigit reject: #isLetter. + union1 := lazyNonLetters union: lazyLetters. + union2 := lazyLetters union: lazyNonLetters. + self assert: (digits noneSatisfy: [:d | union1 includes: d]). + self assert: (digits noneSatisfy: [:d | union2 includes: d]). + self assert: ('abc' allSatisfy: [:d | union1 includes: d]). + self assert: ('abc' allSatisfy: [:d | union2 includes: d]). + self assert: ('()[]{}' allSatisfy: [:d | union1 includes: d]). + self assert: ('()[]{}' allSatisfy: [:d | union2 includes: d]).! Item was added: + ----- Method: CharacterSetTest>>testUnionWithLazy (in category 'tests') ----- + testUnionWithLazy + | digits nonDigit lazyLetters az union1 union2 | + digits := ($0 to: $9) as: CharacterSet. + nonDigit := digits complement. + lazyLetters := nonDigit select: #isLetter. + union1 := digits union: lazyLetters. + union2 := lazyLetters union: digits. + az := ($a to: $z) as: CharacterSet. + self assert: (digits allSatisfy: [:d | union1 includes: d]). + self assert: (digits allSatisfy: [:d | union2 includes: d]). + self assert: (az allSatisfy: [:d | union1 includes: d]). + self assert: (az allSatisfy: [:d | union2 includes: d]). + self assert: ('()[]{}' noneSatisfy: [:d | union1 includes: d]). + self assert: ('()[]{}' noneSatisfy: [:d | union2 includes: d]).! |
Free forum by Nabble | Edit this page |