"Pharo Kernel-Tests slice — small subset of the canonical Pharo unit
 tests for SmallInteger, Float, String, Symbol, Boolean, Character.
 Runs through the SUnit framework defined in lib/smalltalk/sunit.sx."

TestCase subclass: #IntegerTest
  instanceVariableNames: ''!

!IntegerTest methodsFor: 'arithmetic'!
testAddition self assert: 2 + 3 equals: 5!
testSubtraction self assert: 10 - 4 equals: 6!
testMultiplication self assert: 6 * 7 equals: 42!
testDivisionExact self assert: 10 / 2 equals: 5!
testNegation self assert: 7 negated equals: -7!
testAbs self assert: -5 abs equals: 5!
testZero self assert: 0 + 0 equals: 0!
testIdentity self assert: 42 == 42! !

!IntegerTest methodsFor: 'comparison'!
testLessThan self assert: 1 < 2!
testLessOrEqual self assert: 5 <= 5!
testGreater self assert: 10 > 3!
testEqualSelf self assert: 7 = 7!
testNotEqual self assert: (3 ~= 5)!
testBetween self assert: (5 between: 1 and: 10)! !

!IntegerTest methodsFor: 'predicates'!
testEvenTrue self assert: 4 even!
testEvenFalse self deny: 5 even!
testOdd self assert: 3 odd!
testIsInteger self assert: 0 isInteger!
testIsNumber self assert: 1 isNumber!
testIsZero self assert: 0 isZero!
testIsNotZero self deny: 1 isZero! !

!IntegerTest methodsFor: 'powers and roots'!
testFactorialZero self assert: 0 factorial equals: 1!
testFactorialFive self assert: 5 factorial equals: 120!
testRaisedTo self assert: (2 raisedTo: 8) equals: 256!
testSquared self assert: 9 squared equals: 81!
testSqrtPerfect self assert: 16 sqrt equals: 4!
testGcd self assert: (24 gcd: 18) equals: 6!
testLcm self assert: (4 lcm: 6) equals: 12! !

!IntegerTest methodsFor: 'rounding'!
testFloor self assert: 3.7 floor equals: 3!
testCeiling self assert: 3.2 ceiling equals: 4!
testTruncated self assert: -3.7 truncated equals: -3!
testRounded self assert: 3.5 rounded equals: 4! !

TestCase subclass: #StringTest
  instanceVariableNames: ''!

!StringTest methodsFor: 'access'!
testSize self assert: 'hello' size equals: 5!
testEmpty self assert: '' isEmpty!
testNotEmpty self assert: 'a' notEmpty!
testAtFirst self assert: ('hello' at: 1) equals: 'h'!
testAtLast self assert: ('hello' at: 5) equals: 'o'!
testFirst self assert: 'world' first equals: 'w'!
testLast self assert: 'world' last equals: 'd'! !

!StringTest methodsFor: 'concatenation'!
testCommaConcat self assert: 'hello, ' , 'world' equals: 'hello, world'!
testEmptyConcat self assert: '' , 'x' equals: 'x'!
testSelfConcat self assert: 'ab' , 'ab' equals: 'abab'! !

!StringTest methodsFor: 'comparisons'!
testEqual self assert: 'a' = 'a'!
testNotEqual self deny: 'a' = 'b'!
testIncludes self assert: ('banana' includes: $a)!
testIncludesNot self deny: ('banana' includes: $z)!
testIndexOf self assert: ('abcde' indexOf: $c) equals: 3! !

!StringTest methodsFor: 'transforms'!
testCopyFromTo self assert: ('helloworld' copyFrom: 6 to: 10) equals: 'world'!
testFormat self assert: ('Hello, {1}!' format: #('World')) equals: 'Hello, World!'! !

TestCase subclass: #BooleanTest
  instanceVariableNames: ''!

!BooleanTest methodsFor: 'logic'!
testNotTrue self deny: true not!
testNotFalse self assert: false not!
testAnd self assert: (true & true)!
testOr self assert: (true | false)!
testIfTrueTaken self assert: (true ifTrue: [1] ifFalse: [2]) equals: 1!
testIfFalseTaken self assert: (false ifTrue: [1] ifFalse: [2]) equals: 2!
testAndShortCircuit self assert: (false and: [1/0]) equals: false!
testOrShortCircuit self assert: (true or: [1/0]) equals: true! !
