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

test[m8n] 02 SystemDictionary


--test binding and access to s8 smalltalk
if (not smalltalk) then require("boot") end
if (smalltalk==nil) then error("Global smalltalk is missing") end

--Ensure nativeLanguage is "lua"
if (smalltalk.Smalltalk:nativeLanguage()~="lua") then error("Invalid native language (must be lua)") end

--ensure core nil detection functions are present
if (type(smalltalk.isNil_)~="function") then error("#isNil: is missing/broken") end
if (type(smalltalk.notNil_)~="function") then error("#notNil: is missing/broken") end
if (type(smalltalk.isNil)~="function") then error("#isNil is missing/broken") end
if (type(smalltalk.notNil)~="function") then error("#notNil is missing/broken") end


--tests for smalltalk.isNil
if (smalltalk:isNil_(smalltalk.Object)) then error("Invalid result") end
if (smalltalk:isNil_(1)) then error("Invalid result") end
if (smalltalk:isNil_(0)) then error("Invalid result") end
if (smalltalk:isNil_(true)) then error("Invalid result") end
if (smalltalk:isNil_(false)) then error("Invalid result") end
if (smalltalk:isNil_("")) then error("Invalid result") end
if (smalltalk:isNil_("nil")) then error("Invalid result") end
if (not smalltalk:isNil_(nil)) then error("Must be true") end
if (smalltalk:isNil_(smalltalk)) then error("Must be false") end
if (smalltalk:isNil_(smalltalk.Object)) then error("Must be false") end
if (smalltalk:isNil_(1)) then error("Must be false") end
if (smalltalk:isNil_("hello")) then error("Must be false") end

--tests for nil alias
if (not (smalltalk:isNil_((nil):class():alias()))) then error("nil alias broken") end


--Array instantiation
local array=smalltalk:newArray(); array[1]=123; print("Array size="..tostring(#array).." first="..tostring(array[1])); if (array["$klass"]["$className"]~="Array") then error("Must be Array") else print("Ok") end


--lookup walking
if (smalltalk:whoImplements(smalltalk.Point,"yourself") ~= smalltalk.Object) then error("Must be Object") end


--walking global names
smalltalk:globalsDo(function(each) print("  "..each) end)