[Pkg] The Trunk: CollectionsTests-mt.326.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Nov 18 16:30:34 UTC 2019
Marcel Taeumel uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-mt.326.mcz
==================== Summary ====================
Name: CollectionsTests-mt.326
Author: mt
Time: 18 November 2019, 5:30:37.365051 pm
UUID: dbd08425-8bfa-3a41-b1ae-d11ad450a255
Ancestors: CollectionsTests-mt.325
Adds tests about adding attributes to text.
=============== Diff against CollectionsTests-mt.325 ===============
Item was changed:
+ ----- Method: TextTest>>fixturesFormat (in category 'fixtures') -----
- ----- Method: TextTest>>fixturesFormat (in category 'tests') -----
fixturesFormat
^ {
{ '\{ \} \\ foo {1} bar {2}' asText
addAttribute: TextEmphasis bold from: 3 to: 10;
addAttribute: TextEmphasis italic from: 12 to: 18;
yourself.
#(12 'string').
'{ } \ foo 12 bar string' asText
addAttribute: TextEmphasis bold from: 2 to: 7;
addAttribute: TextEmphasis italic from: 9 to: 14;
yourself }.
{ '\{ \} \\ foo {2} bar {1}' asText.
{ 'string' asText
addAttribute: TextEmphasis bold from: 2 to: 4;
yourself.
12 }.
'{ } \ foo 12 bar string' asText
addAttribute: TextEmphasis bold from: 19 to: 21;
yourself }.
{ '\{1}' asText.
#().
'{1}' asText }.
{ '\{1}{1}' asText allBold.
{ $a asText
addAttribute: TextEmphasis italic;
yourself }.
'{1}a' asText allBold
addAttribute: TextEmphasis italic from: 4 to: 4;
yourself }.
{ 'foo' asText.
#().
'foo' asText }.
}!
Item was changed:
+ ----- Method: TextTest>>fixturesFormatErrors (in category 'fixtures') -----
- ----- Method: TextTest>>fixturesFormatErrors (in category 'tests') -----
fixturesFormatErrors
^ #(
'{1 }'
'{1abc}'
'{ 1}'
'{ 1.0 }'
'{1'
'{1 foo'
'{2}'
'{0}'
'{-0}'
'{-1}'
)!
Item was added:
+ ----- Method: TextTest>>test02Format (in category 'tests') -----
+ test02Format
+
+ self fixturesFormat do: [ :fixture | | expectedResult actualResult |
+ expectedResult := fixture third.
+ actualResult := fixture first format: fixture second.
+ self
+ assert: expectedResult equals: actualResult;
+ assert: expectedResult runs size equals: actualResult runs size.
+ 1 to: expectedResult size do: [ :i |
+ self
+ assert: (expectedResult attributesAt: i) asSet
+ equals: (actualResult attributesAt: i) asSet ] ]!
Item was added:
+ ----- Method: TextTest>>test03FormatErrors (in category 'tests') -----
+ test03FormatErrors
+
+ self fixturesFormatErrors do: [ :each |
+ self should: [ each asText format: { 'x' } ] raise: Error ]!
Item was added:
+ ----- Method: TextTest>>test04AddAttribute (in category 'tests') -----
+ test04AddAttribute
+
+ | text attributeOne attributeTwo |
+ text := Text fromString: 'abc'.
+ attributeOne := TextEmphasis bold.
+ attributeTwo := TextColor color: Color yellow.
+
+ 1 to: text size do: [:index |
+ self assert: (text attributesAt: index) isEmpty].
+
+ text addAttribute: attributeOne.
+ 1 to: text size do: [:index |
+ self assert: {attributeOne} equals: (text attributesAt: index)].
+
+ text addAttribute: attributeTwo.
+ 1 to: text size do: [:index |
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: index)].
+ !
Item was added:
+ ----- Method: TextTest>>test05AddAttributeFromTo (in category 'tests') -----
+ test05AddAttributeFromTo
+
+ | text attributeOne attributeTwo |
+ attributeOne := TextEmphasis bold.
+ attributeTwo := TextColor color: Color yellow.
+
+ text := Text fromString: 'abc'.
+ self assert: (text attributesAt: 1) isEmpty.
+ self assert: (text attributesAt: 2) isEmpty.
+ self assert: (text attributesAt: 3) isEmpty.
+
+ text addAttribute: attributeOne from: 2 to: 3.
+ self assert: (text attributesAt: 1) isEmpty.
+ self assert: {attributeOne} equals: (text attributesAt: 2).
+ self assert: {attributeOne} equals: (text attributesAt: 3).
+
+ text addAttribute: attributeTwo from: 1 to: 2.
+ self assert: {attributeTwo} equals: (text attributesAt: 1).
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: 2).
+ self assert: {attributeOne} equals: (text attributesAt: 3).
+ !
Item was added:
+ ----- Method: TextTest>>test06AddAllAttributes (in category 'tests') -----
+ test06AddAllAttributes
+
+ | text attributeOne attributeTwo |
+ attributeOne := TextEmphasis bold.
+ attributeTwo := TextColor color: Color yellow.
+
+ text := Text fromString: 'abc'.
+ self assert: (text attributesAt: 1) isEmpty.
+ self assert: (text attributesAt: 2) isEmpty.
+ self assert: (text attributesAt: 3) isEmpty.
+
+ text addAllAttributes: {attributeOne. attributeTwo}.
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: 1).
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: 2).
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: 3).!
Item was added:
+ ----- Method: TextTest>>test07AddAllAttributesFromTo (in category 'tests') -----
+ test07AddAllAttributesFromTo
+
+ | text attributeOne attributeTwo |
+ attributeOne := TextEmphasis bold.
+ attributeTwo := TextColor color: Color yellow.
+
+ text := Text fromString: 'abc'.
+ self assert: (text attributesAt: 1) isEmpty.
+ self assert: (text attributesAt: 2) isEmpty.
+ self assert: (text attributesAt: 3) isEmpty.
+
+ text addAllAttributes: {attributeOne. attributeTwo} from: 2 to: 3.
+ self assert: (text attributesAt: 1) isEmpty.
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: 2).
+ self assert: {attributeOne. attributeTwo} equals: (text attributesAt: 3).!
Item was removed:
- ----- Method: TextTest>>testFormat (in category 'tests') -----
- testFormat
-
- self fixturesFormat do: [ :fixture | | expectedResult actualResult |
- expectedResult := fixture third.
- actualResult := fixture first format: fixture second.
- self
- assert: expectedResult equals: actualResult;
- assert: expectedResult runs size equals: actualResult runs size.
- 1 to: expectedResult size do: [ :i |
- self
- assert: (expectedResult attributesAt: i) asSet
- equals: (actualResult attributesAt: i) asSet ] ]!
Item was removed:
- ----- Method: TextTest>>testFormatErrors (in category 'tests') -----
- testFormatErrors
-
- self fixturesFormatErrors do: [ :each |
- self should: [ each asText format: { 'x' } ] raise: Error ]!
More information about the Packages
mailing list