[Vm-dev] VM Maker: VMMaker-dtl.303.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Mar 12 01:27:07 UTC 2013


David T. Lewis uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker-dtl.303.mcz

==================== Summary ====================

Name: VMMaker-dtl.303
Author: dtl
Time: 11 March 2013, 9:25:44.432 pm
UUID: 2ff403f4-35f2-4889-899f-e89f4e421870
Ancestors: VMMaker-dtl.302

Add SlangTest unit tests to document the slang C preprocessor directives.

Background:
Mantis 0005238: Integer bug on 64bit image/32bit VM
VMMaker-dtl.133: VMMaker 3.11.0 Add support for C preprocessor statements in Slang

=============== Diff against VMMaker-dtl.302 ===============

Item was added:
+ ----- Method: SlangTest>>testIfElseEndif (in category 'testing preprocessor directives') -----
+ testIfElseEndif
+ 	"Test isDefinedTrueExpression:inSmalltalk:comment:ifTrue:ifFalse: "
+ 
+ 	"(SlangTest selector: #testIfElseEndif) run"
+ 
+ 	| cString stringWithoutWhiteSpace lines |
+ 	"verify that the default Smalltalk block that is evaluated in simulation"
+ 	self assert: SlangTestSupportInterpreter new ifDefinedTrueElseEndif = 4.
+ 
+ 	"verify generated C string"
+ 	cString := SlangTestSupportInterpreter asCString: #ifDefinedTrueElseEndif.
+ 	lines := (cString findTokens: Character cr) select: [:e |
+ 		{
+ 			'# if (SIZE == 8)  // SIZE may be 4 or 8' .
+ 			'	return 8;' .
+ 			'# else' .
+ 			'	return 4;' .
+ 			'# endif  // SIZE == 8'
+ 		} includes: e ].
+ 	self should: lines size = 5.
+ 	self should: ('*return 8*' match: lines second).
+ 	self should: ('*return 4*' match: lines fourth).
+ 
+ 	"check the rest of the method, ignoring whitespace"
+ 	cString := SlangTestSupportInterpreter asCString: #ifDefinedTrueElseEndif.
+ 	stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
+ 	self should: stringWithoutWhiteSpace =
+ 		'sqIntifDefinedTrueElseEndif(void){#if(SIZE==8)//SIZEmaybe4or8return8;#elsereturn4;#endif//SIZE==8returnnull;}'.
+ 
+ "
+ sqInt ifDefinedTrueElseEndif(void) {
+ 	
+ # if (SIZE == 8)  // SIZE may be 4 or 8
+ 	return 8;
+ # else
+ 	return 4;
+ # endif  // SIZE == 8
+ 	
+ 	return null;
+ }
+ "!

Item was added:
+ ----- Method: SlangTest>>testIfdefElseEndif (in category 'testing preprocessor directives') -----
+ testIfdefElseEndif
+ 	"Test isDefined:inSmalltalk:comment:ifTrue:ifFalse: "
+ 
+ 	"(SlangTest selector: #testIfdefElseEndif) run"
+ 
+ 	| cString stringWithoutWhiteSpace lines |
+ 	self flag: #FIXME. "See redundant implementation in oscog #cppIf:ifTrue:ifFalse:"
+ 
+ 	"verify that the default Smalltalk block that is evaluated in simulation"
+ 	self assert: SlangTestSupportInterpreter new ifdefElseEndif = #defaultBlockForSimulation.
+ 
+ 	"verify generated C string"
+ 	cString := SlangTestSupportInterpreter asCString: #ifdefElseEndif.
+ 	lines := (cString findTokens: Character cr) select: [:e |
+ 		{
+ 			'# ifdef HAVE_FOO  // some platforms do not support foo properly' .
+ 			'	return 1;' .
+ 			'# else' .
+ 			'	return 0;' .
+ 			'# endif  // HAVE_FOO'
+ 		} includes: e ].
+ 	self should: lines size = 5.
+ 	self should: ('*return 1*' match: lines second).
+ 	self should: ('*return 0*' match: lines fourth).
+ 
+ 	"check the rest of the method, ignoring whitespace"
+ 	stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
+ 	self should: stringWithoutWhiteSpace =
+ 		'sqIntifdefElseEndif(void){#ifdefHAVE_FOO//someplatformsdonotsupportfooproperlyreturn1;#elsereturn0;#endif//HAVE_FOOreturnnull;}'.
+ 
+ "
+ sqInt ifdefElseEndif(void) {
+ 	
+ # ifdef HAVE_FOO  // some platforms do not support foo properly
+ 	return 1;
+ # else
+ 	return 0;
+ # endif  // HAVE_FOO
+ 	
+ 	return null;
+ }
+ "!

Item was added:
+ ----- Method: SlangTest>>testIfdefEndif (in category 'testing preprocessor directives') -----
+ testIfdefEndif
+ 	"Test isDefined:inSmalltalk:comment:ifTrue: "
+ 
+ 	"(SlangTest selector: #testIfdefEndif) run"
+ 
+ 	| cString stringWithoutWhiteSpace lines |
+ 	self flag: #FIXME. "See redundant implementation in oscog #cppIf:ifTrue:"
+ 
+ 	"verify that the default Smalltalk block that is evaluated in simulation"
+ 	self assert: SlangTestSupportInterpreter new ifdefEndif = #defaultBlockForSimulation.
+ 
+ 	"verify generated C string"
+ 	cString := SlangTestSupportInterpreter asCString: #ifdefEndif.
+ 	lines := (cString findTokens: Character cr) select: [:e |
+ 		{
+ 			'# ifdef HAVE_FOO  // some platforms do not support foo properly' .
+ 			'	return 1;' .
+ 			'# endif  // HAVE_FOO'
+ 		} includes: e ].
+ 	self should: lines size = 3.
+ 
+ 	"check the rest of the method, ignoring whitespace"
+ 	cString := SlangTestSupportInterpreter asCString: #ifdefEndif.
+ 	stringWithoutWhiteSpace := cString reject: [:e | e isSeparator].
+ 	self should: stringWithoutWhiteSpace =
+ 		'sqIntifdefEndif(void){#ifdefHAVE_FOO//someplatformsdonotsupportfooproperlyreturn1;#endif//HAVE_FOOreturn0;}'.
+ 
+ "
+ sqInt ifdefEndif(void) {
+ 	
+ # ifdef HAVE_FOO  // some platforms do not support foo properly
+ 	return 1;
+ # endif  // HAVE_FOO
+ 	
+ 	return 0;
+ }
+ "!

Item was added:
+ ----- Method: SlangTest>>testPreprocessorExpression (in category 'testing preprocessor directives') -----
+ testPreprocessorExpression
+ 	"Test preprocessorExpression: "
+ 
+ 	"(SlangTest selector: #testPreprocessorExpression) run"
+ 
+ 	| cString |
+ 	self flag: #FIXME. "See redundant implementation in oscog #cPreprocessorDirective: "
+ 
+ 	cString := SlangTestSupportInterpreter asCString: #preprocessorExpression.
+ 	self should: ('*# define FOO bar*' match: cString).
+ 	self should: ((cString findTokens: Character cr) select: [:e | e = '# define FOO bar' ]) size = 1.
+ 	self should: ((cString findTokens: Character cr) select: [:e | e = '## define FOO bar' ]) size = 0.
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>ifDefinedTrueElseEndif (in category 'preprocessor directives') -----
+ ifDefinedTrueElseEndif
+ 
+ 	self isDefinedTrueExpression: 'SIZE == 8'
+ 		inSmalltalk: [ ^ 4 ]
+ 		comment: 'SIZE may be 4 or 8'
+ 		ifTrue: [ ^8 ]
+ 		ifFalse: [ ^4 ].
+ 	^nil
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>ifdefElseEndif (in category 'preprocessor directives') -----
+ ifdefElseEndif
+ 
+ 	self isDefined: 'HAVE_FOO'
+ 		inSmalltalk: [ ^ #defaultBlockForSimulation ]
+ 		comment: 'some platforms do not support foo properly'
+ 		ifTrue: [ ^true ]
+ 		ifFalse: [ ^false ].
+ 	^nil
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>ifdefEndif (in category 'preprocessor directives') -----
+ ifdefEndif
+ 
+ 	self isDefined: 'HAVE_FOO'
+ 		inSmalltalk: [ ^ #defaultBlockForSimulation ]
+ 		comment: 'some platforms do not support foo properly'
+ 		ifTrue: [ ^ true ].
+ 	^ false
+ !

Item was added:
+ ----- Method: SlangTestSupportInterpreter>>preprocessorExpression (in category 'preprocessor directives') -----
+ preprocessorExpression
+ 
+ 	self preprocessorExpression: 'define FOO bar'.
+ !



More information about the Vm-dev mailing list