Skip to content

Commit

Permalink
removed asElementSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Dec 8, 2023
1 parent f9c80f9 commit b3516e2
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 196 deletions.
16 changes: 8 additions & 8 deletions src/Toplo-Tests/ToElementSelectorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
ToElementSelectorTest >> testAsStyleSelectorOnArray [

| selector |
selector := #(#'small-sizing' #x) asElementSelector.
selector := #(#'small-sizing' #x) asStampSelector.
self assert: (selector isKindOf: ToStampSelector).
self assert: (selector allStamps includesAll: #(#'small-sizing' #x)).

Expand All @@ -23,7 +23,7 @@ ToElementSelectorTest >> testAsStyleSelectorOnArray [
ToElementSelectorTest >> testAsStyleSelectorOnArray2 [

| selector |
selector := { 'small-sizing'. 'x' } asElementSelector.
selector := { 'small-sizing'. 'x' } asStampSelector.
self assert: (selector isKindOf: ToStampSelector).
self assert: (selector allStamps includesAll: #( #'small-sizing' #x ))
]
Expand All @@ -32,23 +32,23 @@ ToElementSelectorTest >> testAsStyleSelectorOnArray2 [
ToElementSelectorTest >> testAsStyleSelectorOnArray3 [

| selector |
selector := { 'small-sizing'. 'x' } asElementSelector.
selector := { 'small-sizing'. 'x' } asStampSelector.
self assert: (selector isKindOf: ToStampSelector).
self assert: (selector allStamps includesAll: #( #'small-sizing' #x ))
]

{ #category : 'tests - asToTag' }
ToElementSelectorTest >> testAsStyleSelectorOnObjectNotImplemented [

self should: [Object new asElementSelector] raise: MessageNotUnderstood .
self should: [Object new asTypeSelector] raise: MessageNotUnderstood .

]

{ #category : 'tests - asToTag' }
ToElementSelectorTest >> testAsStyleSelectorOnSet3 [

| selector |
selector := { 'small-sizing'. 'x' } asSet asElementSelector.
selector := { 'small-sizing'. 'x' } asSet asStampSelector.
self assert: (selector isKindOf: ToStampSelector).
self assert: (selector allStamps includesAll: #(#'small-sizing' #x)).

Expand All @@ -58,7 +58,7 @@ ToElementSelectorTest >> testAsStyleSelectorOnSet3 [
ToElementSelectorTest >> testAsStyleSelectorOnString [

| selector |
selector := 'small-sizing' asElementSelector.
selector := 'small-sizing' asStampSelector.
self assert: (selector isKindOf: ToStampSelector).
self assert: selector allStamps asArray equals: #(#'small-sizing').

Expand All @@ -68,7 +68,7 @@ ToElementSelectorTest >> testAsStyleSelectorOnString [
ToElementSelectorTest >> testAsStyleSelectorOnSymbol [

| selector |
selector := #'small-sizing' asElementSelector.
selector := #'small-sizing' asStampSelector.
self assert: (selector isKindOf: ToStampSelector).
self assert: selector allStamps asArray equals: #(#'small-sizing').

Expand All @@ -78,7 +78,7 @@ ToElementSelectorTest >> testAsStyleSelectorOnSymbol [
ToElementSelectorTest >> testAsStyleSelectorOnToElement [

| selector |
selector := ToElement asElementSelector.
selector := ToElement asTypeSelector.
self assert: (selector isKindOf: ToTypeSelector).
self assert: selector type equals: ToElement.

Expand Down
34 changes: 17 additions & 17 deletions src/Toplo-Tests/ToSelectorInterpreterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ ToSelectorInterpreterTest >> testActionSelector [
ToSelectorInterpreterTest >> testChildMixedWithParentSelector [

| button innerElement icon label engine innerElementSelector buttonSelector |
buttonSelector := #button asElementSelector
withChild: #'button-label'
atDepth: 2. "child: #'button-icon' depth: 2"
innerElementSelector := #'inner-element' asElementSelector
buttonSelector := #button asStampSelector
withChild: #'button-label' asStampSelector
atDepth: 2.
innerElementSelector := #'inner-element' asStampSelector
withParent: buttonSelector.

button := ToElement new.
Expand Down Expand Up @@ -127,7 +127,7 @@ ToSelectorInterpreterTest >> testChildSelectorWithTwoChildrenDepth1 [

| button icon label engine buttonSelector |
buttonSelector := (ToStampSelector new addStamp: #button) withChild:
#'button-label'.
#'button-label' asStampSelector.

button := ToElement new.
button addAllStamps: #( #button ).
Expand All @@ -150,8 +150,8 @@ ToSelectorInterpreterTest >> testChildSelectorWithTwoChildrenWithTwoChildSelecto

| button innerElement icon label engine buttonSelector |
buttonSelector := ((ToStampSelector new addStamp: #button)
withChild: #'button-label'
atDepth: 2) withChild: #'button-icon' atDepth: 2.
withChild: #'button-label' asStampSelector
atDepth: 2) withChild: #'button-icon' asStampSelector atDepth: 2.

button := ToElement new id: #button.
button addAllStamps: #( #button ).
Expand Down Expand Up @@ -359,7 +359,7 @@ ToSelectorInterpreterTest >> testRuleWithAndSiblingSelector [
" a rule with an And operator "

| selector engine parent child sibling |
selector := (ToStampSelector new addStamp: #child ) sibling: #sibling.
selector := (ToStampSelector new addStamp: #child ) sibling: #sibling asStampSelector.

parent := ToElement new.
child := ToElement new addStamp: #child.
Expand All @@ -377,7 +377,7 @@ ToSelectorInterpreterTest >> testRuleWithAndSiblingSelector2 [

| selector engine parent child sibling |
selector := ((ToStampSelector new addStamp: #child) withParent:
#( #parent )) sibling: #sibling.
#( #parent ) asStampSelector ) sibling: #sibling asStampSelector.

parent := ToElement new.
child := ToElement new addStamp: #child.
Expand All @@ -400,7 +400,7 @@ ToSelectorInterpreterTest >> testRuleWithAndSiblingSelector3 [

| selector engine parent child sibling |
selector := ((ToStampSelector new addStamp: #child) withParent:
#( #parent )) sibling: #sibling.
#( #parent ) asStampSelector) sibling: #sibling asStampSelector.

parent := ToElement new.
child := ToElement new addStamp: #child.
Expand All @@ -423,8 +423,8 @@ ToSelectorInterpreterTest >> testRuleWithAndTwoSiblingSelector [

| selector engine parent child sibling1 sibling2 |
selector := (((ToStampSelector new addStamp: #child) withParent:
#( #parent )) sibling: #'image-sibling') sibling:
#'label-sibling'.
#( #parent ) asStampSelector) sibling: #'image-sibling' asStampSelector) sibling:
#'label-sibling' asStampSelector.

parent := ToElement new.
child := ToElement new addStamp: #child.
Expand All @@ -447,8 +447,8 @@ ToSelectorInterpreterTest >> testRuleWithAndTwoSiblingSelector2 [

| selector engine parent child sibling1 sibling2 |
selector := (((ToStampSelector new addStamp: #child) withParent:
#( #parent )) sibling: #( #image #'image-sibling' ))
sibling: #( #label #'label-sibling' ).
#( #parent ) asStampSelector ) sibling: #( #image #'image-sibling' ) asStampSelector )
sibling: #( #label #'label-sibling' ) asStampSelector.

parent := ToElement new.
child := ToElement new addStamp: #child.
Expand All @@ -471,9 +471,9 @@ ToSelectorInterpreterTest >> testRuleWithAndTwoSiblingSelector3 [

| selector engine parent inner child sibling1 sibling2 |
selector := (((ToStampSelector new addStamp: #child)
withParent: #( #parent )
atDepth: 2) sibling: #( #image #'image-sibling' ))
sibling: #( #label #'label-sibling' ).
withParent: #( #parent ) asStampSelector
atDepth: 2) sibling: #( #image #'image-sibling' ) asStampSelector)
sibling: #( #label #'label-sibling' ) asStampSelector.

parent := ToElement new.
inner := ToElement new.
Expand Down
28 changes: 14 additions & 14 deletions src/Toplo-Tests/ToStyleScriptTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ ToStyleScriptTest >> testRuleStackWithSelectStyle [
| styleScript styleRule rhs |
rhs := ToIdSelector new id: #button.
styleScript := ToStyleScript new.
styleScript select: #button style: [ :theStyleScript |
theStyleScript select: #danger asElementSelector style: [ ].
theStyleScript select: #dashed asElementSelector style: [ ] ].
styleScript select: #button asStampSelector style: [ :theStyleScript |
theStyleScript select: #danger asStampSelector style: [ ].
theStyleScript select: #dashed asStampSelector style: [ ] ].
self assert: styleScript styleRules size equals: 1.
styleRule := styleScript styleRules first.
self assert: (styleRule selector isKindOf: ToStampSelector).
Expand All @@ -85,7 +85,7 @@ ToStyleScriptTest >> testRuleStackWithSelectStyle2 [
| styleScript styleRule wasHere top |
styleScript := ToStyleScript new.
wasHere := false.
styleScript select: #button style: [ :theStyleScript |
styleScript select: #button asStampSelector style: [ :theStyleScript |
wasHere := true.
self assert: theStyleScript identicalTo: styleScript.
self assert: theStyleScript ruleStack size equals: 1.
Expand All @@ -105,8 +105,8 @@ ToStyleScriptTest >> testRuleStackWithSelectStyleWithSubSelect [
| styleScript styleRule wasHere top |
styleScript := ToStyleScript new.
wasHere := false.
styleScript select: #button style: [ :scr |
scr select: #label style: [
styleScript select: #button asStampSelector style: [ :scr |
scr select: #label asStampSelector style: [
wasHere := true.
self assert: scr ruleStack size equals: 2.
top := scr ruleStack top ] ].
Expand All @@ -125,7 +125,7 @@ ToStyleScriptTest >> testSelectStyle [
| styleRule rhs styleScript |
rhs := ToIdSelector new id: #button.
(styleScript := ToStyleScript new)
select: #button
select: #button asStampSelector
style: [ :theStyleScript | ].
self assert: styleScript styleRules size equals: 1.
styleRule := styleScript styleRules first.
Expand Down Expand Up @@ -181,9 +181,9 @@ ToStyleScriptTest >> testSelectStyleWithSubRule [

| styleScript styleRule |
styleScript := ToStyleScript new.
styleScript select: #button style: [ :theStyleScript |
theStyleScript select: #danger asElementSelector style: [ ].
theStyleScript select: #dashed asElementSelector style: [ ] ].
styleScript select: #button asStampSelector style: [ :theStyleScript |
theStyleScript select: #danger asStampSelector style: [ ].
theStyleScript select: #dashed asStampSelector style: [ ] ].
self assert: styleScript styleRules size equals: 1.
styleRule := styleScript styleRules first.
self assert: (styleRule selector isKindOf: ToStampSelector).
Expand All @@ -198,9 +198,9 @@ ToStyleScriptTest >> testSelectStyleWithSubRule2 [
| styleScript |
self flag: 'add assertions'.
(styleScript := ToStyleScript new)
select: #button asElementSelector
select: #button asStampSelector
style: [ :sr |
sr select: #checkable asElementSelector style: [ :sr2 | ] ]
sr select: #checkable asStampSelector style: [ :sr2 | ] ]
]

{ #category : 'tests' }
Expand Down Expand Up @@ -428,14 +428,14 @@ ToStyleScriptTest >> testWriteWith3 [

| styleScript styleRule dangerRule dangerWriter |
styleScript := ToStyleScript new.
styleScript select: #button style: [ :theStyleScript |
styleScript select: #button asStampSelector style: [ :theStyleScript |
theStyleScript
write: (ToFeatureProperty new name: #border)
with: Color black.
theStyleScript
write: (ToFeatureProperty new name: #background)
with: Color gray.
theStyleScript select: #danger style: [
theStyleScript select: #danger asStampSelector style: [
theStyleScript
write: (ToFeatureProperty new name: #border)
with: Color red ] ].
Expand Down
Loading

0 comments on commit b3516e2

Please sign in to comment.