Kernel-Tests.st 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. Smalltalk current createPackage: 'Kernel-Tests' properties: #{}!
  2. TestCase subclass: #BlockClosureTest
  3. instanceVariableNames: ''
  4. package: 'Kernel-Tests'!
  5. !BlockClosureTest methodsFor: 'tests'!
  6. testCanClearInterval
  7. self shouldnt: [([Error new signal] valueWithInterval: 0) clearInterval] raise: Error
  8. !
  9. testCanClearTimeout
  10. self shouldnt: [([Error new signal] valueWithTimeout: 0) clearTimeout] raise: Error
  11. !
  12. testCompiledSource
  13. self assert: ([1+1] compiledSource includesSubString: 'function')
  14. !
  15. testEnsure
  16. self assert: 3 equals: ([3] ensure: [4])
  17. !
  18. testEnsureRaises
  19. self should: [[Error new signal] ensure: [true]] raise: Error
  20. !
  21. testNumArgs
  22. self assert: [] numArgs equals: 0.
  23. self assert: [:a :b | ] numArgs equals: 2
  24. !
  25. testOnDo
  26. self assert: ([Error new signal] on: Error do: [:ex | true])
  27. !
  28. testValue
  29. self assert: ([1+1] value) equals: 2.
  30. self assert: ([:x | x +1] value: 2) equals: 3.
  31. self assert: ([:x :y | x*y] value: 2 value: 4) equals: 8.
  32. "Arguments are optional in Amber. This isn't ANSI compliant."
  33. self assert: ([:a :b :c | 1] value) equals: 1
  34. !
  35. testValueWithPossibleArguments
  36. self assert: ([1] valueWithPossibleArguments: #(3 4)) equals: 1.
  37. self assert: ([:a | a + 4] valueWithPossibleArguments: #(3 4)) equals: 7.
  38. self assert: ([:a :b | a + b] valueWithPossibleArguments: #(3 4 5)) equals: 7.
  39. !
  40. testWhileFalse
  41. | i |
  42. i := 0.
  43. [i > 5] whileFalse: [i := i + 1].
  44. self assert: i equals: 6.
  45. i := 0.
  46. [i := i + 1. i > 5] whileFalse.
  47. self assert: i equals: 6
  48. !
  49. testWhileTrue
  50. | i |
  51. i := 0.
  52. [i < 5] whileTrue: [i := i + 1].
  53. self assert: i equals: 5.
  54. i := 0.
  55. [i := i + 1. i < 5] whileTrue.
  56. self assert: i equals: 5
  57. ! !
  58. TestCase subclass: #BooleanTest
  59. instanceVariableNames: ''
  60. package: 'Kernel-Tests'!
  61. !BooleanTest methodsFor: 'tests'!
  62. testEquality
  63. "We're on top of JS...just be sure to check the basics!!"
  64. self deny: 0 = false.
  65. self deny: false = 0.
  66. self deny: '' = false.
  67. self deny: false = ''.
  68. self assert: true = true.
  69. self deny: false = true.
  70. self deny: true = false.
  71. self assert: false = false.
  72. "JS may do some type coercing after sending a message"
  73. self assert: true yourself = true.
  74. self assert: true yourself = true yourself
  75. !
  76. testIdentity
  77. "We're on top of JS...just be sure to check the basics!!"
  78. self deny: 0 == false.
  79. self deny: false == 0.
  80. self deny: '' == false.
  81. self deny: false == ''.
  82. self assert: true == true.
  83. self deny: false == true.
  84. self deny: true == false.
  85. self assert: false == false.
  86. "JS may do some type coercing after sending a message"
  87. self assert: true yourself == true.
  88. self assert: true yourself == true yourself
  89. !
  90. testIfTrueIfFalse
  91. self assert: (true ifTrue: ['alternative block']) = 'alternative block'.
  92. self assert: (true ifFalse: ['alternative block']) = nil.
  93. self assert: (false ifTrue: ['alternative block']) = nil.
  94. self assert: (false ifFalse: ['alternative block']) = 'alternative block'.
  95. self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.
  96. self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.
  97. self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.
  98. self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
  99. !
  100. testIfTrueIfFalseWithBoxing
  101. self assert: (true yourself ifTrue: ['alternative block']) = 'alternative block'.
  102. self assert: (true yourself ifFalse: ['alternative block']) = nil.
  103. self assert: (false yourself ifTrue: ['alternative block']) = nil.
  104. self assert: (false yourself ifFalse: ['alternative block']) = 'alternative block'.
  105. self assert: (false yourself ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.
  106. self assert: (false yourself ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.
  107. self assert: (true yourself ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.
  108. self assert: (true yourself ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.
  109. !
  110. testLogic
  111. "Trivial logic table"
  112. self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).
  113. self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).
  114. "Checking that expressions work fine too"
  115. self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).
  116. self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))
  117. !
  118. testLogicKeywords
  119. "Trivial logic table"
  120. self
  121. assert: (true and: [ true]);
  122. deny: (true and: [ false ]);
  123. deny: (false and: [ true ]);
  124. deny: (false and: [ false ]).
  125. self
  126. assert: (true or: [ true ]);
  127. assert: (true or: [ false ]);
  128. assert: (false or: [ true ]);
  129. deny: (false or: [ false ]).
  130. "Checking that expressions work fine too"
  131. self
  132. assert: (true and: [ 1 > 0 ]);
  133. deny: ((1 > 0) and: [ false ]);
  134. deny: ((1 > 0) and: [ 1 > 2 ]).
  135. self
  136. assert: (false or: [ 1 > 0 ]);
  137. assert: ((1 > 0) or: [ false ]);
  138. assert: ((1 > 0) or: [ 1 > 2 ])
  139. !
  140. testNonBooleanError
  141. self should: [ '' ifTrue: [] ifFalse: [] ] raise: NonBooleanReceiver
  142. ! !
  143. TestCase subclass: #ClassBuilderTest
  144. instanceVariableNames: 'builder theClass'
  145. package: 'Kernel-Tests'!
  146. !ClassBuilderTest methodsFor: 'running'!
  147. setUp
  148. builder := ClassBuilder new
  149. !
  150. tearDown
  151. theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]
  152. !
  153. testClassCopy
  154. theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
  155. self assert: theClass superclass == ObjectMock superclass.
  156. self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.
  157. self assert: theClass name equals: 'ObjectMock2'.
  158. self assert: theClass package == ObjectMock package.
  159. self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys
  160. !
  161. testClassMigration
  162. | instance oldClass |
  163. oldClass := builder copyClass: ObjectMock named: 'ObjectMock2'.
  164. instance := (Smalltalk current at: 'ObjectMock2') new.
  165. "Change the superclass of ObjectMock2"
  166. ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')
  167. instanceVariableNames: ''
  168. package: 'Kernel-Tests'.
  169. self deny: oldClass == ObjectMock2.
  170. self assert: ObjectMock2 superclass == ObjectMock.
  171. self assert: ObjectMock2 instanceVariableNames isEmpty.
  172. self assert: ObjectMock2 selectors equals: oldClass selectors.
  173. self assert: ObjectMock2 comment equals: oldClass comment.
  174. self assert: ObjectMock2 package name equals: 'Kernel-Tests'.
  175. self deny: instance class == ObjectMock2.
  176. self assert: instance class name equals: 'OldObjectMock2'.
  177. self assert: (Smalltalk current at: 'OldObjectMock2') isNil.
  178. Smalltalk current removeClass: ObjectMock2
  179. !
  180. testInstanceVariableNames
  181. self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')
  182. ! !
  183. TestCase subclass: #CollectionTest
  184. instanceVariableNames: ''
  185. package: 'Kernel-Tests'!
  186. !CollectionTest methodsFor: 'accessing'!
  187. collection
  188. ^ self collectionClass withAll: self defaultValues
  189. !
  190. collectionClass
  191. ^ self class collectionClass
  192. !
  193. collectionWithDuplicates
  194. ^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')
  195. !
  196. defaultValues
  197. ^ #(1 2 3 -4)
  198. ! !
  199. !CollectionTest methodsFor: 'convenience'!
  200. assertSameContents: aCollection as: anotherCollection
  201. self assert: aCollection size = anotherCollection size.
  202. aCollection do: [ :each |
  203. self assert: (aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each) ]
  204. ! !
  205. !CollectionTest methodsFor: 'testing'!
  206. isCollectionReadOnly
  207. ^ false
  208. ! !
  209. !CollectionTest methodsFor: 'tests'!
  210. testAsArray
  211. self
  212. assertSameContents: self collection
  213. as: self collection asArray
  214. !
  215. testAsOrderedCollection
  216. self
  217. assertSameContents: self collection
  218. as: self collection asOrderedCollection
  219. !
  220. testAsSet
  221. | c set |
  222. c := self collectionWithDuplicates.
  223. set := c asSet.
  224. self assert: set size = 5.
  225. c do: [ :each |
  226. self assert: (set includes: each) ]
  227. !
  228. testCollect
  229. | newCollection |
  230. newCollection := #(1 2 3 4).
  231. self
  232. assertSameContents: (self collection collect: [ :each |
  233. each abs ])
  234. as: newCollection
  235. !
  236. testDetect
  237. self assert: (self collection detect: [ :each | each < 0 ]) = -4.
  238. self
  239. should: [ self collection detect: [ :each | each = 6 ] ]
  240. raise: Error
  241. !
  242. testDo
  243. | newCollection |
  244. newCollection := OrderedCollection new.
  245. self collection do: [ :each |
  246. newCollection add: each ].
  247. self
  248. assertSameContents: self collection
  249. as: newCollection
  250. !
  251. testIsEmpty
  252. self assert: self collectionClass new isEmpty.
  253. self deny: self collection isEmpty
  254. !
  255. testSelect
  256. | newCollection |
  257. newCollection := #(2 -4).
  258. self
  259. assertSameContents: (self collection select: [ :each |
  260. each even ])
  261. as: newCollection
  262. !
  263. testSize
  264. self assert: self collectionClass new size = 0.
  265. self assert: self collection size = 4
  266. ! !
  267. !CollectionTest class methodsFor: 'accessing'!
  268. collectionClass
  269. ^ nil
  270. ! !
  271. !CollectionTest class methodsFor: 'testing'!
  272. isAbstract
  273. ^ self collectionClass isNil
  274. ! !
  275. CollectionTest subclass: #HashedCollectionTest
  276. instanceVariableNames: ''
  277. package: 'Kernel-Tests'!
  278. !HashedCollectionTest methodsFor: 'accessing'!
  279. collection
  280. ^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4 }
  281. !
  282. collectionWithDuplicates
  283. ^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4. 'e' -> 1. 'f' -> 2. 'g' -> 10 }
  284. ! !
  285. !HashedCollectionTest class methodsFor: 'accessing'!
  286. collectionClass
  287. ^ HashedCollection
  288. ! !
  289. HashedCollectionTest subclass: #DictionaryTest
  290. instanceVariableNames: ''
  291. package: 'Kernel-Tests'!
  292. !DictionaryTest methodsFor: 'accessing'!
  293. collection
  294. ^ Dictionary new
  295. at: 1 put: 1;
  296. at: 'a' put: 2;
  297. at: true put: 3;
  298. at: 4 put: -4;
  299. yourself
  300. !
  301. collectionWithDuplicates
  302. ^ Dictionary new
  303. at: 1 put: 1;
  304. at: 'a' put: 2;
  305. at: true put: 3;
  306. at: 4 put: -4;
  307. at: 'b' put: 1;
  308. at: 3 put: 3;
  309. at: false put: 12;
  310. yourself
  311. ! !
  312. !DictionaryTest methodsFor: 'tests'!
  313. testAccessing
  314. | d |
  315. d := Dictionary new.
  316. d at: 'hello' put: 'world'.
  317. self assert: (d at: 'hello') = 'world'.
  318. self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.
  319. self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.
  320. d at: 1 put: 2.
  321. self assert: (d at: 1) = 2.
  322. d at: 1@3 put: 3.
  323. self assert: (d at: 1@3) = 3
  324. !
  325. testDynamicDictionaries
  326. self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)
  327. !
  328. testEquality
  329. | d1 d2 |
  330. self assert: Dictionary new = Dictionary new.
  331. d1 := Dictionary new at: 1 put: 2; yourself.
  332. d2 := Dictionary new at: 1 put: 2; yourself.
  333. self assert: d1 = d2.
  334. d2 := Dictionary new at: 1 put: 3; yourself.
  335. self deny: d1 = d2.
  336. d2 := Dictionary new at: 2 put: 2; yourself.
  337. self deny: d1 = d2.
  338. d2 := Dictionary new at: 1 put: 2; at: 3 put: 4; yourself.
  339. self deny: d1 = d2.
  340. !
  341. testIfAbsent
  342. | d visited |
  343. visited := false.
  344. d := Dictionary new.
  345. d at: 'hello' ifAbsent: [ visited := true ].
  346. self assert: visited.
  347. !
  348. testIfPresent
  349. | d visited absent |
  350. visited := false.
  351. d := Dictionary new.
  352. d at: 'hello' put: 'world'.
  353. d at: 'hello' ifPresent: [ :value | visited := value ].
  354. self assert: visited = 'world'.
  355. absent := d at: 'bye' ifPresent: [ :value | visited := value ].
  356. self assert: absent isNil.
  357. !
  358. testIfPresentIfAbsent
  359. | d visited |
  360. visited := false.
  361. d := Dictionary new.
  362. d at: 'hello' put: 'world'.
  363. d at: 'hello' ifPresent: [ :value | visited := value ] ifAbsent: [ visited := true ].
  364. self assert: visited = 'world'.
  365. d at: 'buy' ifPresent: [ :value | visited := value ] ifAbsent: [ visited := true ].
  366. self assert: visited.
  367. !
  368. testKeys
  369. | d |
  370. d := Dictionary new.
  371. d at: 1 put: 2.
  372. d at: 2 put: 3.
  373. d at: 3 put: 4.
  374. self assert: d keys = #(1 2 3)
  375. !
  376. testPrintString
  377. self
  378. assert: 'a Dictionary(''firstname''->''James'' , ''lastname''->''Bond'')'
  379. equals: (Dictionary new
  380. at:'firstname' put: 'James';
  381. at:'lastname' put: 'Bond';
  382. printString)
  383. !
  384. testRemoveKey
  385. | d key |
  386. d := Dictionary new.
  387. d at: 1 put: 2.
  388. d at: 2 put: 3.
  389. d at: 3 put: 4.
  390. key := 2.
  391. self assert: d keys = #(1 2 3).
  392. d removeKey: key.
  393. self assert: d keys = #(1 3).
  394. self assert: d values = #(2 4).
  395. self deny: (d includesKey: 2)
  396. !
  397. testRemoveKeyIfAbsent
  398. | d key |
  399. d := Dictionary new.
  400. d at: 1 put: 2.
  401. d at: 2 put: 3.
  402. d at: 3 put: 4.
  403. key := 2.
  404. self assert: (d removeKey: key) = 3.
  405. key := 3.
  406. self assert: (d removeKey: key ifAbsent: [42]) = 4.
  407. key := 'why'.
  408. self assert: (d removeKey: key ifAbsent: [42] ) = 42.
  409. !
  410. testSize
  411. | d |
  412. d := Dictionary new.
  413. self assert: d size = 0.
  414. d at: 1 put: 2.
  415. self assert: d size = 1.
  416. d at: 2 put: 3.
  417. self assert: d size = 2.
  418. !
  419. testValues
  420. | d |
  421. d := Dictionary new.
  422. d at: 1 put: 2.
  423. d at: 2 put: 3.
  424. d at: 3 put: 4.
  425. self assert: d values = #(2 3 4)
  426. ! !
  427. !DictionaryTest class methodsFor: 'accessing'!
  428. collectionClass
  429. ^ Dictionary
  430. ! !
  431. CollectionTest subclass: #SequenceableCollectionTest
  432. instanceVariableNames: ''
  433. package: 'Kernel-Tests'!
  434. !SequenceableCollectionTest methodsFor: 'tests'!
  435. testAt
  436. self assert: (self collection at: 4) = -4.
  437. self should: [ self collection at: 5 ] raise: Error
  438. !
  439. testAtIfAbsent
  440. self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) = 'none'
  441. ! !
  442. SequenceableCollectionTest subclass: #ArrayTest
  443. instanceVariableNames: ''
  444. package: 'Kernel-Tests'!
  445. !ArrayTest methodsFor: 'testing'!
  446. testAtIfAbsent
  447. | array |
  448. array := #('hello' 'world').
  449. self assert: (array at: 1) equals: 'hello'.
  450. self assert: (array at: 2) equals: 'world'.
  451. self assert: (array at: 2 ifAbsent: ['not found']) equals: 'world'.
  452. self assert: (array at: 0 ifAbsent: ['not found']) equals: 'not found'.
  453. self assert: (array at: -10 ifAbsent: ['not found']) equals: 'not found'.
  454. self assert: (array at: 3 ifAbsent: ['not found']) equals: 'not found'.
  455. !
  456. testFirstN
  457. self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).
  458. !
  459. testIfEmpty
  460. self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )
  461. !
  462. testPrintString
  463. | array |
  464. array := Array new.
  465. self assert: 'a Array ()' equals: ( array printString ).
  466. array add: 1; add: 3.
  467. self assert: 'a Array (1 3)' equals: ( array printString ).
  468. array add: 'foo'.
  469. self assert: 'a Array (1 3 ''foo'')' equals: ( array printString ).
  470. array remove: 1; remove: 3.
  471. self assert: 'a Array (''foo'')' equals: ( array printString ).
  472. array addLast: 3.
  473. self assert: 'a Array (''foo'' 3)' equals: ( array printString ).
  474. array addLast: 3.
  475. self assert: 'a Array (''foo'' 3 3)' equals: ( array printString ).
  476. ! !
  477. !ArrayTest class methodsFor: 'accessing'!
  478. collectionClass
  479. ^ Array
  480. ! !
  481. SequenceableCollectionTest subclass: #StringTest
  482. instanceVariableNames: ''
  483. package: 'Kernel-Tests'!
  484. !StringTest methodsFor: 'accessing'!
  485. collection
  486. ^'hello'
  487. !
  488. collectionWithDuplicates
  489. ^ 'abbaerte'
  490. ! !
  491. !StringTest methodsFor: 'tests'!
  492. testAddRemove
  493. self should: ['hello' add: 'a'] raise: Error.
  494. self should: ['hello' remove: 'h'] raise: Error
  495. !
  496. testAsArray
  497. self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').
  498. !
  499. testAt
  500. self assert: ('hello' at: 1) = 'h'.
  501. self assert: ('hello' at: 5) = 'o'.
  502. self assert: ('hello' at: 6 ifAbsent: [nil]) = nil
  503. !
  504. testAtPut
  505. "String instances are read-only"
  506. self should: ['hello' at: 1 put: 'a'] raise: Error
  507. !
  508. testCollect
  509. | newCollection |
  510. newCollection := 'hheelllloo'.
  511. self
  512. assertSameContents: (self collection collect: [ :each |
  513. each, each ])
  514. as: newCollection
  515. !
  516. testCopyWithoutAll
  517. self
  518. assert: 'hello world'
  519. equals: ('*hello* *world*' copyWithoutAll: '*')
  520. !
  521. testDetect
  522. self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.
  523. self
  524. should: [ self collection detect: [ :each | each = 6 ] ]
  525. raise: Error
  526. !
  527. testEquality
  528. self assert: 'hello' = 'hello'.
  529. self deny: 'hello' = 'world'.
  530. self assert: 'hello' = 'hello' yourself.
  531. self assert: 'hello' yourself = 'hello'.
  532. "test JS falsy value"
  533. self deny: '' = 0
  534. !
  535. testIdentity
  536. self assert: 'hello' == 'hello'.
  537. self deny: 'hello' == 'world'.
  538. self assert: 'hello' == 'hello' yourself.
  539. self assert: 'hello' yourself == 'hello'.
  540. "test JS falsy value"
  541. self deny: '' == 0
  542. !
  543. testIncludesSubString
  544. self assert: ('amber' includesSubString: 'ber').
  545. self deny: ('amber' includesSubString: 'zork').
  546. !
  547. testJoin
  548. self assert: 'hello,world' equals: (',' join: #('hello' 'world'))
  549. !
  550. testSelect
  551. | newCollection |
  552. newCollection := 'o'.
  553. self
  554. assertSameContents: (self collection select: [ :each |
  555. each = 'o' ])
  556. as: newCollection
  557. !
  558. testSize
  559. self assert: 'smalltalk' size equals: 9.
  560. self assert: '' size equals: 0
  561. !
  562. testStreamContents
  563. self
  564. assert: 'hello world'
  565. equals: (String streamContents: [ :aStream |
  566. aStream
  567. nextPutAll: 'hello'; space;
  568. nextPutAll: 'world' ])
  569. ! !
  570. !StringTest class methodsFor: 'accessing'!
  571. collectionClass
  572. ^ String
  573. ! !
  574. SequenceableCollectionTest subclass: #SymbolTest
  575. instanceVariableNames: ''
  576. package: 'Kernel-Tests'!
  577. !SymbolTest methodsFor: 'accessing'!
  578. collection
  579. ^ #hello
  580. !
  581. collectionWithDuplicates
  582. ^ #phhaaarorra
  583. ! !
  584. !SymbolTest methodsFor: 'tests'!
  585. testAsString
  586. self assert: #hello asString equals: 'hello'
  587. !
  588. testAsSymbol
  589. self assert: #hello == #hello asSymbol
  590. !
  591. testAt
  592. self assert: (#hello at: 1) = 'h'.
  593. self assert: (#hello at: 5) = 'o'.
  594. self assert: (#hello at: 6 ifAbsent: [nil]) = nil
  595. !
  596. testAtPut
  597. "Symbol instances are read-only"
  598. self should: ['hello' at: 1 put: 'a'] raise: Error
  599. !
  600. testCollect
  601. | newCollection |
  602. newCollection := #hheelllloo.
  603. self
  604. assertSameContents: (self collection collect: [ :each |
  605. each, each ])
  606. as: newCollection
  607. !
  608. testComparing
  609. self assert: #ab > #aa.
  610. self deny: #ab > #ba.
  611. self assert: #ab < #ba.
  612. self deny: #bb < #ba.
  613. self assert: #ab >= #aa.
  614. self deny: #ab >= #ba.
  615. self assert: #ab <= #ba.
  616. self deny: #bb <= #ba
  617. !
  618. testCopying
  619. self assert: #hello copy == #hello.
  620. self assert: #hello deepCopy == #hello
  621. !
  622. testDetect
  623. self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.
  624. self
  625. should: [ self collection detect: [ :each | each = 'z' ] ]
  626. raise: Error
  627. !
  628. testEquality
  629. self assert: #hello = #hello.
  630. self deny: #hello = #world.
  631. self assert: #hello = #hello yourself.
  632. self assert: #hello yourself = #hello.
  633. self deny: #hello = 'hello'.
  634. self deny: 'hello' = #hello.
  635. !
  636. testIdentity
  637. self assert: #hello == #hello.
  638. self deny: #hello == #world.
  639. self assert: #hello = #hello yourself.
  640. self assert: #hello yourself = #hello asString asSymbol
  641. !
  642. testIsEmpty
  643. self deny: self collection isEmpty.
  644. self assert: '' asSymbol isEmpty
  645. !
  646. testIsSymbolIsString
  647. self assert: #hello isSymbol.
  648. self deny: 'hello' isSymbol.
  649. self deny: #hello isString.
  650. self assert: 'hello' isString
  651. !
  652. testSelect
  653. | newCollection |
  654. newCollection := 'o'.
  655. self
  656. assertSameContents: (self collection select: [ :each |
  657. each = 'o' ])
  658. as: newCollection
  659. !
  660. testSize
  661. self assert: #a size equals: 1.
  662. self assert: #aaaaa size equals: 5
  663. ! !
  664. !SymbolTest class methodsFor: 'accessing'!
  665. collectionClass
  666. ^ Symbol
  667. ! !
  668. TestCase subclass: #JSObjectProxyTest
  669. instanceVariableNames: ''
  670. package: 'Kernel-Tests'!
  671. !JSObjectProxyTest methodsFor: 'accessing'!
  672. jsObject
  673. <return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null}>
  674. ! !
  675. !JSObjectProxyTest methodsFor: 'tests'!
  676. testDNU
  677. self should: [self jsObject foo] raise: MessageNotUnderstood
  678. !
  679. testMessageSend
  680. self assert: self jsObject a equals: 1.
  681. self assert: self jsObject b equals: 2.
  682. self assert: (self jsObject c: 3) equals: 3
  683. !
  684. testMethodWithArguments
  685. self assert: (self jsObject c: 1) equals: 1
  686. !
  687. testPrinting
  688. self assert: self jsObject printString = '[object Object]'
  689. !
  690. testPropertyThatReturnsEmptyString
  691. | object |
  692. object := self jsObject.
  693. self assert: '' equals: object d.
  694. object d: 'hello'.
  695. self assert: 'hello' equals: object d
  696. !
  697. testPropertyThatReturnsUndefined
  698. | object |
  699. object := self jsObject.
  700. self shouldnt: [ object e ] raise: MessageNotUnderstood.
  701. self assert: object e isNil
  702. !
  703. testYourself
  704. | object |
  705. object := self jsObject
  706. d: 'test';
  707. yourself.
  708. self assert: object d equals: 'test'
  709. ! !
  710. TestCase subclass: #NumberTest
  711. instanceVariableNames: ''
  712. package: 'Kernel-Tests'!
  713. !NumberTest methodsFor: 'tests'!
  714. testAbs
  715. self assert: 4 abs = 4.
  716. self assert: -4 abs = 4
  717. !
  718. testArithmetic
  719. "We rely on JS here, so we won't test complex behavior, just check if
  720. message sends are corrects"
  721. self assert: 1.5 + 1 = 2.5.
  722. self assert: 2 - 1 = 1.
  723. self assert: -2 - 1 = -3.
  724. self assert: 12 / 2 = 6.
  725. self assert: 3 * 4 = 12.
  726. "Simple parenthesis and execution order"
  727. self assert: 1 + 2 * 3 = 9.
  728. self assert: 1 + (2 * 3) = 7
  729. !
  730. testComparison
  731. self assert: 3 > 2.
  732. self assert: 2 < 3.
  733. self deny: 3 < 2.
  734. self deny: 2 > 3.
  735. self assert: 3 >= 3.
  736. self assert: 3.1 >= 3.
  737. self assert: 3 <= 3.
  738. self assert: 3 <= 3.1
  739. !
  740. testCopying
  741. self assert: 1 copy == 1.
  742. self assert: 1 deepCopy == 1
  743. !
  744. testEquality
  745. self assert: 1 = 1.
  746. self assert: 0 = 0.
  747. self deny: 1 = 0.
  748. self assert: 1 yourself = 1.
  749. self assert: 1 = 1 yourself.
  750. self assert: 1 yourself = 1 yourself.
  751. self deny: 0 = false.
  752. self deny: false = 0.
  753. self deny: '' = 0.
  754. self deny: 0 = ''
  755. !
  756. testHexNumbers
  757. self assert: 16r9 = 9.
  758. self assert: 16rA truncated = 10.
  759. self assert: 16rB truncated = 11.
  760. self assert: 16rC truncated = 12.
  761. self assert: 16rD truncated = 13.
  762. self assert: 16rE truncated = 14.
  763. self assert: 16rF truncated = 15
  764. !
  765. testIdentity
  766. self assert: 1 == 1.
  767. self assert: 0 == 0.
  768. self deny: 1 == 0.
  769. self assert: 1 yourself == 1.
  770. self assert: 1 == 1 yourself.
  771. self assert: 1 yourself == 1 yourself.
  772. self deny: 1 == 2
  773. !
  774. testInvalidHexNumbers
  775. self should: [16rG] raise: MessageNotUnderstood.
  776. self should: [16rg] raise: MessageNotUnderstood.
  777. self should: [16rH] raise: MessageNotUnderstood.
  778. self should: [16rh] raise: MessageNotUnderstood.
  779. self should: [16rI] raise: MessageNotUnderstood.
  780. self should: [16ri] raise: MessageNotUnderstood.
  781. self should: [16rJ] raise: MessageNotUnderstood.
  782. self should: [16rj] raise: MessageNotUnderstood.
  783. self should: [16rK] raise: MessageNotUnderstood.
  784. self should: [16rk] raise: MessageNotUnderstood.
  785. self should: [16rL] raise: MessageNotUnderstood.
  786. self should: [16rl] raise: MessageNotUnderstood.
  787. self should: [16rM] raise: MessageNotUnderstood.
  788. self should: [16rm] raise: MessageNotUnderstood.
  789. self should: [16rN] raise: MessageNotUnderstood.
  790. self should: [16rn] raise: MessageNotUnderstood.
  791. self should: [16rO] raise: MessageNotUnderstood.
  792. self should: [16ro] raise: MessageNotUnderstood.
  793. self should: [16rP] raise: MessageNotUnderstood.
  794. self should: [16rp] raise: MessageNotUnderstood.
  795. self should: [16rQ] raise: MessageNotUnderstood.
  796. self should: [16rq] raise: MessageNotUnderstood.
  797. self should: [16rR] raise: MessageNotUnderstood.
  798. self should: [16rr] raise: MessageNotUnderstood.
  799. self should: [16rS] raise: MessageNotUnderstood.
  800. self should: [16rs] raise: MessageNotUnderstood.
  801. self should: [16rT] raise: MessageNotUnderstood.
  802. self should: [16rt] raise: MessageNotUnderstood.
  803. self should: [16rU] raise: MessageNotUnderstood.
  804. self should: [16ru] raise: MessageNotUnderstood.
  805. self should: [16rV] raise: MessageNotUnderstood.
  806. self should: [16rv] raise: MessageNotUnderstood.
  807. self should: [16rW] raise: MessageNotUnderstood.
  808. self should: [16rw] raise: MessageNotUnderstood.
  809. self should: [16rX] raise: MessageNotUnderstood.
  810. self should: [16rx] raise: MessageNotUnderstood.
  811. self should: [16rY] raise: MessageNotUnderstood.
  812. self should: [16ry] raise: MessageNotUnderstood.
  813. self should: [16rZ] raise: MessageNotUnderstood.
  814. self should: [16rz] raise: MessageNotUnderstood.
  815. self should: [16rABcdEfZ] raise: MessageNotUnderstood.
  816. !
  817. testMinMax
  818. self assert: (2 max: 5) equals: 5.
  819. self assert: (2 min: 5) equals: 2
  820. !
  821. testNegated
  822. self assert: 3 negated = -3.
  823. self assert: -3 negated = 3
  824. !
  825. testPrintShowingDecimalPlaces
  826. self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).
  827. self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).
  828. self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).
  829. self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).
  830. self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).
  831. self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).
  832. self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).
  833. self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).
  834. self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).
  835. self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).
  836. self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).
  837. self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).
  838. self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).
  839. !
  840. testRounded
  841. self assert: 3 rounded = 3.
  842. self assert: 3.212 rounded = 3.
  843. self assert: 3.51 rounded = 4
  844. !
  845. testSqrt
  846. self assert: 4 sqrt = 2.
  847. self assert: 16 sqrt = 4
  848. !
  849. testSquared
  850. self assert: 4 squared = 16
  851. !
  852. testTimesRepeat
  853. | i |
  854. i := 0.
  855. 0 timesRepeat: [i := i + 1].
  856. self assert: i equals: 0.
  857. 5 timesRepeat: [i := i + 1].
  858. self assert: i equals: 5
  859. !
  860. testTo
  861. self assert: (1 to: 5) equals: #(1 2 3 4 5)
  862. !
  863. testToBy
  864. self assert: (0 to: 6 by: 2) equals: #(0 2 4 6).
  865. self should: [1 to: 4 by: 0] raise: Error
  866. !
  867. testTruncated
  868. self assert: 3 truncated = 3.
  869. self assert: 3.212 truncated = 3.
  870. self assert: 3.51 truncated = 3
  871. ! !
  872. Object subclass: #ObjectMock
  873. instanceVariableNames: 'foo bar'
  874. package: 'Kernel-Tests'!
  875. !ObjectMock commentStamp!
  876. ObjectMock is there only to perform tests on classes.!
  877. !ObjectMock methodsFor: 'not yet classified'!
  878. foo
  879. ^foo
  880. !
  881. foo: anObject
  882. foo := anObject
  883. ! !
  884. TestCase subclass: #ObjectTest
  885. instanceVariableNames: ''
  886. package: 'Kernel-Tests'!
  887. !ObjectTest methodsFor: 'tests'!
  888. notDefined
  889. <return undefined;>
  890. !
  891. testBasicAccess
  892. | o |
  893. o := Object new.
  894. o basicAt: 'a' put: 1.
  895. self assert: (o basicAt: 'a') equals: 1.
  896. self assert: (o basicAt: 'b') equals: nil
  897. !
  898. testBasicPerform
  899. | o |
  900. o := Object new.
  901. o basicAt: 'func' put: ['hello'].
  902. o basicAt: 'func2' put: [:a | a + 1].
  903. self assert: (o basicPerform: 'func') equals: 'hello'.
  904. self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4
  905. !
  906. testDNU
  907. self should: [Object new foo] raise: MessageNotUnderstood
  908. !
  909. testEquality
  910. | o |
  911. o := Object new.
  912. self deny: o = Object new.
  913. self assert: o = o.
  914. self assert: o yourself = o.
  915. self assert: o = o yourself
  916. !
  917. testHalt
  918. self should: [Object new halt] raise: Error
  919. !
  920. testIdentity
  921. | o |
  922. o := Object new.
  923. self deny: o == Object new.
  924. self assert: o == o.
  925. self assert: o yourself == o.
  926. self assert: o == o yourself
  927. !
  928. testIfNil
  929. self deny: Object new isNil.
  930. self deny: (Object new ifNil: [true]) = true.
  931. self assert: (Object new ifNotNil: [true]) = true.
  932. self assert: (Object new ifNil: [false] ifNotNil: [true]) = true.
  933. self assert: (Object new ifNotNil: [true] ifNil: [false]) = true
  934. !
  935. testInstVars
  936. | o |
  937. o := ObjectMock new.
  938. self assert: (o instVarAt: #foo) equals: nil.
  939. o instVarAt: #foo put: 1.
  940. self assert: (o instVarAt: #foo) equals: 1.
  941. self assert: (o instVarAt: 'foo') equals: 1
  942. !
  943. testNilUndefined
  944. "nil in Smalltalk is the undefined object in JS"
  945. self assert: nil = self notDefined
  946. !
  947. testYourself
  948. | o |
  949. o := ObjectMock new.
  950. self assert: o yourself == o
  951. !
  952. testidentityHash
  953. | o1 o2 |
  954. o1 := Object new.
  955. o2 := Object new.
  956. self assert: o1 identityHash == o1 identityHash.
  957. self deny: o1 identityHash == o2 identityHash
  958. ! !
  959. TestCase subclass: #PackageTest
  960. instanceVariableNames: 'zorkPackage grulPackage backUpCommitPathJs backUpCommitPathSt'
  961. package: 'Kernel-Tests'!
  962. !PackageTest methodsFor: 'running'!
  963. setUp
  964. backUpCommitPathJs := Package defaultCommitPathJs.
  965. backUpCommitPathSt := Package defaultCommitPathSt.
  966. Package resetCommitPaths.
  967. zorkPackage := Package new name: 'Zork'.
  968. grulPackage := Package new
  969. name: 'Grul';
  970. commitPathJs: 'server/grul/js';
  971. commitPathSt: 'grul/st';
  972. yourself
  973. !
  974. tearDown
  975. Package
  976. defaultCommitPathJs: backUpCommitPathJs;
  977. defaultCommitPathSt: backUpCommitPathSt
  978. ! !
  979. !PackageTest methodsFor: 'tests'!
  980. testGrulCommitPathJsShouldBeServerGrulJs
  981. self assert: 'server/grul/js' equals: grulPackage commitPathJs
  982. !
  983. testGrulCommitPathStShouldBeGrulSt
  984. self assert: 'grul/st' equals: grulPackage commitPathSt
  985. !
  986. testZorkCommitPathJsShouldBeJs
  987. self assert: 'js' equals: zorkPackage commitPathJs
  988. !
  989. testZorkCommitPathStShouldBeSt
  990. self assert: 'st' equals: zorkPackage commitPathSt
  991. ! !
  992. PackageTest subclass: #PackageWithDefaultCommitPathChangedTest
  993. instanceVariableNames: ''
  994. package: 'Kernel-Tests'!
  995. !PackageWithDefaultCommitPathChangedTest methodsFor: 'running'!
  996. setUp
  997. super setUp.
  998. Package
  999. defaultCommitPathJs: 'javascripts/';
  1000. defaultCommitPathSt: 'smalltalk/'.
  1001. ! !
  1002. !PackageWithDefaultCommitPathChangedTest methodsFor: 'tests'!
  1003. testGrulCommitPathJsShouldBeServerGrulJs
  1004. self assert: 'server/grul/js' equals: grulPackage commitPathJs
  1005. !
  1006. testGrulCommitPathStShouldBeGrulSt
  1007. self assert: 'grul/st' equals: grulPackage commitPathSt
  1008. !
  1009. testZorkCommitPathJsShouldBeJavascript
  1010. self assert: 'javascripts/' equals: zorkPackage commitPathJs
  1011. !
  1012. testZorkCommitPathStShouldBeSmalltalk
  1013. self assert: 'smalltalk/' equals: zorkPackage commitPathSt
  1014. ! !
  1015. !PackageWithDefaultCommitPathChangedTest class methodsFor: 'accessing'!
  1016. shouldInheritSelectors
  1017. ^ false
  1018. ! !
  1019. TestCase subclass: #PointTest
  1020. instanceVariableNames: ''
  1021. package: 'Kernel-Tests'!
  1022. !PointTest methodsFor: 'tests'!
  1023. testAccessing
  1024. self assert: (Point x: 3 y: 4) x equals: 3.
  1025. self assert: (Point x: 3 y: 4) y equals: 4.
  1026. self assert: (Point new x: 3) x equals: 3.
  1027. self assert: (Point new y: 4) y equals: 4
  1028. !
  1029. testArithmetic
  1030. self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).
  1031. self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).
  1032. self assert: 3@4 - (3@4 ) equals: (Point x: 0 y: 0).
  1033. self assert: 6@8 / (3@4 ) equals: (Point x: 2 y: 2)
  1034. !
  1035. testAt
  1036. self assert: 3@4 equals: (Point x: 3 y: 4)
  1037. !
  1038. testEgality
  1039. self assert: 3@4 = (3@4).
  1040. self deny: 3@5 = (3@6)
  1041. !
  1042. testTranslateBy
  1043. self assert: 3@4 equals: (3@3 translateBy: 0@1).
  1044. self assert: 3@2 equals: (3@3 translateBy: 0@1 negated).
  1045. self assert: 5@6 equals: (3@3 translateBy: 2@3).
  1046. self assert: 0@3 equals: (3@3 translateBy: 3 negated @0).
  1047. ! !
  1048. TestCase subclass: #RandomTest
  1049. instanceVariableNames: ''
  1050. package: 'Kernel-Tests'!
  1051. !RandomTest methodsFor: 'tests'!
  1052. textNext
  1053. 10000 timesRepeat: [
  1054. | current next |
  1055. next := Random new next.
  1056. self assert: (next >= 0).
  1057. self assert: (next < 1).
  1058. self deny: current = next.
  1059. next = current]
  1060. ! !
  1061. TestCase subclass: #SetTest
  1062. instanceVariableNames: ''
  1063. package: 'Kernel-Tests'!
  1064. !SetTest methodsFor: 'tests'!
  1065. testAddRemove
  1066. | set |
  1067. set := Set new.
  1068. self assert: set isEmpty.
  1069. set add: 3.
  1070. self assert: (set includes: 3).
  1071. set add: 5.
  1072. self assert: (set includes: 5).
  1073. set remove: 3.
  1074. self deny: (set includes: 3)
  1075. !
  1076. testAt
  1077. self should: [Set new at: 1 put: 2] raise: Error
  1078. !
  1079. testPrintString
  1080. | set |
  1081. set := Set new.
  1082. self assert: 'a Set ()' equals: ( set printString ).
  1083. set add: 1; add: 3.
  1084. self assert: 'a Set (1 3)' equals: ( set printString ).
  1085. set add: 'foo'.
  1086. self assert: 'a Set (1 3 ''foo'')' equals: ( set printString ).
  1087. set remove: 1; remove: 3.
  1088. self assert: 'a Set (''foo'')' equals: ( set printString ).
  1089. set add: 3.
  1090. self assert: 'a Set (''foo'' 3)' equals: ( set printString ).
  1091. set add: 3.
  1092. self assert: 'a Set (''foo'' 3)' equals: ( set printString ).
  1093. !
  1094. testSize
  1095. self assert: Set new size equals: 0.
  1096. self assert: (Set withAll: #(1 2 3 4)) size equals: 4.
  1097. self assert: (Set withAll: #(1 1 1 1)) size equals: 1
  1098. !
  1099. testUnicity
  1100. | set |
  1101. set := Set new.
  1102. set add: 21.
  1103. set add: 'hello'.
  1104. set add: 21.
  1105. self assert: set size = 2.
  1106. set add: 'hello'.
  1107. self assert: set size = 2.
  1108. self assert: set asArray equals: #(21 'hello')
  1109. ! !
  1110. TestCase subclass: #UndefinedTest
  1111. instanceVariableNames: ''
  1112. package: 'Kernel-Tests'!
  1113. !UndefinedTest methodsFor: 'tests'!
  1114. testCopying
  1115. self assert: nil copy equals: nil
  1116. !
  1117. testDeepCopy
  1118. self assert: nil deepCopy = nil
  1119. !
  1120. testIfNil
  1121. self assert: (nil ifNil: [true]) equals: true.
  1122. self deny: (nil ifNotNil: [true]) = true.
  1123. self assert: (nil ifNil: [true] ifNotNil: [false]) equals: true.
  1124. self deny: (nil ifNotNil: [true] ifNil: [false]) = true
  1125. !
  1126. testIsNil
  1127. self assert: nil isNil.
  1128. self deny: nil notNil.
  1129. ! !