2
0

Kernel-Tests.st 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. TestCase subclass: #StringTest
  2. instanceVariableNames: ''
  3. category: 'Kernel-Tests'!
  4. !StringTest methodsFor: 'tests'!
  5. testJoin
  6. self assert: 'hello,world' equals: (',' join: #('hello' 'world'))
  7. !
  8. testStreamContents
  9. self
  10. assert: 'hello world'
  11. equals: (String streamContents: [:aStream| aStream
  12. nextPutAll: 'hello'; space;
  13. nextPutAll: 'world'])
  14. !
  15. testIncludesSubString
  16. self assert: ('jtalk' includesSubString: 'alk').
  17. self deny: ('jtalk' includesSubString: 'zork').
  18. ! !
  19. TestCase subclass: #DictionaryTest
  20. instanceVariableNames: ''
  21. category: 'Kernel-Tests'!
  22. !DictionaryTest methodsFor: 'tests'!
  23. testPrintString
  24. self
  25. assert: 'a Dictionary(''firstname'' -> ''James'' , ''lastname'' -> ''Bond'')'
  26. equals: (Dictionary new
  27. at:'firstname' put: 'James';
  28. at:'lastname' put: 'Bond';
  29. printString)
  30. ! !
  31. TestCase subclass: #NumberTest
  32. instanceVariableNames: ''
  33. category: 'Kernel-Tests'!
  34. !NumberTest methodsFor: 'tests'!
  35. testNegated
  36. self assert: (3 negated + 4) equals: 1
  37. ! !
  38. TestCase subclass: #BooleanTest
  39. instanceVariableNames: ''
  40. category: 'Kernel-Tests'!
  41. !BooleanTest methodsFor: 'tests'!
  42. testLogic
  43. "Trivial logic table"
  44. self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).
  45. self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).
  46. "Checking that expressions work fine too"
  47. self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).
  48. self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))
  49. ! !