Source

tddbc-sap02-legacy / TDDBC-Sap02-FizzBuzz.1.cs

'From Squeak4.2 of 4 February 2011 [latest update: #10966] on 7 June 2011 at 10:24:46 am'!
TestCase subclass: #FizzBuzzTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TDDBC-Sap02-FizzBuzz'!

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 13:55'!
test011fizzBuzzを送ると1を返す
	self assert: 1 fizzBuzz = 1!]lang[(6 2 8 4 1 3 29)0,5,0,5,0,5,0! !

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 13:58'!
test023fizzBuzzを送るとFizzを返す
	self assert: 3 fizzBuzz = 'Fizz'!]lang[(6 2 8 4 4 3 34)0,5,0,5,0,5,0! !

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 14:00'!
test035fizzBuzzを送るとBuzzを返す
	self assert: 5 fizzBuzz = 'Buzz'!]lang[(6 2 8 4 4 3 34)0,5,0,5,0,5,0! !

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 14:02'!
test0415fizzBuzzを送るとFizzBuzzを返す
	self assert: 15 fizzBuzz = 'FizzBuzz'!]lang[(6 3 8 4 8 3 39)0,5,0,5,0,5,0! !

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 14:04'!
test056fizzBuzzを送るとFizzを返す
	self assert: 6 fizzBuzz = 'Fizz'!]lang[(6 2 8 4 4 3 34)0,5,0,5,0,5,0! !

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 14:12'!
test0610fizzBuzzを送るとBuzzを返す
	self assert: 10 fizzBuzz = 'Buzz'!]lang[(6 3 8 4 4 3 35)0,5,0,5,0,5,0! !

!FizzBuzzTest methodsFor: 'as yet unclassified' stamp: 'TDDBC 6/5/2011 14:13'!
test0730fizzBuzzを送るとFizzBuzzを返す
	self assert: 30 fizzBuzz = 'FizzBuzz'!]lang[(6 3 8 4 8 3 39)0,5,0,5,0,5,0! !


!Integer methodsFor: 'converting' stamp: 'TDDBC 6/5/2011 14:36'!
fizzBuzz
	| fizzBuzzStream |
	fizzBuzzStream := '' writeStream.
	(self isDivisibleBy: 3) ifTrue: [fizzBuzzStream nextPutAll: 'Fizz'].
	(self isDivisibleBy: 5) ifTrue: [fizzBuzzStream nextPutAll: 'Buzz'].
	fizzBuzzStream isEmpty ifTrue: [^self].
	^fizzBuzzStream contents! !