[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[py8] 10

.
self running: 'Tests - core tests'
self notNil
true yourself

Object yourself == Object
Object class yourself = Object class

Class isClass
Object isClass
Point isClass
Smalltalk isClass

Smalltalk class isClass not
Object class isClass not
Point class isClass not
Class class isClass not

Point isMetaclass not
Point class isMetaclass
Point instanceClass = Point
Point class instanceClass = Point

Object superclass isNil
Object class superclass = Class

12 isObject: 12
12 isObject: #hello
Smalltalk isObject: Smalltalk
Smalltalk isObject: Smalltalk class
#hello isObject: Point zero
Point zero isObject: #hello

self = self
self == self
nil = nil
nil == nil
1 = 1
#hello = #hello
"1 == 1
"#hello == #hello
Object = Object
Object == Object
Object class = Object class
Object class == Object class

Point zero isClass not
Smalltalk classes notEmpty

Object notNil
Object superclass isNil
Object class notNil
Object class superclass == Class
Object new yourself notNil

Object name notNil
Object class name notNil

self running: 'test[s8] Array literals - http://swiki.smalltalking.net/s8-media/205'
#() isArray
#() size = 0
#() isEmpty
#(1 2 3 4) size = 4
#(1 2.3 3.1 4) size = 4
#( one #two ) size = 2
#( one #two ) first isString
#( one #two ) second isString
#( one #two ) last = #two
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) size = 12
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) first isNumber
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) second isString
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) third isNumber
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) fourth isString
(#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) at: 9) isNil
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) at: 10
#( 1.2 + 5 new #new new: New: Point nil true false under_scored ) last isString
#( One #(Two nil #() ) ) isArray
#( One #(Two nil #() ) ) size = 2
#( One #(Two nil #() ) ) first isString
#( One #(Two nil #() ) ) second first isString
#( One #(Two nil #() ) ) second second isNil
#( One #(Two nil #() ) ) second third isArray
#( One #(Two nil #() ) ) second third isEmpty
#( - 1 ) size = 2
#( - 1 ) = #( - 1 )
#( - 1 ) = (Array with: $- with: 1)

self running: 'test[s8] equality tests - http://swiki.smalltalking.net/s8-media/237'
true = true
nil isNil
nil notNil = false
(1 @ 1) notNil
1 + 1 / 2 = 1 = true
1 + 1 - 1 = 2 = false
1 + 1 - 1 = #1 = false
1 + 1 - 1 = $1 = false
1 + 1 - 1 = true = false
1 - 1 = nil = false
1 - 1 = false = false
1 - 1 = (1 - 2) = false
$a = #a = true
12 = 12 = true
nil = nil = true
12 = nil = false
nil = 12 = false
1 + 1 = (8 - 6) = true
#(1 2 3) = #(3 2 1) reversed = true
true = #true = false
#12 = (10 + 2) = false
#1 = (1 + 1 - 1) = false
Array new = 0 = false
0 = #() = false
#() = #()
#(1) = #(1)
#(0) = 0 = false
0 = #(0) = false
#(#(0 1)) first first = 0 = true
#(#(0 1)) last last = 1 = true
#(98) = nil = false
#(7 nil) last = nil = true
nil = #(98) = false
nil = #(98 nil) last = true
#(98) last - 98 = 0 = true
5 @ 3 = false = false
5 @ 3 = true = false
5 @ 3 = nil = false
1 @ 1 = #hello = false
1 @ 1 = 3 = false
1 @ 1 = 1
1 @ 1 = (1@1)
1 @ 1 isKindOf: Point
(3 timesRepeat: [:i| i * i > i ]) = 3
Point zero + 1 = 1

self running: 'test[s8] IKO and responds tests - http://swiki.smalltalking.net/s8-media/238'
5@3 isKindOf: Point
(2 isKindOf: Point) not
(5@3 isKindOf: nil) = false
"(MyUndefinedGlobal isKindOf: Point) not
"(MyUndefinedGlobal respondsTo: #yourself) not
Point respondsTo: #basicNew
(Point respondsTo: nil) not
(Point respondsTo: 12) not
(Point respondsTo: #unknown) not

(Point isKindOf: Point) = false
(Point new isKindOf: Point) = true
((Point x: 1 y: 3) isKindOf: Point) = true

self running: 'test[s8] division and reminder - http://swiki.smalltalking.net/s8-media/273'
5 \\ 1.5 = (5 - (5 // 1.5 * 1.5))
5 \\ 7 = (5 - (5 // 7 * 7))
5 \\ 8.5 = (5 - (5 // 8.5 * 8.5))
5 \\ 2 = (5 - (5 // 2 * 2))
5 \\ -1.5 = (5 - (5 // -1.5 * -1.5))
-5 \\ 7 = (-5 - (-5 // 7 * 7))
-5 \\ 7 = (-5 - (-5 // 7 * 7))
-5 \\ 8.5 = (-5 - (-5 // 8.5 * 8.5))
5 \\ -2 = (5 - (5 // -2 * -2))
5.5 \\ 2 = (5.5 - (5.5 // 2 * 2))
5 // 2 = 2
2 // 5 = 0
5.5 // -2.2 = -2
-5.5 // -2.2 = 2
"[5 \\ 0] on: Error do: [:ex | ^true ]. ^false
"[5 // 0] on: Error do: [:ex | ^true ]. ^false

self running: 'test[s8] identity tests - http://swiki.smalltalking.net/s8-media/392'
"1 + 1 == 2
1 + 1 - 1 == 2 = false
(1 + 1 - 1) toString = $1
1 - 1 == nil = false
1 - 1 == false = false
1 - 1 == (1 - 2) = false
[ | x | x := 5@3. x == x = true ] value
"$a == #a
"12 == 12
nil == nil
"1 + 1 == (8 - 6)
#(1 2 3) == #(3 2 1) reversed = false
true == #true = false
#12 == (10 + 2) = false
#1 == (1 + 1 - 1) = false
Array new == 0 = false
0 == Array new = false
"0 == XXXX = false
"XXXX == 0 = false
"XXXX == nil = false
#(0) == 0 = false
0 == #(0) = false
"#(#(0 1)) first first == 0
"#(#(0 1)) last last == 1
#(98) == nil = false
#(7 nil) last == nil
nil = #(98) == false
nil == #(98 nil) last = true
"#(98) last - 98 == 0

self running: 'sunit[s8] iterating - http://swiki.smalltalking.net/s8-media/795'
((1 to: 10) collect: [:i| i ]) = #(1 2 3 4 5 6 7 8 9 10)
((10 to: 1) collect: [:i| i ]) isEmpty
((10 to: 1 by: -1) collect: [:i| i ]) = #(10 9 8 7 6 5 4 3 2 1)
((10 to: 1 by: -7) collect: [:i| i ]) = #(10 3)
(($A to: $Z) collect: [:i| i ]) = #(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
(($A to: $Z by: 7) collect: [:i| i ]) = #(A H O V)
(($A to: $Z by: 7) + 1 collect: [:i| i ]) = #(B I P W)

self running: 'Smalltalk class tests'
Smalltalk current notNil
Smalltalk current yourself = Smalltalk current 
Smalltalk current isKindOf: Smalltalk
Smalltalk classes notEmpty
(Smalltalk @ #Point) first = Point
(Smalltalk @ #missingGlobal) isEmpty
Smalltalk @ #Point do: [:cls| ^true ]. ^false
Smalltalk @ #missingGlobal do: [:g| ^false ].^true
(Smalltalk at: #Point) = Point
(Smalltalk at: #missingGlobal) isNil
Smalltalk gc notNil
Smalltalk includesKey: #Point
Smalltalk isRunningOn: Smalltalk nativeLanguage
Smalltalk rootClasses notEmpty
self running: 'Smalltalk methods and selectors tests'
Smalltalk selectors includes: #product
"Smalltalk allMethodsDo: [:each| ^each classField = Object ]. ^false
Smalltalk allSelectors notEmpty
Smalltalk allSelectorsDo: [:each| ^each notNil ]. ^false
self running: 'Smalltalk implementors tests'
(Object implementorsOf: #yourself) notEmpty
self running: 'Smalltalk senders tests'
(Smalltalk sendersOf: #yourself) notEmpty

self running: 'Smalltalk instance tests'
(Smalltalk current @ #Point) = Point
Smalltalk current @ #(Boolean 1)
(Smalltalk current at: #Point) = Point
(Smalltalk current at: #missingGlobal ifAbsent: [ #missing ]) = #missing
Smalltalk current product = #S8
Smalltalk current buildString isString
#nil compilerSupport = Compiler
Smalltalk current deepCopy == Smalltalk current 
Smalltalk current description isKindOf: String
(Smalltalk current eval: 'return (1 + 2)') = 3
(Smalltalk current eval: 'return smalltalk.classes()') = Smalltalk current classes
Smalltalk current imageFileName notEmpty
Smalltalk current implementors size > 2000
Smalltalk current includesKey: #Point
(Smalltalk current includesKey: nil) = false
(Smalltalk current includesKey: #missingGlobal) = false
Smalltalk current licenseTerms isString
Smalltalk current licenseHolders isString
(Smalltalk current withState: #test do: [ Smalltalk current state ]) = #test

self running: 'Smalltalk lookup'
Smalltalk includesKey: #Object
(Smalltalk includesKey: 'absent key') not
(Smalltalk includesKey: nil) not
(Smalltalk includesKey: 12) not
(Smalltalk includesKey: #()) not

self running: 'test[s8] isObject - http://swiki.smalltalking.net/s8-media/320'
self isObject: Point
self isObject: Point class
self isObject: Object new

self isObject: true
self isObject: false
self isObject: 12
self isObject: 0
self isObject: 1
self isObject: 1 - 1
self isObject: #()
self isObject: #(7)
self isObject: #hello
self isObject: ''
self isObject: [ #hello ]

"(self isObject: #{nil}) not
"(self isObject: nil) not
"(self isObject: nil json) not
"(self isObject: (5@3) json) not

self running: 'test[s8] isNil overwride - http://swiki.smalltalking.net/s8-media/239'
" see test method in tests.st "
"Point new isNil
"Point removeSelector: #isNil

self running: 'test[s8] on: Error do:... - http://swiki.smalltalking.net/s8-media/240'
[true] on: Error do: [false]
[ #broken dnu. false ] on: Exception do: [:ex| true]
[5 \\ 0. false] on: Exception do: [:ex| true ]
[5 // 0. false] on: Exception do: [:ex| true ]

self running: 'test[s8] strict arithmetic - http://swiki.smalltalking.net/s8-media/277'
[  5 + #34. false ] on: Exception do: [:ex| true ]
[ 5 + Array new. false ] on: Exception do: [:ex| true ]
[ 5 * #( 1 2 3 ).false ] on: Exception do: [:ex| true ]
[ 5 / #(1). false ] on: Exception do: [:ex| true ]
[ 5 \\ Array new. false ] on: Exception do: [:ex| true ]

self running: 'Printing tests...'
(true toString: #hello) = #hello " Object>>#toString: "
(#hello toString: true) = #true
(#hello toString: nil) = #nil
(#hello toString: 12) = #12
"(1001 toString: 12) = #6b5 "conversion to base 12, see Number>>#toString: "
"(12 toString: 12) = #10  "conversion to base 12, see Number>>#toString: "

self running: 'inheritance & IKO'
Behavior inheritsFrom: Object
(Object inheritsFrom: Behavior) not
Object class allSuperclasses includes: Behavior
Object class inheritsFrom: Behavior

Object isKindOf: Behavior
Point isKindOf: Behavior
Point zero isKindOf: Point