Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section or page about rewriting of code #239

Open
jecisc opened this issue Sep 18, 2019 · 0 comments
Open

Add section or page about rewriting of code #239

jecisc opened this issue Sep 18, 2019 · 0 comments

Comments

@jecisc
Copy link
Member

jecisc commented Sep 18, 2019

Here is a script I did yesterday that is cool IMO:

r := RBParseTreeRewriter new.
r replace: '`@receiver isEmpty should beTrue' with: 'self assertEmpty: `@receiver'.
r replace: '`@receiver should beTrue' with: 'self assert: `@receiver'.
r replace: '`@receiver isEmpty should beFalse' with: 'self denyEmpty: `@receiver'.
r replace: '`@receiver should beFalse' with: 'self deny: `@receiver'.
r replace: '`@receiver should = `@statement1' with: 'self assert: `@receiver equals: `@statement1'.
r replace: '`@receiver should not = `@statement1' with: 'self deny: `@receiver equals: `@statement1'.
r replace: '`@receiver should include: `@statement1' with: 'self assert: (`@receiver includes: `@statement1)'.
r replace: '`@receiver should not include: `@statement1' with: 'self deny: (`@receiver includes: `@statement1)'.
r replace: '`@receiver should equal: `@statement1' with: 'self assert: `@receiver equals: `@statement1'.
r replace: '`@receiver should beKindOf: `@statement1' with: 'self assert: (`@receiver isKindOf: `@statement1)'.
r replace: '`@receiver should beginWith: `@statement1' with: 'self assert: (`@receiver beginsWith: `@statement1)'.
r replace: '`@receiver should > `@statement1' with: 'self assert: (`@receiver > `@statement1)'.
r replace: '`@receiver should not raise: `@statement1' with: 'self shouldnt: `@receiver raise: `@statement1'.

'Fame-Tests-Core' asPackage definedClasses select: [ :e | e inheritsFrom: TestCase ] thenDo: [ :class | 
	
	class methods select: [ :m | m selector beginsWith: 'test' ] thenDo: [ :m |
		n := m parseTree.
		r executeTree: n.
		class compile: n formattedCode.
		 ]
	 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant