Initial commit
This commit is contained in:
37
engines/director/lingo/tests/XObjects.lingo
Normal file
37
engines/director/lingo/tests/XObjects.lingo
Normal file
@@ -0,0 +1,37 @@
|
||||
openXLib("FlushXObj")
|
||||
set flush = FlushXObj(mNew)
|
||||
flush(mClearMask)
|
||||
flush(mAddToMask, 0, 0)
|
||||
flush(mFlush)
|
||||
flush(mFlushEvents, 0, 0)
|
||||
|
||||
openXLib("PalXObj")
|
||||
set fixpal = FixPalette(mNew, 0, 20, 512, 20)
|
||||
fixpal(mPatchIt)
|
||||
|
||||
openXLib("winXOBJ")
|
||||
set winxobj = RearWindow(mNew, "M")
|
||||
scummVMAssert(winxobj(mGetMemoryNeeded) = 0)
|
||||
|
||||
-- test closing XObject
|
||||
scummVMAssert(objectp(FlushXObj) = 1)
|
||||
closeXlib "FlushXObj"
|
||||
scummVMAssert(objectp(FlushXObj) = 0)
|
||||
|
||||
scummVMAssert(objectp(RearWindow) = 1)
|
||||
closeXlib()
|
||||
scummVMAssert(objectp(RearWindow) = 0)
|
||||
|
||||
-- test showGlobals and clearGlobals on XObjects
|
||||
clearGlobals()
|
||||
openXLib("FileIO")
|
||||
scummVMAssert(objectp(FileIO))
|
||||
|
||||
showGlobals() -- FileIO should not be listed
|
||||
clearGlobals()
|
||||
scummVMAssert(objectp(FileIO)) -- FileIO should not be cleared
|
||||
|
||||
set FileIO = "test"
|
||||
showGlobals() -- FileIO should be listed
|
||||
clearGlobals()
|
||||
scummVMAssert(voidp(FileIO)) -- FileIO should be cleared
|
||||
BIN
engines/director/lingo/tests/blend2.pic
Normal file
BIN
engines/director/lingo/tests/blend2.pic
Normal file
Binary file not shown.
55
engines/director/lingo/tests/builtin.lingo
Normal file
55
engines/director/lingo/tests/builtin.lingo
Normal file
@@ -0,0 +1,55 @@
|
||||
beep
|
||||
beep 3
|
||||
alert "Hi"
|
||||
alert "Hi" && "there"
|
||||
|
||||
open "Hello"
|
||||
open "Hello" with "Finder"
|
||||
open "Hello" && "more" with "Finder"
|
||||
|
||||
-- These are D4+
|
||||
move cast 1, cast 1
|
||||
move cast 1, 3
|
||||
move cast 3, 1
|
||||
move cast 1
|
||||
|
||||
put findEmpty(cast 10)
|
||||
pasteClipBoardInto cast 2
|
||||
put the width of cast 1
|
||||
|
||||
-- Puppet commands must come after the move commands
|
||||
-- move does a force render. Combined with puppetTransitions it just waits and causes a timeout on the buildbot
|
||||
puppetPalette "Rainbow"
|
||||
puppetPalette "System",30
|
||||
puppetPalette "custompal", 15,4
|
||||
|
||||
puppetSound "Air Lock Lock"
|
||||
puppetSound 0
|
||||
|
||||
puppetSprite 15, true
|
||||
|
||||
puppetTempo 30
|
||||
puppetTransition 1
|
||||
puppetTransition 2,4,20
|
||||
|
||||
unload
|
||||
unload ab
|
||||
unload ab, bc
|
||||
|
||||
put framesToHMS(integer(field 3),30,false,false) into field 5
|
||||
|
||||
set save to the scummvmVersion
|
||||
|
||||
set the scummvmVersion to 300
|
||||
scummvmAssert(version = "3.0")
|
||||
set the scummvmVersion to 310
|
||||
scummvmAssert(version = "3.1")
|
||||
set the scummvmVersion to 404
|
||||
scummvmAssert(version = "4.0.4")
|
||||
set the scummvmVersion to 1201
|
||||
scummvmAssert(version = "12.0.1")
|
||||
|
||||
set the scummvmVersion to save
|
||||
|
||||
set n = getNthFileNameInFolder("@", 1)
|
||||
scummvmAssertEqual(n, "0testfile")
|
||||
23
engines/director/lingo/tests/c2.lingo
Normal file
23
engines/director/lingo/tests/c2.lingo
Normal file
@@ -0,0 +1,23 @@
|
||||
-- This file is binary. Watch for 0xC2 symbol at the line ends
|
||||
|
||||
if the text of cast 1 <> the text of cast 2 then Â
|
||||
put "Hello"
|
||||
|
||||
if the text of cast 1 <> the text of cast 2 then Â
|
||||
put "Goodbye"
|
||||
|
||||
set the selStart to Â
|
||||
0
|
||||
|
||||
set the selStart to Â
|
||||
0
|
||||
|
||||
-- This comment is Â
|
||||
the continuationÂ
|
||||
of previous line
|
||||
|
||||
if the castNum of sprite 1 > the number of cast 2 then set the castNum of sprite 1 to the number of Â
|
||||
cast 1
|
||||
|
||||
put "HelloÂ
|
||||
World!"
|
||||
45
engines/director/lingo/tests/chunks.lingo
Normal file
45
engines/director/lingo/tests/chunks.lingo
Normal file
@@ -0,0 +1,45 @@
|
||||
-- put randomName() into item i of field "In"
|
||||
|
||||
-- put the last word of field 1 into field 3
|
||||
|
||||
scummvmAssertEqual(the last char of "Macromedia, the multimedia company", "y")
|
||||
scummvmAssertEqual(the last word of "Macromedia, the multimedia company", "company")
|
||||
scummvmAssertEqual(the last word of "Macromedia, the multimedia company" && "man", "company man")
|
||||
scummvmAssertEqual(word -30000 of "Macromedia, the multimedia company", "company")
|
||||
scummvmAssertEqual(word -30000 of "Macromedia, the multimedia company" && "man", "company man")
|
||||
|
||||
set src = "abcdefghijklmnopqrstuvwxyz"
|
||||
scummvmAssertEqual(char 2 of src, "b")
|
||||
scummvmAssertEqual(char 2 to 0 of src, "b")
|
||||
scummvmAssertEqual(char 2 to 4 of src, "bcd")
|
||||
scummvmAssertEqual(char 2 to 1000 of src, "bcdefghijklmnopqrstuvwxyz")
|
||||
scummvmAssertEqual(char 1000 of src, "")
|
||||
|
||||
set src = " the quick brown fox jumped over the lazy dog"
|
||||
scummvmAssertEqual(word 2 of src, "quick")
|
||||
scummvmAssertEqual(word 2 to 4 of src, "quick brown fox")
|
||||
scummvmAssertEqual(word 2 to 1000 of src, "quick brown fox jumped over the lazy dog")
|
||||
scummvmAssertEqual(word 1000 of src, "")
|
||||
|
||||
set src = "the,quick,brown,fox,jumped,over,the,lazy,dog"
|
||||
scummvmAssertEqual(item 2 of src, "quick")
|
||||
scummvmAssertEqual(item 2 to 4 of src, "quick,brown,fox")
|
||||
scummvmAssertEqual(item 2 to 1000 of src, "quick,brown,fox,jumped,over,the,lazy,dog")
|
||||
scummvmAssertEqual(item 1000 of src, "")
|
||||
|
||||
set src = "the quick" & RETURN & "brown fox" & RETURN & "jumped over" & RETURN & "the lazy dog"
|
||||
scummvmAssertEqual(line 2 of src, "brown fox")
|
||||
scummvmAssertEqual(line 2 to 4 of src, "brown fox" & RETURN & "jumped over" & RETURN & "the lazy dog")
|
||||
scummvmAssertEqual(line 2 to 1000 of src, "brown fox" & RETURN & "jumped over" & RETURN & "the lazy dog")
|
||||
scummvmAssertEqual(line 1000 of src, "")
|
||||
|
||||
put "abcdefghijklmnopqrstuvwxyz" into field 1
|
||||
scummvmAssertEqual(char 2 of field 1, "b")
|
||||
scummvmAssertEqual(char 2 to 0 of field 1, "b")
|
||||
scummvmAssertEqual(char 2 to 4 of field 1, "bcd")
|
||||
scummvmAssertEqual(char 2 to 1000 of field 1, "bcdefghijklmnopqrstuvwxyz")
|
||||
scummvmAssertEqual(char 1000 of field 1, "")
|
||||
|
||||
put "lorem ipsum dolor sit amet" into field 1
|
||||
set the foreColor of word 2 of field 1 to 10
|
||||
put the foreColor of word 2 of field 1
|
||||
93
engines/director/lingo/tests/delete.lingo
Normal file
93
engines/director/lingo/tests/delete.lingo
Normal file
@@ -0,0 +1,93 @@
|
||||
put "qwertyuiop" into test
|
||||
delete char 2 of test
|
||||
scummvmAssertEqual(test, "qertyuiop")
|
||||
|
||||
put "qwertyuiop" into test
|
||||
delete char 2 to 9 of test
|
||||
scummvmAssertEqual(test, "qp")
|
||||
|
||||
put "qwertyuiop" into test
|
||||
delete char 2 to 1000 of test
|
||||
scummvmAssertEqual(test, "q")
|
||||
|
||||
put "qwertyuiop" into test
|
||||
delete char 0 of test
|
||||
scummvmAssertEqual(test, "")
|
||||
|
||||
put "qwertyuiop" into test
|
||||
delete the last char of test
|
||||
scummvmAssertEqual(test, "qwertyuio")
|
||||
|
||||
put "lorem ipsum dolor" into test
|
||||
delete word 2 of test
|
||||
scummvmAssertEqual(test, "lorem dolor")
|
||||
|
||||
put "lorem ipsum dolor" into test
|
||||
delete word 2 to 3 of test
|
||||
scummvmAssertEqual(test, "lorem ")
|
||||
|
||||
put "lorem ipsum dolor" into test
|
||||
delete word 2 to 1000 of test
|
||||
scummvmAssertEqual(test, "lorem ")
|
||||
|
||||
put "lorem ipsum dolor" into test
|
||||
delete the last word of test
|
||||
scummvmAssertEqual(test, "lorem ipsum ")
|
||||
|
||||
put "lorem,ipsum,dolor,sit,amet" into test
|
||||
delete item 3 of test
|
||||
scummvmAssertEqual(test, "lorem,ipsum,sit,amet")
|
||||
|
||||
put "lorem,ipsum,dolor,sit,amet" into test
|
||||
delete item 2 to 5 of test
|
||||
scummvmAssertEqual(test, "lorem")
|
||||
|
||||
put "lorem,ipsum,dolor,sit,amet" into test
|
||||
delete item 1 of test
|
||||
scummvmAssertEqual(test, "ipsum,dolor,sit,amet")
|
||||
|
||||
put "lorem,ipsum,dolor,sit,amet" into test
|
||||
delete the last item of test
|
||||
scummvmAssertEqual(test, "lorem,ipsum,dolor,sit")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit" & RETURN & "amet" into test
|
||||
delete line 3 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "sit" & RETURN & "amet")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit" & RETURN & "amet" into test
|
||||
delete line 2 to 5 of test
|
||||
scummvmAssertEqual(test, "lorem")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit" & RETURN & "amet" into test
|
||||
delete the last line of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "dolor" & RETURN & "sit")
|
||||
|
||||
put "foo" & RETURN & "lorem ipsum" into test
|
||||
delete char 3 of word 2 of line 2 of test
|
||||
scummvmAssertEqual(test, "foo" & RETURN & "lorem ipum")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor,sit,amet" & RETURN & "nunc" into test
|
||||
delete item 1 of line 3 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "sit,amet" & RETURN & "nunc")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor,sit,amet" & RETURN & "nunc" into test
|
||||
delete item 2 of line 3 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "dolor,amet" & RETURN & "nunc")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor,sit,amet" & RETURN & "nunc" into test
|
||||
delete item 3 of line 3 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & "ipsum" & RETURN & "dolor,sit" & RETURN & "nunc")
|
||||
|
||||
put "lorem" & RETURN & "ipsum" & RETURN & "dolor,sit,amet" & RETURN & "nunc" into test
|
||||
delete item 1 of line 2 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & RETURN & "dolor,sit,amet" & RETURN & "nunc")
|
||||
delete item 1 of line 2 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & RETURN & "dolor,sit,amet" & RETURN & "nunc")
|
||||
delete item 4 of line 2 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & RETURN & "dolor,sit,amet" & RETURN & "nunc")
|
||||
delete item 4 of line 4 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & RETURN & "dolor,sit,amet" & RETURN & "nunc")
|
||||
delete item 1 of line 4 of test
|
||||
scummvmAssertEqual(test, "lorem" & RETURN & RETURN & "dolor,sit,amet" & RETURN)
|
||||
|
||||
|
||||
249
engines/director/lingo/tests/equality.lingo
Normal file
249
engines/director/lingo/tests/equality.lingo
Normal file
@@ -0,0 +1,249 @@
|
||||
scummvmAssert(VOID = VOID)
|
||||
scummvmAssert(not(VOID < VOID))
|
||||
scummvmAssert(VOID <= VOID)
|
||||
scummvmAssert(not(VOID > VOID))
|
||||
scummvmAssert(VOID >= VOID)
|
||||
|
||||
scummvmAssert(VOID = 0)
|
||||
scummvmAssert(VOID < 0)
|
||||
scummvmAssert(VOID <= 0)
|
||||
scummvmAssert(not(VOID > 0))
|
||||
scummvmAssert(not(VOID >= 0))
|
||||
|
||||
scummvmAssert(not(0 = VOID))
|
||||
scummvmAssert(0 > VOID)
|
||||
scummvmAssert(0 >= VOID)
|
||||
scummvmAssert(not(0 < VOID))
|
||||
scummvmAssert(not(0 <= VOID))
|
||||
|
||||
scummvmAssert(1 = 1)
|
||||
scummvmAssert(1 = "1")
|
||||
scummvmAssert(1 = 1.0)
|
||||
scummvmAssert(cast 1 = cast 1)
|
||||
scummvmAssert("test" = "test")
|
||||
scummvmAssert(#test = #test)
|
||||
set string = the text of field 1
|
||||
scummvmAssert(field 1 = string)
|
||||
scummvmAssert(0 = "")
|
||||
scummvmAssert(1 <> cast 1)
|
||||
scummvmAssert("test" <> #test)
|
||||
|
||||
-- If string parses as a float, coerce to float
|
||||
scummvmAssert("2000" > 25)
|
||||
scummvmAssert(25 < "2000")
|
||||
scummvmAssert("2000.5" > 25)
|
||||
scummvmAssert(25 < "2000.5")
|
||||
scummvmAssert("20e5" > 25)
|
||||
scummvmAssert(25 < "20e5")
|
||||
scummvmAssert(" 2000" > 25)
|
||||
scummvmAssert(25 < " 2000")
|
||||
scummvmAssert("2000" > 2.5)
|
||||
scummvmAssert(25 < "2000")
|
||||
scummvmAssert("2000.5" > 2.5)
|
||||
scummvmAssert(2.5 < "2000.5")
|
||||
scummvmAssert("20e5" > 2.5)
|
||||
scummvmAssert(2.5 < "20e5")
|
||||
scummvmAssert(" 2000" > 2.5)
|
||||
scummvmAssert(2.5 < " 2000")
|
||||
|
||||
-- If a string doesn't parse as a float, coerce the number to a string
|
||||
scummvmAssert("2/" < 20)
|
||||
scummvmAssert(20 > "2/")
|
||||
scummvmAssert("2000 e" < 25)
|
||||
scummvmAssert(25 > "2000 e")
|
||||
|
||||
-- Two strings, treat with normal string ordering rules
|
||||
scummvmAssert("2000" <> "2000.0")
|
||||
scummvmAssert("2000" < "25")
|
||||
scummvmAssert("abc" < "abcd")
|
||||
scummvmAssert("abc" < "def")
|
||||
|
||||
-- Non-coercable string is always bigger than a number or void
|
||||
scummvmAssert("test" > 3000)
|
||||
scummvmAssert(3000 < "test")
|
||||
scummvmAssert("test" > 300.0)
|
||||
scummvmAssert(300.0 < "test")
|
||||
scummvmAssert("test" > VOID)
|
||||
scummvmAssert(VOID < "test")
|
||||
|
||||
|
||||
-- Mimic an object
|
||||
scummvmAssert("<Object:#FileIO" > 0)
|
||||
|
||||
-- Invalid comparisons should return FALSE
|
||||
scummvmAssert(not (#test <= 0))
|
||||
|
||||
-- Picture comparisons are always false, even between the exact same cast.
|
||||
-- set a to the picture of cast 1
|
||||
-- scummvmAssert(a <> a)
|
||||
-- scummvmAssert(a <> the picture of cast 1) -- always false
|
||||
|
||||
|
||||
-- String comparison
|
||||
scummvmAssert("a" = "A")
|
||||
scummvmAssert(not("a" < "A"))
|
||||
scummvmAssert(not("a" <= "A"))
|
||||
scummvmAssert("a" > "A")
|
||||
scummvmAssert("a" >= "A")
|
||||
|
||||
scummvmAssert(not("a" = "Z"))
|
||||
scummvmAssert("a" < "Z")
|
||||
scummvmAssert("a" <= "Z")
|
||||
scummvmAssert(not("a" > "Z"))
|
||||
scummvmAssert(not("a" >= "Z"))
|
||||
|
||||
scummvmAssert(not("Z" = "a"))
|
||||
scummvmAssert(not("Z" < "a"))
|
||||
scummvmAssert(not("Z" <= "a"))
|
||||
scummvmAssert("Z" > "a")
|
||||
scummvmAssert("Z" >= "a")
|
||||
|
||||
scummvmAssert(not("a" = "Bubba"))
|
||||
scummvmAssert("a" < "Bubba")
|
||||
scummvmAssert("a" <= "Bubba")
|
||||
scummvmAssert(not("a" > "Bubba"))
|
||||
scummvmAssert(not("a" >= "Bubba"))
|
||||
|
||||
scummvmAssert("z" = "Z")
|
||||
scummvmAssert(not("z" < "Z"))
|
||||
scummvmAssert(not("z" <= "Z"))
|
||||
scummvmAssert("z" > "Z")
|
||||
scummvmAssert("z" >= "Z")
|
||||
|
||||
scummvmAssert("abba" = "Abba")
|
||||
scummvmAssert(not("abba" < "Abba"))
|
||||
scummvmAssert(not("abba" <= "Abba"))
|
||||
scummvmAssert("abba" > "Abba")
|
||||
scummvmAssert("abba" >= "Abba")
|
||||
|
||||
scummvmAssert("Erwin's Catalyst" = "Erwin's Catalyst")
|
||||
scummvmAssert(not("Erwin's Catalyst" < "Erwin's Catalyst"))
|
||||
scummvmAssert("Erwin's Catalyst" <= "Erwin's Catalyst")
|
||||
scummvmAssert(not("Erwin's Catalyst" > "Erwin's Catalyst"))
|
||||
scummvmAssert("Erwin's Catalyst" >= "Erwin's Catalyst")
|
||||
|
||||
-- Char 213 resolves to U+2018 LEFT SINGLE QUOTATION MARK under D4-mac
|
||||
scummvmAssert("Erwin's Catalyst" = ("Erwin" & numToChar(213) & "s Catalyst"))
|
||||
scummvmAssert("Erwin's Catalyst" < ("Erwin" & numToChar(213) & "s Catalyst"))
|
||||
scummvmAssert("Erwin's Catalyst" <= ("Erwin" & numToChar(213) & "s Catalyst"))
|
||||
scummvmAssert(not("Erwin's Catalyst" > ("Erwin" & numToChar(213) & "s Catalyst")))
|
||||
scummvmAssert(not("Erwin's Catalyst" >= ("Erwin" & numToChar(213) & "s Catalyst")))
|
||||
|
||||
|
||||
-- Array comparison with coercion
|
||||
scummvmAssert([] = [])
|
||||
scummvmAssert(not([] <> []))
|
||||
scummvmAssert([1, 2] = [1, 2])
|
||||
scummvmAssert(not([1, 2] <> [1, 2]))
|
||||
scummvmAssert([1, 2] = [1, "2"])
|
||||
scummvmAssert(not([1, 2] <> [1, "2"]))
|
||||
scummvmAssert([1, 2, 3] = [1, "2", 3.0])
|
||||
scummvmAssert(not([1, 2, 3] <> [1, "2", 3.0]))
|
||||
scummvmAssert(["testa", "testb"] = ["testa", "TESTB"])
|
||||
scummvmAssert([#a: "testa", #b: "testb"] = [#a: "testa", #b: "TESTB"])
|
||||
|
||||
-- D4 has a quirk where only the left side list elements are checked
|
||||
set the scummvmVersion to 400
|
||||
scummvmAssert([] = [1, "2", 4])
|
||||
scummvmAssert(not([] <> [1, "2", 4]))
|
||||
scummvmAssert([1, 2] = [1, "2", 4])
|
||||
scummvmAssert(not([1, 2] <> [1, "2", 4]))
|
||||
scummvmAssert([1, 2, 3] <> [1, "2", 4])
|
||||
scummvmAssert(not([1, 2, 3] = [1, "2", 4]))
|
||||
scummvmAssert([1, 2, 3] <> [1, "2"])
|
||||
scummvmAssert(not([1, 2, 3] = [1, "2"]))
|
||||
scummvmAssert([:] = [#a: 1, #b: "2", #c: 4])
|
||||
scummvmAssert(not([:] <> [#a: 1, #b: "2", #c: 4]))
|
||||
scummvmAssert([#a: 1, #b: 2] = [#a: 1, #b: "2", #c: 4])
|
||||
scummvmAssert(not([#a: 1, #b: 2] <> [#a: 1, #b: "2", #c: 4]))
|
||||
scummvmAssert([#a: 1, #b: 2, #c: 3] <> [#a: 1, #b: "2", #c: 4])
|
||||
scummvmAssert(not([#a: 1, #b: 2, #c: 3] = [#a: 1, #b: "2", #c: 4]))
|
||||
scummvmAssert([#a: 1, #b: 2, #c: 3] <> [#a: 1, #b: "2"])
|
||||
scummvmAssert(not([#a: 1, #b: 2, #c: 3] = [#a: 1, #b: "2"]))
|
||||
|
||||
set the scummvmVersion to 500
|
||||
scummvmAssert([] <> [1, "2", 4])
|
||||
scummvmAssert(not([] = [1, "2", 4]))
|
||||
scummvmAssert([1, 2] <> [1, "2", 4])
|
||||
scummvmAssert(not([1, 2] = [1, "2", 4]))
|
||||
scummvmAssert([1, 2, 3] <> [1, "2", 4])
|
||||
scummvmAssert(not([1, 2, 3] = [1, "2", 4]))
|
||||
scummvmAssert([1, 2, 3] <> [1, "2"])
|
||||
scummvmAssert(not([1, 2, 3] = [1, "2"]))
|
||||
scummvmAssert([:] <> [#a: 1, #b: "2", #c: 4])
|
||||
scummvmAssert(not([:] = [#a: 1, #b: "2", #c: 4]))
|
||||
scummvmAssert([#a: 1, #b: 2] <> [#a: 1, #b: "2", #c: 4])
|
||||
scummvmAssert(not([#a: 1, #b: 2] = [#a: 1, #b: "2", #c: 4]))
|
||||
scummvmAssert([#a: 1, #b: 2, #c: 3] <> [#a: 1, #b: "2", #c: 4])
|
||||
scummvmAssert(not([#a: 1, #b: 2, #c: 3] = [#a: 1, #b: "2", #c: 4]))
|
||||
scummvmAssert([#a: 1, #b: 2, #c: 3] <> [#a: 1, #b: "2"])
|
||||
scummvmAssert(not([#a: 1, #b: 2, #c: 3] = [#a: 1, #b: "2"]))
|
||||
|
||||
-- single-element equality check, check to see if all list elements match
|
||||
scummvmAssert(0 = [])
|
||||
scummvmAssert([] = 0)
|
||||
scummvmAssert(not(0 <> []))
|
||||
scummvmAssert(not([] <> 0))
|
||||
scummvmAssert(2 = [])
|
||||
scummvmAssert([] = 2)
|
||||
scummvmAssert(not(2 <> []))
|
||||
scummvmAssert(not([] <> 2))
|
||||
scummvmAssert(2 = [2, 2.0, "2", "2.0"])
|
||||
scummvmAssert([2, 2.0, "2", "2.0"] = 2)
|
||||
scummvmAssert(2 <> [2, 2.0, "2", "2.1"])
|
||||
scummvmAssert([2, 2.0, "2", "2.1"] <> 2)
|
||||
|
||||
scummvmAssert(0 = [:])
|
||||
scummvmAssert([:] = 0)
|
||||
scummvmAssert(not(0 <> [:]))
|
||||
scummvmAssert(not([:] <> 0))
|
||||
scummvmAssert(2 = [:])
|
||||
scummvmAssert([:] = 2)
|
||||
scummvmAssert(not(2 <> [:]))
|
||||
scummvmAssert(not([:] <> 2))
|
||||
scummvmAssert(2 = [#a: 2, #b: 2.0, #c: "2", #d: "2.0"])
|
||||
scummvmAssert([#a: 2, #b: 2.0, #c: "2", #d: "2.0"] = 2)
|
||||
scummvmAssert(2 <> [#a: 2, #b: 2.0, #c: "2", #d: "2.1"])
|
||||
scummvmAssert([#a: 2, #b: 2.0, #c: "2", #d: "2.1"] <> 2)
|
||||
|
||||
scummvmAssert(0 = point(0, 0))
|
||||
scummvmAssert(point(0, 0) = 0)
|
||||
scummvmAssert(2 = point(2, 2))
|
||||
scummvmAssert(point(2, 2) = 2)
|
||||
scummvmAssert(2 <> point(2, 3))
|
||||
scummvmAssert(point(2, 3) <> 2)
|
||||
|
||||
scummvmAssert(0 = rect(0, 0, 0, 0))
|
||||
scummvmAssert(rect(0, 0, 0, 0) = 0)
|
||||
scummvmAssert(2 = rect(2, 2, 2, 2))
|
||||
scummvmAssert(rect(2, 2, 2, 2) = 2)
|
||||
scummvmAssert(2 <> rect(2, 2, 2, 3))
|
||||
scummvmAssert(rect(2, 2, 2, 3) <> 2)
|
||||
|
||||
|
||||
|
||||
-- Void comparison
|
||||
set v1 = value("!")
|
||||
set v2 = value("!")
|
||||
|
||||
scummvmAssert(v1 = v2)
|
||||
scummvmAssert(not(v1 < v2))
|
||||
scummvmAssert(not(v1 > v2))
|
||||
|
||||
scummvmAssert(v1 = 0)
|
||||
scummvmAssert(v1 < 0)
|
||||
scummvmAssert(not(v1 > 0))
|
||||
|
||||
scummvmAssert(not(v1 = 0.0))
|
||||
scummvmAssert(v1 < 0.0)
|
||||
scummvmAssert(not(v1 > 0.0))
|
||||
|
||||
scummvmAssert(not(v1 = "0"))
|
||||
scummvmAssert(v1 < "0")
|
||||
scummvmAssert(not(v1 > "0"))
|
||||
|
||||
scummvmAssert(not(v1 = "what"))
|
||||
scummvmAssert(v1 < "what")
|
||||
scummvmAssert(not(v1 > "what"))
|
||||
|
||||
|
||||
21
engines/director/lingo/tests/events.lingo
Normal file
21
engines/director/lingo/tests/events.lingo
Normal file
@@ -0,0 +1,21 @@
|
||||
on exitFrame
|
||||
beep
|
||||
end exitFrame
|
||||
|
||||
on enterFrame me
|
||||
beep
|
||||
end
|
||||
|
||||
on annoy howMuch
|
||||
beep random(howMuch)
|
||||
alert "Aren't handlers fun?"
|
||||
end annoy
|
||||
|
||||
on annoy2 howMuch
|
||||
beep random(howMuch)
|
||||
alert "Aren't handlers fun?"
|
||||
end annoy2 howMuch
|
||||
|
||||
on move me
|
||||
set h = the locH of sprite pSprite + pChangeH
|
||||
end
|
||||
18
engines/director/lingo/tests/factory-do.lingo
Normal file
18
engines/director/lingo/tests/factory-do.lingo
Normal file
@@ -0,0 +1,18 @@
|
||||
abc(mNew)
|
||||
|
||||
factory abc
|
||||
method mNew
|
||||
instance avar
|
||||
set avar to "a variable"
|
||||
set res1 = me(callDo)
|
||||
scummvmAssertEqual(res1, "a variable")
|
||||
me(setDo)
|
||||
scummvmAssertEqual(avar, 100)
|
||||
|
||||
method callDo
|
||||
set myvar = 0
|
||||
do("set myvar = avar")
|
||||
return myvar
|
||||
|
||||
method setDo
|
||||
do("set avar = 100")
|
||||
143
engines/director/lingo/tests/factory.lingo
Normal file
143
engines/director/lingo/tests/factory.lingo
Normal file
@@ -0,0 +1,143 @@
|
||||
AimGun2
|
||||
|
||||
aim1(mDispose)
|
||||
|
||||
set notAMethod = 0
|
||||
scummvmAssertError aim2(notAMethod) -- should error
|
||||
aim2("notAMethod") -- should run fallback handler
|
||||
|
||||
-- method call syntax without parens
|
||||
GrammarFactory mSetStatusToArg "foo"
|
||||
scummvmAssertEqual status "foo"
|
||||
GrammarFactory mSetStatusToArg2 "foo", "bar"
|
||||
scummvmAssertEqual status "bar"
|
||||
|
||||
-- method call syntax with parens and a comma
|
||||
GrammarFactory(mSetStatusToArg, "foo")
|
||||
scummvmAssertEqual status "foo"
|
||||
GrammarFactory(mSetStatusToArg2, "foo", "bar")
|
||||
scummvmAssertEqual status "bar"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg, "foo") "foo"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg2, "foo", "bar") "bar"
|
||||
|
||||
-- method call syntax with parens and no comma
|
||||
GrammarFactory(mSetStatusToArg "foo")
|
||||
scummvmAssertEqual status "foo"
|
||||
GrammarFactory(mSetStatusToArg2 "foo", "bar")
|
||||
scummvmAssertEqual status "bar"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg "foo") "foo"
|
||||
scummvmAssertEqual GrammarFactory(mReturnArg2 "foo", "bar") "bar"
|
||||
|
||||
--
|
||||
macro AimGun2
|
||||
global aim1
|
||||
set aim1 = aim2(mNew)
|
||||
--
|
||||
factory aim2
|
||||
method mNew
|
||||
dontpassevent
|
||||
global aim1
|
||||
when mousedown then aim1(fire)
|
||||
when keydown then aim1(mExit)
|
||||
set the locv of sprite 24 to 540
|
||||
method mMove x, y
|
||||
global aimCopy
|
||||
set the locH of sprite 15 to x
|
||||
set the locV of sprite 15 to y-250
|
||||
set aimCopy = me
|
||||
method mAtFrame
|
||||
dontpassevent
|
||||
me(mMove, the mouseH, the mouseV)
|
||||
method fire
|
||||
global fire1, targeth, targetv
|
||||
set fire1 = fire2(mNew)
|
||||
set the perframehook to fire1
|
||||
me(mDispose)
|
||||
method mExit
|
||||
set the perframehook to false
|
||||
postfire
|
||||
me(mDispose)
|
||||
method mDispose
|
||||
global aim1
|
||||
set aim1 = 1
|
||||
when keydown then nothing
|
||||
--
|
||||
factory fire2
|
||||
method mNew
|
||||
dontpassevent
|
||||
when mousedown then nothing
|
||||
set the castnum of sprite 14 to f15
|
||||
method mAtFrame
|
||||
Global StartH, StartV, targetv, stepH, stepV, bcast
|
||||
dontpassevent
|
||||
set the castnum of sprite 14 to bcast
|
||||
set the LocV of sprite 14 to (startV-stepV)
|
||||
if sprite 14 intersects 10 and (startV-6) <= targetV then
|
||||
set the castnum of sprite 14 to f16
|
||||
set the perframehook to false
|
||||
me(hit)
|
||||
exit
|
||||
end if
|
||||
if startV < targetV or bcast>g17 then
|
||||
set the perframehook to false
|
||||
set the locV of sprite 14 to 340
|
||||
aimgun2
|
||||
exit
|
||||
end if
|
||||
set startV to (startV-stepV)
|
||||
set bcast = bcast + 1
|
||||
method hit
|
||||
global KillLoc
|
||||
set killloc to the loch of sprite 3
|
||||
go "Death"
|
||||
set the locV of sprite 14 to 400
|
||||
aimgun2
|
||||
if factory(killloc) then put "boo"
|
||||
method mDispose
|
||||
global fire1
|
||||
set fire1 = 0
|
||||
Method mNew2 theSprite, startCastRight, endCastRight, startCastLeft, endCastLeft
|
||||
instance startDrawLeft, endDrawLeft, startDrawRight, endDrawRight, multiDrawP
|
||||
|
||||
if startCastLeft and endCastLeft then set multiDrawP to TRUE
|
||||
set startDrawLeft to startCastRight
|
||||
set endDrawLeft to endCastRight
|
||||
set startDrawRight to startCastLeft
|
||||
set endDrawRight to endCastLeft
|
||||
|
||||
me(mInitBirdPart, theSprite, startCastRight)
|
||||
Method mAtFrame2 frame, subFrame
|
||||
global gMouseH, gMouseV
|
||||
set gMouseH = mouseH()
|
||||
set gMouseV = mouseV()
|
||||
|
||||
-- Exit when "Done" button, which resides upon score channel 6.
|
||||
if (the clickOn = 6) then exit
|
||||
|
||||
put the mouseDown into mouseClick
|
||||
Body(mEveryFrame, mouseClick)
|
||||
RightWing(mEveryFrame, mouseClick)
|
||||
LeftWing(mEveryFrame, mouseClick)
|
||||
|
||||
|
||||
--
|
||||
macro KillIt2
|
||||
global KillLoc
|
||||
set the locH of sprite 3 to KillLoc
|
||||
|
||||
on aim2 test
|
||||
put "fallback worked!"
|
||||
end
|
||||
|
||||
--
|
||||
factory GrammarFactory
|
||||
method mSetStatusToArg arg
|
||||
global status
|
||||
set status = arg
|
||||
method mSetStatusToArg2 arg1, arg2
|
||||
global status
|
||||
set status = arg2
|
||||
method mReturnArg arg
|
||||
return arg
|
||||
method mReturnArg2 arg1, arg2
|
||||
return arg2
|
||||
27
engines/director/lingo/tests/global.lingo
Normal file
27
engines/director/lingo/tests/global.lingo
Normal file
@@ -0,0 +1,27 @@
|
||||
global version
|
||||
|
||||
on initPattern
|
||||
global MaxPattern
|
||||
set MaxPattern = 65
|
||||
put "first: " & MaxPattern
|
||||
set a = 5
|
||||
end initPattern
|
||||
|
||||
on increase
|
||||
global MaxPattern
|
||||
set MaxPattern = MaxPattern + 1
|
||||
put MaxPattern
|
||||
set a = 10
|
||||
end increase
|
||||
|
||||
set a = 8
|
||||
set MaxPattern = 3
|
||||
|
||||
initPattern
|
||||
|
||||
increase
|
||||
increase
|
||||
|
||||
put MaxPattern
|
||||
|
||||
put a
|
||||
28
engines/director/lingo/tests/goto.lingo
Normal file
28
engines/director/lingo/tests/goto.lingo
Normal file
@@ -0,0 +1,28 @@
|
||||
go to frame "Open23" of movie "OpenCabin23"
|
||||
go "CARDBACK"
|
||||
go movie "BAR 1"
|
||||
go to "Open23" of movie "OpenCabin23"
|
||||
go to "Chair"
|
||||
|
||||
set varframe to "VARFrame"
|
||||
set varmovie to "VARMovie"
|
||||
|
||||
go to frame 35
|
||||
go the frame
|
||||
go "label two"
|
||||
go to movie "Chicago"
|
||||
go to frame 23 of movie "Chicago"
|
||||
go to frame "main loop" of movie "Basic With"
|
||||
go to marker(1)
|
||||
go frame "dissolve" of movie "captain's table"
|
||||
|
||||
play frame 37
|
||||
play frame "label one"
|
||||
play movie "Desert Scene"
|
||||
play frame 23 of movie "Chicago"
|
||||
play frame varframe of movie varmovie
|
||||
play frame "main loop" of movie "Basic With"
|
||||
play done
|
||||
|
||||
playAccel "Lungs.mma"
|
||||
playAccel "Bolitas.mma", loop, clickStop, whatFits
|
||||
13
engines/director/lingo/tests/hms.lingo
Normal file
13
engines/director/lingo/tests/hms.lingo
Normal file
@@ -0,0 +1,13 @@
|
||||
scummvmAssertEqual framesToHMS(123456, 30, FALSE, FALSE), " 01:08:35.06 "
|
||||
scummvmAssertEqual framesToHMS(-123456, 30, FALSE, FALSE), "-01:08:35.06 "
|
||||
|
||||
scummvmAssertEqual framesToHMS(123456, 30, FALSE, TRUE), " 01:08:35.20 "
|
||||
|
||||
scummvmAssertEqual HMSToFrames(" 01:08:35.06 ", 30, FALSE, FALSE), 123456
|
||||
scummvmAssertEqual HMSToFrames("-01:08:35.06 ", 30, FALSE, FALSE), -123456
|
||||
scummvmAssertEqual HMSToFrames("01:08:35.06", 30, FALSE, FALSE), 123456
|
||||
scummvmAssertEqual HMSToFrames("08:35.06", 30, FALSE, FALSE), 15456
|
||||
scummvmAssertEqual HMSToFrames("35.06", 30, FALSE, FALSE), 1056
|
||||
scummvmAssertEqual HMSToFrames("35", 30, FALSE, FALSE), 1050
|
||||
|
||||
scummvmAssertEqual HMSToFrames(" 01:08:35.20 ", 30, FALSE, TRUE), 123456
|
||||
172
engines/director/lingo/tests/if.lingo
Normal file
172
engines/director/lingo/tests/if.lingo
Normal file
@@ -0,0 +1,172 @@
|
||||
--
|
||||
set x = 1
|
||||
if x = 5 then exit
|
||||
else put 10.0
|
||||
|
||||
if x = 6 then put 2
|
||||
|
||||
set y = 4
|
||||
|
||||
-- defined variables are falsy when checked with not
|
||||
-- i.e. not varundefined => true
|
||||
-- only a var with value 0 is seen as false when checked with not
|
||||
-- i.e. not 0 => true
|
||||
scummvmAssert(varundefined = 0)
|
||||
scummvmAssert(not varundefined = 1)
|
||||
|
||||
set a to 0
|
||||
scummvmAssert(not a = 1)
|
||||
set a to 0.0
|
||||
scummvmAssert(not a = 0)
|
||||
set a to "string"
|
||||
scummvmAssert(not a = 0)
|
||||
set parray to [#pt: 1, #ar: 0]
|
||||
scummvmAssert(not parray = 0)
|
||||
--
|
||||
|
||||
repeat with x = 1 to 6
|
||||
if x = 3 then put 30
|
||||
else if x = 4 then put 40
|
||||
else if x = 5 then put 50
|
||||
else put 10.0
|
||||
if x = 1 then
|
||||
put 1
|
||||
else if x = 2 then
|
||||
put 1232.12345678901234
|
||||
put 2.2
|
||||
else if x = 3 then
|
||||
put 3
|
||||
else if x = 4 then
|
||||
put 4
|
||||
else if x = 5 then
|
||||
put 5
|
||||
else if x = 6 then
|
||||
put 6
|
||||
end if
|
||||
if x = 4 then put 40
|
||||
else put 50
|
||||
end repeat
|
||||
|
||||
if the keyCode = 36 then -- return key goes to first menu
|
||||
go to frame 1
|
||||
else if the keyCode = 123 then -- left arrow goes to previous menu
|
||||
dontPassEvent
|
||||
go to marker(-1)
|
||||
else if the keyCode = 124 then -- right arrow goes to next menu
|
||||
dontPassEvent
|
||||
go to marker(1)
|
||||
else if the keyCode = 125 then -- down arrow goes to last (bottom) menu
|
||||
dontPassEvent
|
||||
go to frame "credits"
|
||||
else if the keyCode = 126 then -- up arrow goes to first (top) menu
|
||||
dontPassEvent
|
||||
go to frame 1
|
||||
end if
|
||||
|
||||
if abs(y) = x and abs(x) = y then
|
||||
put TRUE
|
||||
else
|
||||
put FALSE
|
||||
end if
|
||||
|
||||
if abs(y) = x and abs(x) = y then put 5
|
||||
if abs(y) = x and abs(x) = y then put 5
|
||||
else put 6
|
||||
|
||||
if the selection = the text of cast 1 then
|
||||
go to frame "sEnd"
|
||||
exit
|
||||
else if whichTry = 1 then go to frame "sTell"
|
||||
else if whichTry = 2 then go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
|
||||
if the selection = the text of cast 1 then
|
||||
go to frame "sEnd"
|
||||
exit
|
||||
else if whichTry = 1 then
|
||||
go to frame "sTell"
|
||||
else if whichTry = 2 then
|
||||
put 5
|
||||
go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
else put 6
|
||||
|
||||
if the selection = the text of cast 1 then go to frame "sEnd"
|
||||
else put 7
|
||||
|
||||
if the selection = the text of cast 1 then go to frame "sEnd"
|
||||
else if whichTry = 1 then
|
||||
go to frame "sTell"
|
||||
else if whichTry = 2 then
|
||||
put 5
|
||||
go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
else
|
||||
put 6
|
||||
put 7
|
||||
end if
|
||||
|
||||
if the selection = the text of cast 1 then go to frame "sEnd"
|
||||
else if whichTry = 1 then
|
||||
go to frame "sTell"
|
||||
else if whichTry = 2 then
|
||||
put 5
|
||||
go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
else put 7
|
||||
|
||||
if rollOver(2) then
|
||||
put "The cursor is INSIDE the square." into field "Cursor Status"
|
||||
else
|
||||
put "The cursor is OUTSIDE the square." into field "Cursor Status"
|
||||
end if
|
||||
|
||||
if the selection = the text of cast 1 then
|
||||
if whichTry = 3 then
|
||||
go to frame "sDo"
|
||||
end if
|
||||
else if whichTry = 1 then
|
||||
if whichTry = 3 then go to frame "sDo"
|
||||
else
|
||||
put 5
|
||||
end if
|
||||
else if whichTry = 2 then
|
||||
if whichTry = 3 then go to frame "sDo"
|
||||
else
|
||||
if the selection = the text of cast A21 then
|
||||
if whichTry = 3 then
|
||||
go to frame "Foo"
|
||||
end if
|
||||
else if abra = 5 then put 6
|
||||
else
|
||||
put 7
|
||||
if abra = 7 then put 5
|
||||
end if
|
||||
end if
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
else put 6
|
||||
|
||||
if the selection = the text of cast 1 then go to frame "sEnd"
|
||||
|
||||
when keyDown then if the key = RETURN then checkField
|
||||
when keyDown then if the key = QUOTE then checkField
|
||||
|
||||
if the mouseH > ((the right of sprite 15) - 20) then beep
|
||||
else if ((the mouseH > ((the left of sprite 15) + 30)) and Â
|
||||
(the mouseH < ((the left of sprite 15) + 73)) and Â
|
||||
(the mouseV > ((the top of sprite 15) + 20)) and Â
|
||||
(the mouseV < ((the top of sprite 15) + 40))) then StoreButtonHit
|
||||
else if ((the mouseH > ((the left of sprite 15) + 81)) and Â
|
||||
(the mouseH < ((the left of sprite 15) +124)) and Â
|
||||
(the mouseV > ((the top of sprite 15) + 20)) and Â
|
||||
(the mouseV < ((the top of sprite 15) + 40))) then LoadButtonHit
|
||||
else if ((the mouseH > ((the left of sprite 15) + 30)) and Â
|
||||
(the mouseH < ((the left of sprite 15) +124)) and Â
|
||||
(the mouseV > ((the top of sprite 15) + 55)) and Â
|
||||
(the mouseV < ((the top of sprite 15) + 83))) then AudioButtonHit
|
||||
end if
|
||||
|
||||
macro WindowHorzP X
|
||||
set X1 = constrainH( 14, X )
|
||||
if X1 = X then return( TRUE )
|
||||
else return( FALSE )
|
||||
17
engines/director/lingo/tests/ilk.lingo
Normal file
17
engines/director/lingo/tests/ilk.lingo
Normal file
@@ -0,0 +1,17 @@
|
||||
-- single arg variant, return type
|
||||
put ilk(10)
|
||||
put ilk(20.0)
|
||||
put ilk("Macromedia")
|
||||
put ilk(point(10, 20))
|
||||
put ilk(ilk(10))
|
||||
set x = point(10, 20)
|
||||
put ilk(x)
|
||||
|
||||
-- two arg variant, return if type matches
|
||||
put ilk(10, #integer)
|
||||
put ilk("Macromedia", #string)
|
||||
set x = list(1,2,3)
|
||||
put ilk(x, #list)
|
||||
put ilk(x, #linearlist)
|
||||
put ilk(x, #integer)
|
||||
|
||||
0
engines/director/lingo/tests/lingotests
Normal file
0
engines/director/lingo/tests/lingotests
Normal file
34
engines/director/lingo/tests/listoverride.lingo
Normal file
34
engines/director/lingo/tests/listoverride.lingo
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
on count l
|
||||
return "what is this"
|
||||
end
|
||||
|
||||
on add l, x
|
||||
return "this is the worst"
|
||||
end
|
||||
|
||||
set result = count([1, 2, 3])
|
||||
scummvmAssertEqual(result, 3)
|
||||
|
||||
set result = count([1: 2, 3: 4, 5: 6])
|
||||
scummvmAssertEqual(result, 3)
|
||||
|
||||
set result = count(rect(1, 2, 3, 4))
|
||||
scummvmAssertEqual(result, 4)
|
||||
|
||||
set result = count(point(1, 2))
|
||||
scummvmAssertEqual(result, 2)
|
||||
|
||||
set result = count("not an array")
|
||||
scummvmAssertEqual(result, "what is this")
|
||||
|
||||
set result = add("still not an array")
|
||||
scummvmAssertEqual(result, "this is the worst")
|
||||
|
||||
set result = add("even less of an array", 8)
|
||||
scummvmAssertEqual(result, "this is the worst")
|
||||
|
||||
set target = [1, 2, 3]
|
||||
add(target, 4)
|
||||
scummvmAssertEqual(count(target), 4)
|
||||
|
||||
371
engines/director/lingo/tests/lists.lingo
Normal file
371
engines/director/lingo/tests/lists.lingo
Normal file
@@ -0,0 +1,371 @@
|
||||
set x = []
|
||||
set y = [:]
|
||||
set machinery = [#gears:6, #balls:3, #ramps:8]
|
||||
set nested = [1, 2, [3, 4], 5]
|
||||
set gList = ["car":1, "boat": 20]
|
||||
|
||||
set a to [1, 2, 3]
|
||||
put a
|
||||
|
||||
set gList = [point(70, 190), point(217, 66), point(364, 185)]
|
||||
|
||||
set gBugList = [[energy: 10, mood: "Happy"], [energy: -10, mood: "Sad"], [energy: 60, mood: "Hungry"], [energy: 20, mood: "Sad"]]
|
||||
|
||||
set b to [4, 5, 6, 7]
|
||||
scummvmAssertEqual(string(a + b), "[5, 7, 9]")
|
||||
scummvmAssertEqual(string(a - b), "[-3, -3, -3]")
|
||||
scummvmAssertEqual(string(a * b), "[4, 10, 18]")
|
||||
scummvmAssertEqual(string(b / a), "[4, 2, 2]")
|
||||
scummvmAssertEqual(string(b mod a), "[0, 1, 0]")
|
||||
scummvmAssertEqual(string(-a), "[-1, -2, -3]")
|
||||
|
||||
set floats to [4.0, 5.0, 6.0, 7.0]
|
||||
set strings to ["4", "5", "6", "7"]
|
||||
|
||||
scummvmAssertEqual(a + floats, [5.0, 7.0, 9.0])
|
||||
scummvmAssertEqual(a + strings, [5.0, 7.0, 9.0])
|
||||
scummvmAssertEqual(string(a + 1), "[2, 3, 4]")
|
||||
scummvmAssertEqual(string(1 + b), "[5, 6, 7, 8]")
|
||||
|
||||
-- property Array tests
|
||||
set propArray to [501: "cast", 502: "value", 1.5: "script", a: "score", #b: "member", "color": "red"]
|
||||
set var to getPropAt(propArray, 1)
|
||||
scummvmAssertEqual(var, 501)
|
||||
set var to getAt(propArray, 1)
|
||||
scummvmAssertEqual(var, "cast")
|
||||
|
||||
set var to getProp(propArray, 1.5)
|
||||
scummvmAssertEqual(var, "script")
|
||||
set var to getProp(propArray, #a)
|
||||
scummvmAssertEqual(var, "score")
|
||||
set var to getProp(propArray, "a")
|
||||
scummvmAssertEqual(var, "score")
|
||||
set var to getProp(propArray, #color)
|
||||
scummvmAssertEqual(var, "red")
|
||||
set var to getProp(propArray, #b)
|
||||
scummvmAssertEqual(var, "member")
|
||||
|
||||
-- itemOf
|
||||
set string_array to "one,, three, four"
|
||||
set res to item 2 of string_array
|
||||
scummvmAssert(res="")
|
||||
set res to item 3 of string_array
|
||||
scummvmAssert(res=" three")
|
||||
set res to item 4 of string_array
|
||||
scummvmAssert(res=" four")
|
||||
|
||||
-- itemOf check for float
|
||||
set res to item 3.4 of string_array
|
||||
scummvmAssert(res=" three")
|
||||
|
||||
-- itemOf out of bounds checks
|
||||
set res to item 5 of string_array
|
||||
scummvmAssert(res="")
|
||||
|
||||
set res to item -1 of string_array
|
||||
scummvmAssert(res=string_array)
|
||||
|
||||
-- itemOf: test delimiter
|
||||
set save = the itemDelimiter
|
||||
set the itemDelimiter = ":"
|
||||
set delim_array to "one: two: three: four"
|
||||
set res to item 3 of delim_array
|
||||
scummvmAssert(res=" three")
|
||||
set the itemDelimiter = save
|
||||
|
||||
-- rects
|
||||
set rct to rect(0, 0, 100, 100)
|
||||
set gA to getAt(rct, 2)
|
||||
scummvmAssertEqual(gA, 0)
|
||||
set gA to getAt(rct, 3)
|
||||
scummvmAssertEqual(gA, 100)
|
||||
setAt rct, 2, 20
|
||||
scummvmAssertEqual(getAt(rct, 2), 20)
|
||||
|
||||
-- array conversions
|
||||
set a to point(11, 12)
|
||||
set b to rect(21, 22, 23, 24)
|
||||
set c to [31]
|
||||
set d to [41, 42]
|
||||
set e to [51, 52, 53]
|
||||
set f to [61, 62, 63, 64]
|
||||
set g to [71, 72, 73, 74, 75]
|
||||
set h to 5
|
||||
|
||||
scummvmAssertEqual(string(a + a), "point(22, 24)")
|
||||
scummvmAssertEqual(string(a + b), "[32, 34]")
|
||||
scummvmAssertEqual(string(a + c), "[42]")
|
||||
scummvmAssertEqual(string(a + d), "point(52, 54)")
|
||||
scummvmAssertEqual(string(a + e), "[62, 64]")
|
||||
scummvmAssertEqual(string(a + f), "[72, 74]")
|
||||
scummvmAssertEqual(string(a + g), "[82, 84]")
|
||||
scummvmAssertEqual(string(a + h), "point(16, 17)")
|
||||
|
||||
scummvmAssertEqual(string(b + a), "[32, 34]")
|
||||
scummvmAssertEqual(string(b + b), "rect(42, 44, 46, 48)")
|
||||
scummvmAssertEqual(string(b + c), "[52]")
|
||||
scummvmAssertEqual(string(b + d), "[62, 64]")
|
||||
scummvmAssertEqual(string(b + e), "[72, 74, 76]")
|
||||
scummvmAssertEqual(string(b + f), "rect(82, 84, 86, 88)")
|
||||
scummvmAssertEqual(string(b + g), "[92, 94, 96, 98]")
|
||||
scummvmAssertEqual(string(b + h), "rect(26, 27, 28, 29)")
|
||||
|
||||
scummvmAssertEqual(string(c + a), "[42]")
|
||||
scummvmAssertEqual(string(c + b), "[52]")
|
||||
scummvmAssertEqual(string(c + c), "[62]")
|
||||
scummvmAssertEqual(string(c + d), "[72]")
|
||||
scummvmAssertEqual(string(c + e), "[82]")
|
||||
scummvmAssertEqual(string(c + f), "[92]")
|
||||
scummvmAssertEqual(string(c + g), "[102]")
|
||||
scummvmAssertEqual(string(c + h), "[36]")
|
||||
|
||||
scummvmAssertEqual(string(d + a), "[52, 54]")
|
||||
scummvmAssertEqual(string(d + b), "[62, 64]")
|
||||
scummvmAssertEqual(string(d + c), "[72]")
|
||||
scummvmAssertEqual(string(d + d), "[82, 84]")
|
||||
scummvmAssertEqual(string(d + e), "[92, 94]")
|
||||
scummvmAssertEqual(string(d + f), "[102, 104]")
|
||||
scummvmAssertEqual(string(d + g), "[112, 114]")
|
||||
scummvmAssertEqual(string(d + h), "[46, 47]")
|
||||
|
||||
scummvmAssertEqual(string(e + a), "[62, 64]")
|
||||
scummvmAssertEqual(string(e + b), "[72, 74, 76]")
|
||||
scummvmAssertEqual(string(e + c), "[82]")
|
||||
scummvmAssertEqual(string(e + d), "[92, 94]")
|
||||
scummvmAssertEqual(string(e + e), "[102, 104, 106]")
|
||||
scummvmAssertEqual(string(e + f), "[112, 114, 116]")
|
||||
scummvmAssertEqual(string(e + g), "[122, 124, 126]")
|
||||
scummvmAssertEqual(string(e + h), "[56, 57, 58]")
|
||||
|
||||
scummvmAssertEqual(string(f + a), "[72, 74]")
|
||||
scummvmAssertEqual(string(f + b), "[82, 84, 86, 88]")
|
||||
scummvmAssertEqual(string(f + c), "[92]")
|
||||
scummvmAssertEqual(string(f + d), "[102, 104]")
|
||||
scummvmAssertEqual(string(f + e), "[112, 114, 116]")
|
||||
scummvmAssertEqual(string(f + f), "[122, 124, 126, 128]")
|
||||
scummvmAssertEqual(string(f + g), "[132, 134, 136, 138]")
|
||||
scummvmAssertEqual(string(f + h), "[66, 67, 68, 69]")
|
||||
|
||||
scummvmAssertEqual(string(g + a), "[82, 84]")
|
||||
scummvmAssertEqual(string(g + b), "[92, 94, 96, 98]")
|
||||
scummvmAssertEqual(string(g + c), "[102]")
|
||||
scummvmAssertEqual(string(g + d), "[112, 114]")
|
||||
scummvmAssertEqual(string(g + e), "[122, 124, 126]")
|
||||
scummvmAssertEqual(string(g + f), "[132, 134, 136, 138]")
|
||||
scummvmAssertEqual(string(g + g), "[142, 144, 146, 148, 150]")
|
||||
scummvmAssertEqual(string(g + h), "[76, 77, 78, 79, 80]")
|
||||
|
||||
scummvmAssertEqual(string(h + a), "point(16, 17)")
|
||||
scummvmAssertEqual(string(h + b), "rect(26, 27, 28, 29)")
|
||||
scummvmAssertEqual(string(h + c), "[36]")
|
||||
scummvmAssertEqual(string(h + d), "[46, 47]")
|
||||
scummvmAssertEqual(string(h + e), "[56, 57, 58]")
|
||||
scummvmAssertEqual(string(h + f), "[66, 67, 68, 69]")
|
||||
scummvmAssertEqual(string(h + g), "[76, 77, 78, 79, 80]")
|
||||
scummvmAssertEqual(string(h + h), "10")
|
||||
|
||||
-- proplist with missing keys
|
||||
set proplist_without_keys = ["key": "value", "keyless expr 1", "keyless expr 2"]
|
||||
set proplist_with_keys = ["key": "value", 2: "keyless expr 1", 3: "keyless expr 2"]
|
||||
scummvmAssert(proplist_without_keys = proplist_with_keys)
|
||||
|
||||
-- list with symbol or string as key
|
||||
set templst to [#mood: 1]
|
||||
set tempmood to the mood of templst
|
||||
scummvmAssert(tempmood = 1)
|
||||
put templst
|
||||
|
||||
-- assign and check
|
||||
set the mood of templst to 2
|
||||
set tempmood to the mood of templst
|
||||
scummvmAssert(tempmood = 2)
|
||||
put templst
|
||||
|
||||
|
||||
-- add
|
||||
set list1 = [1, 4, 2]
|
||||
add list1, 3
|
||||
scummVMAssert(getPos(list1, 3) = 4)
|
||||
set list1 = [1, 4, 2]
|
||||
sort list1
|
||||
add list1, 3
|
||||
scummVMAssert(getPos(list1, 3) = 3)
|
||||
|
||||
-- addAt
|
||||
|
||||
|
||||
-- addProp
|
||||
|
||||
|
||||
-- append
|
||||
|
||||
|
||||
-- count
|
||||
|
||||
|
||||
-- deleteAt (uses getAt as basis)
|
||||
set testList to [1, 2, 3, 4, 5]
|
||||
deleteAt testList, 3
|
||||
scummvmAssertEqual(testList, [1, 2, 4, 5])
|
||||
set testList to [#a: 1, #b: 2, #c: 3, #d: 4, #e: 5]
|
||||
deleteAt testList, 3
|
||||
scummvmAssertEqual(testList, [#a: 1, #b: 2, #d: 4, #e: 5])
|
||||
|
||||
|
||||
-- deleteOne (uses getOne as basis)
|
||||
set testList to [5, 4, 3, 1, 4]
|
||||
deleteOne testList, 4
|
||||
scummvmAssertEqual(testList, [5, 3, 1, 4])
|
||||
set testlist to [5, "4.0", 3, 1, 4]
|
||||
deleteOne testList, 4
|
||||
scummvmAssertEqual(testList, [5, 3, 1, 4])
|
||||
set testlist to [5, 4.0, 3, 1, 4]
|
||||
deleteOne testList, 4
|
||||
scummvmAssertEqual(testList, [5, 3, 1, 4])
|
||||
set testlist to [5, "urgh", 3, 1, "urgh"]
|
||||
deleteOne testList, "urgh"
|
||||
scummvmAssertEqual(testList, [5, 3, 1, "urgh"])
|
||||
set testlist to [5, "URGH", 3, 1, "urgh"]
|
||||
deleteOne testList, "urgh"
|
||||
scummvmAssertEqual(testList, [5, "URGH", 3, 1])
|
||||
|
||||
|
||||
-- deleteProp
|
||||
|
||||
|
||||
-- findPos
|
||||
set testList to [#a: 1, #b: 2, #bb: 3, #d: 4, #e: 5]
|
||||
scummvmAssertEqual(findPos(testList, #b), 2)
|
||||
scummvmAssertEqual(findPos(testList, #f), VOID)
|
||||
|
||||
set testList to []
|
||||
scummvmAssertEqual(findPos(testList, #3), 0)
|
||||
set testList to [1, 3, 0]
|
||||
scummvmAssertEqual(findPos(testList, 3), 3)
|
||||
scummvmAssertEqual(findPos(testList, 2), 2)
|
||||
scummvmAssertEqual(findPos(testList, 4), 0)
|
||||
scummvmAssertEqual(findPos(testList, -1), 0)
|
||||
scummvmAssertEqual(findPos(testList, 1), 1)
|
||||
sort testList
|
||||
scummvmAssertEqual(findPos(testList, 1), 2)
|
||||
scummvmAssertEqual(findPos(testList, 0), 1)
|
||||
scummvmAssertEqual(findPos(testList, 2), 0)
|
||||
scummvmAssertEqual(findPos(testList, 4), 0)
|
||||
|
||||
-- findPosNear
|
||||
set testList to [#b: 2, #a: 1, #bb: 3, #d: 4, #e: 5]
|
||||
scummvmAssertEqual(findPosNear(testList, #b), 1)
|
||||
-- if the property list isn't sorted and the value isn't there, return the size of the list + 1
|
||||
scummvmAssertEqual(findPosNear(testList, #missing), 6)
|
||||
scummvmAssertEqual(findPosNear(testList, #bbb), 6)
|
||||
sort testList
|
||||
scummvmAssertEqual(findPosNear(testList, #bbb), 4)
|
||||
|
||||
set testList to [1: 2, 4: 8, 16: 32]
|
||||
scummvmAssertEqual(findPosNear(testList, 4), 2)
|
||||
scummvmAssertEqual(findPosNear(testList, 10), 4)
|
||||
sort testList
|
||||
scummvmAssertEqual(findPosNear(testList, 10), 3)
|
||||
|
||||
-- the manual claims that findPosNear throws an error if you give it a regular list. the manual is wrong.
|
||||
set testList to [62, 5, 33]
|
||||
scummvmAssertEqual(findPosNear(testList, 5), 2)
|
||||
-- if the property list isn't sorted and the value isn't there, return the value
|
||||
scummvmAssertEqual(findPosNear(testList, 44), 44)
|
||||
sort testList
|
||||
scummvmAssertEqual(findPosNear(testList, 5), 1)
|
||||
scummvmAssertEqual(findPosNear(testList, 44), 3)
|
||||
|
||||
|
||||
-- getaProp
|
||||
set testList to [#a, #b, #c, #d, #e]
|
||||
scummvmAssertEqual(getaProp(testList, 4), #d)
|
||||
scummvmAssertError getaProp(testList, 7)
|
||||
set testList to [#a: 5, #b: 4, #c: 3, #d: 2, #e: 1]
|
||||
scummvmAssertEqual(getaProp(testList, #d), 2)
|
||||
scummvmAssert(voidp(getaProp(testList, #g)))
|
||||
|
||||
|
||||
-- getAt
|
||||
set testList to [5, 4, 3, 2, 1]
|
||||
scummvmAssertEqual(getAt(testList, 2), 4)
|
||||
scummvmAssertError getAt(testList, 7)
|
||||
set testList to [#a: 5, #b: 4, #c: 3, #d: 2, #e: 1]
|
||||
scummvmAssertEqual(getAt(testList, 2), 4)
|
||||
scummvmAssertError getAt(testList, 7)
|
||||
|
||||
|
||||
-- getLast
|
||||
set testList to [#a, #b, #c]
|
||||
scummvmAssertEqual(getLast(testList), #c)
|
||||
scummvmAssert(voidp(getLast([])))
|
||||
set testList to [#a: 3, #b: 2, #c: 1]
|
||||
scummvmAssertEqual(getLast(testList), 1)
|
||||
scummvmAssert(voidp(getLast([:])))
|
||||
|
||||
|
||||
-- getOne
|
||||
set testList to [#a, #b, #c, #d, #d, #e]
|
||||
scummvmAssertEqual(getOne(testList, #d), 4)
|
||||
scummvmAssertEqual(getOne(testList, #g), 0)
|
||||
|
||||
set testList to [5, 4, 3, 1, 4]
|
||||
scummvmAssertEqual(getOne(testList, 4), 2)
|
||||
set testlist to [5, "4.0", 3, 1, 4]
|
||||
scummvmAssertEqual(getOne(testList, 4), 2)
|
||||
set testlist to [5, 4.0, 3, 1, 4]
|
||||
scummvmAssertEqual(getOne(testList, 4), 2)
|
||||
set testlist to [5, "urgh", 3, 1, "urgh"]
|
||||
scummvmAssertEqual(getOne(testList, "urgh"), 2)
|
||||
set testlist to [5, "URGH", 3, 1, "urgh"]
|
||||
scummvmAssertEqual(getOne(testList, "urgh"), 5)
|
||||
|
||||
-- for finding ARRAY/PARRAY, check the pointer, not the contents
|
||||
set testList to [#a, #b, [1, 2, 3]]
|
||||
scummvmAssertEqual(getOne(testList, [1, 2, 3]), 0)
|
||||
set subItem to [1, 2, 3]
|
||||
set testList to [#a, #b, subItem]
|
||||
scummvmAssertEqual(getOne(testList, subItem), 3)
|
||||
|
||||
|
||||
-- getProp
|
||||
set testList to [#a, #b, #c, #d, #e]
|
||||
scummvmAssertEqual(getProp(testList, 3), #c)
|
||||
|
||||
|
||||
-- getPropAt
|
||||
|
||||
|
||||
-- ilk
|
||||
|
||||
|
||||
-- list
|
||||
|
||||
|
||||
-- listP
|
||||
|
||||
|
||||
-- max
|
||||
|
||||
|
||||
-- min
|
||||
|
||||
|
||||
-- setaProp
|
||||
|
||||
|
||||
-- setAt
|
||||
set lst to []
|
||||
setAt lst,1,5
|
||||
scummvmAssertEqual(lst, [5])
|
||||
set lst to []
|
||||
setAt lst,3,5
|
||||
scummvmAssertEqual(lst, [0,0,5])
|
||||
setAt lst,2,5
|
||||
scummvmAssertEqual(lst, [0,5,5])
|
||||
|
||||
|
||||
-- setProp
|
||||
|
||||
|
||||
-- sort
|
||||
65
engines/director/lingo/tests/loops.lingo
Normal file
65
engines/director/lingo/tests/loops.lingo
Normal file
@@ -0,0 +1,65 @@
|
||||
set x = 5
|
||||
if x <= 5 then set x = 6
|
||||
if (x = 5) then
|
||||
set x = 7 -- this is comment
|
||||
else
|
||||
set x = 8
|
||||
-- this is another comment
|
||||
end if
|
||||
put x
|
||||
-- this is more comment
|
||||
set y = 1
|
||||
repeat while (y < 5)
|
||||
set y = y + 1
|
||||
put y
|
||||
end repeat
|
||||
|
||||
repeat with z = 10 to 15
|
||||
put z
|
||||
end repeat
|
||||
repeat with y = 5 down to 1
|
||||
put y
|
||||
end repeat
|
||||
|
||||
repeat while y < 5
|
||||
set y = y + 1
|
||||
put y
|
||||
end repeat
|
||||
|
||||
|
||||
repeat while y < 5
|
||||
set y = y + 1
|
||||
if y = 3 then next repeat
|
||||
put y
|
||||
end repeat
|
||||
|
||||
-- tests for repeat with
|
||||
|
||||
on exitRepeatWith
|
||||
set aList = [1,2,3,4]
|
||||
repeat with a in aList
|
||||
if a = 3 then
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
return a
|
||||
end exitRepeatWith
|
||||
|
||||
on returnRepeatWith
|
||||
set aList = [1,2,3,4]
|
||||
repeat with a in aList
|
||||
if a = 3 then
|
||||
return a
|
||||
end if
|
||||
end repeat
|
||||
end returnRepeatWith
|
||||
|
||||
on directListRepeatWith
|
||||
repeat with a in [1,2,3,4]
|
||||
put a
|
||||
end repeat
|
||||
end directListRepeatWith
|
||||
|
||||
put exitRepeatWith()
|
||||
put returnRepeatWith()
|
||||
directListRepeatWith()
|
||||
44
engines/director/lingo/tests/macros.lingo
Normal file
44
engines/director/lingo/tests/macros.lingo
Normal file
@@ -0,0 +1,44 @@
|
||||
global x, y
|
||||
set y = 8
|
||||
shipx
|
||||
put x
|
||||
zipx
|
||||
put x
|
||||
put y
|
||||
|
||||
test
|
||||
test()
|
||||
put test
|
||||
put test()
|
||||
if test then test
|
||||
|
||||
--
|
||||
macro SHIPX
|
||||
global x, y
|
||||
set x = Random(5)
|
||||
if x = 1 then
|
||||
go "Zoom"
|
||||
exit
|
||||
end if
|
||||
if x >1 then
|
||||
set y = 10
|
||||
exit
|
||||
end if
|
||||
put 100
|
||||
|
||||
--
|
||||
macro ZIPX
|
||||
set x = Random(5)
|
||||
if x = 1 then
|
||||
go "ZIP"
|
||||
exit
|
||||
end if
|
||||
if x >1 then
|
||||
put x
|
||||
check x, 5
|
||||
exit
|
||||
end if
|
||||
|
||||
--
|
||||
macro test
|
||||
return "a"
|
||||
165
engines/director/lingo/tests/math.lingo
Normal file
165
engines/director/lingo/tests/math.lingo
Normal file
@@ -0,0 +1,165 @@
|
||||
if random(4) > 2 then put 1000
|
||||
set z = 5.5
|
||||
set z1 = 2
|
||||
set z2 = z / z1
|
||||
put z
|
||||
put z1
|
||||
put z2
|
||||
put integer(z2)
|
||||
put cos(z2)
|
||||
|
||||
set x = 2 + 3 * (4 / 2)
|
||||
put x
|
||||
|
||||
put power(2, 8)
|
||||
put power(2, 8, 0)
|
||||
put power(2)
|
||||
updatestage
|
||||
|
||||
-- Type conversion
|
||||
put (1024/4096)*100 -- 0
|
||||
put (1024/4096)*100.0 -- 0.0
|
||||
put ((1024*1.0)/4096)*100.0 -- 25.0
|
||||
|
||||
put the sqrt of 9
|
||||
scummvmAssertEqual(ilk(sqrt(EMPTY)), #float)
|
||||
scummvmAssertEqual(sqrt(EMPTY), 0.0)
|
||||
|
||||
scummvmAssertEqual(ilk(sqrt(4)), #integer)
|
||||
scummvmAssertEqual(string(sqrt(0)), "0")
|
||||
scummvmAssertEqual(string(sqrt(4)), "2")
|
||||
scummvmAssertEqual(string(sqrt(5)), "2")
|
||||
scummvmAssertEqual(string(sqrt(8)), "3")
|
||||
|
||||
scummvmAssertEqual(ilk(sqrt(4.0)), #float)
|
||||
scummvmAssertEqual(sqrt(0.0), 0.0)
|
||||
scummvmAssertEqual(sqrt(4.0), 2.0)
|
||||
scummvmAssertEqual(abs(sqrt(5.0) - 2.2361) < 0.0001, 1)
|
||||
scummvmAssertEqual(abs(sqrt(8.0) - 2.8284) < 0.0001, 1)
|
||||
|
||||
scummvmAssertEqual(ilk(sqrt("4.0")), #float)
|
||||
scummvmAssertEqual(sqrt("0.0"), 0.0)
|
||||
scummvmAssertEqual(sqrt("4.0"), 2.0)
|
||||
scummvmAssertEqual(abs(sqrt("5.0") - 2.2361) < 0.0001, 1)
|
||||
scummvmAssertEqual(abs(sqrt("8.0") - 2.8284) < 0.0001, 1)
|
||||
|
||||
scummvmAssertEqual(ilk(sqrt("4")), #float)
|
||||
scummvmAssertEqual(sqrt("0"), 0.0)
|
||||
scummvmAssertEqual(sqrt("4"), 2.0)
|
||||
scummvmAssertEqual(abs(sqrt("5") - 2.2361) < 0.0001, 1)
|
||||
scummvmAssertEqual(abs(sqrt("8") - 2.8284) < 0.0001, 1)
|
||||
|
||||
-- Testing rounding
|
||||
set save to the scummvmVersion
|
||||
set the scummvmVersion to 300
|
||||
scummvmAssertEqual(integer(2.5), 3)
|
||||
scummvmAssertEqual(integer(2.49), 2)
|
||||
scummvmAssertEqual(integer(2.1), 2)
|
||||
scummvmAssertEqual(integer(2.0), 2)
|
||||
scummvmAssertEqual(integer(1.9), 2)
|
||||
scummvmAssertEqual(integer(1.5), 2)
|
||||
scummvmAssertEqual(integer(1.49), 1)
|
||||
scummvmAssertEqual(integer(1.0), 1)
|
||||
scummvmAssertEqual(integer(0.0), 0)
|
||||
scummvmAssertEqual(integer(-0.49), 0)
|
||||
scummvmAssertEqual(integer(-0.5), 0)
|
||||
scummvmAssertEqual(integer(-1.0), 0)
|
||||
scummvmAssertEqual(integer(-1.49), 0)
|
||||
scummvmAssertEqual(integer(-1.5), -1)
|
||||
scummvmAssertEqual(integer(-1.9), -1)
|
||||
scummvmAssertEqual(integer(-2.0), -1)
|
||||
scummvmAssertEqual(integer(-2.1), -1)
|
||||
scummvmAssertEqual(integer(-2.49), -1)
|
||||
scummvmAssertEqual(integer(-2.5), -2)
|
||||
|
||||
set the scummvmVersion to save
|
||||
|
||||
-- Min/max - D4 has bugs related to handling VOID
|
||||
set the scummvmVersion to 400
|
||||
scummvmAssertEqual(min(VOID, 30), 30)
|
||||
scummvmAssertEqual(ilk(max(VOID, 30)), #void)
|
||||
scummvmAssertEqual(ilk(min(30, VOID)), #void)
|
||||
scummvmAssertEqual(max(30, VOID), 30)
|
||||
|
||||
scummvmAssertEqual(min(VOID, "test"), "test")
|
||||
scummvmAssertEqual(ilk(max(VOID, "test")), #void)
|
||||
scummvmAssertEqual(ilk(min("test", VOID)), #void)
|
||||
scummvmAssertEqual(max("test", VOID), "test")
|
||||
|
||||
scummvmAssertEqual(min(1, VOID, 3), 3)
|
||||
scummvmAssertEqual(max(1, VOID, 3), 3)
|
||||
scummvmAssertEqual(min(VOID, 3, "test"), 3)
|
||||
scummvmAssertEqual(ilk(max(VOID, 3, "test")), #void)
|
||||
scummvmAssertEqual(min(1, VOID, 3, "test"), 3)
|
||||
scummvmAssertEqual(max(1, VOID, 3, "test"), "test")
|
||||
|
||||
scummvmAssertEqual(min(VOID, "test", 3), 3)
|
||||
scummvmAssertEqual(ilk(max(VOID, "test", 3)), #void)
|
||||
scummvmAssertEqual(min(3, VOID, "test"), "test")
|
||||
scummvmAssertEqual(max(3, VOID, "test"), "test")
|
||||
scummvmAssertEqual(ilk(min(3, "test", VOID)), #void)
|
||||
scummvmAssertEqual(max(3, "test", VOID), "test")
|
||||
scummvmAssertEqual(ilk(min("test", 3, VOID)), #void)
|
||||
scummvmAssertEqual(max("test", 3, VOID), "test")
|
||||
scummvmAssertEqual(min("test", VOID, 3), 3)
|
||||
scummvmAssertEqual(max("test", VOID, 3), "test")
|
||||
scummvmAssertEqual(min("test", VOID, 3, "2.5"), "2.5")
|
||||
scummvmAssertEqual(max("test", VOID, 3, "2.5"), "test")
|
||||
scummvmAssertEqual(min(1, "test", VOID, 3, "2.5"), "2.5")
|
||||
scummvmAssertEqual(max(1, "test", VOID, 3, "2.5"), "test")
|
||||
scummvmAssertEqual(min(1, "test", 3, "2.5"), 1)
|
||||
scummvmAssertEqual(max(1, "test", 3, "2.5"), "test")
|
||||
|
||||
-- D5 fixes the VOID bug
|
||||
set the scummvmVersion to 500
|
||||
scummvmAssertEqual(ilk(min(VOID, 30)), #void)
|
||||
scummvmAssertEqual(max(VOID, 30), 30)
|
||||
scummvmAssertEqual(ilk(min(30, VOID)), #void)
|
||||
scummvmAssertEqual(max(30, VOID), 30)
|
||||
|
||||
scummvmAssertEqual(min(VOID, "test"), "test")
|
||||
scummvmAssertEqual(ilk(max(VOID, "test")), #void)
|
||||
scummvmAssertEqual(min("test", VOID), "test")
|
||||
scummvmAssertEqual(ilk(max("test", VOID)), #void)
|
||||
|
||||
scummvmAssertEqual(ilk(min(1, VOID, 3)), #void)
|
||||
scummvmAssertEqual(max(1, VOID, 3), 3)
|
||||
scummvmAssertEqual(min(VOID, 3, "test"), "test")
|
||||
scummvmAssertEqual(max(VOID, 3, "test"), "test")
|
||||
scummvmAssertEqual(min(1, VOID, 3, "test"), "test")
|
||||
scummvmAssertEqual(max(1, VOID, 3, "test"), "test")
|
||||
|
||||
scummvmAssertEqual(min(VOID, "test", 3), 3)
|
||||
scummvmAssertEqual(max(VOID, "test", 3), 3)
|
||||
scummvmAssertEqual(min(3, VOID, "test"), "test")
|
||||
scummvmAssertEqual(max(3, VOID, "test"), "test")
|
||||
scummvmAssertEqual(ilk(min(3, "test", VOID)), #void)
|
||||
scummvmAssertEqual(ilk(max(3, "test", VOID)), #void)
|
||||
scummvmAssertEqual(ilk(min("test", 3, VOID)), #void)
|
||||
scummvmAssertEqual(ilk(max("test", 3, VOID)), #void)
|
||||
scummvmAssertEqual(min("test", VOID, 3), 3)
|
||||
scummvmAssertEqual(max("test", VOID, 3), 3)
|
||||
scummvmAssertEqual(min("test", VOID, 3, "2.5"), "2.5")
|
||||
scummvmAssertEqual(max("test", VOID, 3, "2.5"), 3)
|
||||
scummvmAssertEqual(min(1, "test", VOID, 3, "2.5"), "2.5")
|
||||
scummvmAssertEqual(max(1, "test", VOID, 3, "2.5"), 3)
|
||||
scummvmAssertEqual(min(1, "test", 3, "2.5"), 1)
|
||||
scummvmAssertEqual(max(1, "test", 3, "2.5"), "test")
|
||||
|
||||
-- cases the same for both
|
||||
set the scummvmVersion to 400
|
||||
scummvmAssertEqual(min(29, "30.0"), 29)
|
||||
scummvmAssertEqual(max(29, "30.0"), "30.0")
|
||||
scummvmAssertEqual(min(30, "30.0"), 30)
|
||||
scummvmAssertEqual(max(30, "30.0"), "30.0")
|
||||
scummvmAssertEqual(min(31, "30.0"), "30.0")
|
||||
scummvmAssertEqual(max(31, "30.0"), 31)
|
||||
scummvmAssertEqual(min(30.0, "30.1"), 30.0)
|
||||
scummvmAssertEqual(max(30.0, "30.1"), "30.1")
|
||||
scummvmAssertEqual(min(30.2, "30.1"), "30.1")
|
||||
scummvmAssertEqual(max(30.2, "30.1"), 30.2)
|
||||
|
||||
scummvmAssertEqual(min(50000, "test"), 50000)
|
||||
scummvmAssertEqual(max(50000, "test"), "test")
|
||||
scummvmAssertEqual(min(5000.0, "test"), 5000.0)
|
||||
scummvmAssertEqual(max(5000.0, "test"), "test")
|
||||
17
engines/director/lingo/tests/mci.lingo
Normal file
17
engines/director/lingo/tests/mci.lingo
Normal file
@@ -0,0 +1,17 @@
|
||||
mci "open MM\T005045a.wav type WaveAudio alias T005045a"
|
||||
mci "play T005045a from 22710 to 32872"
|
||||
|
||||
sound playFile 1, "Jet Blast"
|
||||
sound fadeOut 1
|
||||
sound fadeOut 1, 20
|
||||
sound fadeIn 1
|
||||
sound fadeIn 1, 15
|
||||
sound stop 1
|
||||
|
||||
playAccel "globe.mma", repeat, 5, noFlush, clickStop
|
||||
playAccel "globe.mma", tempo, 100, repeat, 10, noFlush, clickStop
|
||||
playAccel "globe.mma", tempo, 10, repeat, 4, noFlush, clickStop
|
||||
|
||||
mci
|
||||
mci close all
|
||||
mci play wave to 15228 hold
|
||||
14
engines/director/lingo/tests/mixed-code.lingo
Normal file
14
engines/director/lingo/tests/mixed-code.lingo
Normal file
@@ -0,0 +1,14 @@
|
||||
put "ONE"
|
||||
|
||||
on two
|
||||
put "TWO"
|
||||
end two
|
||||
|
||||
put "THREE"
|
||||
|
||||
on four
|
||||
put "FOUR"
|
||||
end FOUR
|
||||
|
||||
four
|
||||
two
|
||||
25
engines/director/lingo/tests/mperform.lingo
Normal file
25
engines/director/lingo/tests/mperform.lingo
Normal file
@@ -0,0 +1,25 @@
|
||||
abc(mNew)
|
||||
abc(callPerform)
|
||||
|
||||
factory abc
|
||||
method mnew
|
||||
put "init"
|
||||
|
||||
method callMe
|
||||
put "Am i called?"
|
||||
return "a1"
|
||||
|
||||
method callMe2
|
||||
put "Am i called2?"
|
||||
|
||||
method callMe3
|
||||
put "Am I called3?"
|
||||
|
||||
method callPerform
|
||||
put "stepped into matFrame"
|
||||
set retval to me(mPerform, "callMe")
|
||||
me(mPerform, "callMe2")
|
||||
me(mPerform, "callMe3")
|
||||
put "returned" && retval
|
||||
|
||||
scummvmAssertEqual(retval, "a1")
|
||||
3
engines/director/lingo/tests/point.lingo
Normal file
3
engines/director/lingo/tests/point.lingo
Normal file
@@ -0,0 +1,3 @@
|
||||
put point(10, 20)
|
||||
set x = point(20,30)
|
||||
put x
|
||||
43
engines/director/lingo/tests/put.lingo
Normal file
43
engines/director/lingo/tests/put.lingo
Normal file
@@ -0,0 +1,43 @@
|
||||
put "qwertyuiop" into test
|
||||
put "a" before char 3 of test
|
||||
scummvmAssertEqual(test, "qwaertyuiop")
|
||||
|
||||
put "qwertyuiop" into test
|
||||
put "a" into char 3 of test
|
||||
scummvmAssertEqual(test, "qwartyuiop")
|
||||
|
||||
put "qwertyuiop" into test
|
||||
put "a" after char 3 of test
|
||||
scummvmAssertEqual(test, "qweartyuiop")
|
||||
|
||||
put "lorem ipsum dolor sit amet" into test
|
||||
put "asdf" before word 3 of test
|
||||
scummvmAssertEqual(test, "lorem ipsum asdfdolor sit amet")
|
||||
|
||||
put "lorem ipsum dolor sit amet" into test
|
||||
put "asdf" into word 3 of test
|
||||
scummvmAssertEqual(test, "lorem ipsum asdf sit amet")
|
||||
|
||||
put "lorem ipsum dolor sit amet" into test
|
||||
put "asdf" after word 3 of test
|
||||
scummvmAssertEqual(test, "lorem ipsum dolorasdf sit amet")
|
||||
|
||||
put "123456789" into test
|
||||
put "foo" into char 20 of test
|
||||
scummvmAssertEqual(test, "123456789 foo")
|
||||
|
||||
put "foo" into test
|
||||
put "bar" into word 10000 of test
|
||||
scummvmAssertEqual(test, "foobar")
|
||||
|
||||
put "foo" into test
|
||||
put "bar" into item 10 of test
|
||||
scummvmAssertEqual(test, "foo,,,,,,,,,bar")
|
||||
|
||||
put "foo" into test"
|
||||
put "bar" into line 10 of test
|
||||
scummvmAssertEqual(test, "foo" & RETURN & RETURN & RETURN & RETURN & RETURN & RETURN & RETURN & RETURN & RETURN & "bar")
|
||||
|
||||
put "foo" & RETURN & "lorem ipsum" into test
|
||||
put "bar" into char 3 of word 2 of line 2 of test
|
||||
scummvmAssertEqual(test, "foo" & RETURN & "lorem ipbarum")
|
||||
50
engines/director/lingo/tests/reference.lingo
Normal file
50
engines/director/lingo/tests/reference.lingo
Normal file
@@ -0,0 +1,50 @@
|
||||
-- basic references
|
||||
set a = cast 1
|
||||
set a = cast "castname"
|
||||
set a = field 1
|
||||
set a = field "castname"
|
||||
set a = script "scriptname"
|
||||
set a = window "windowname"
|
||||
|
||||
-- assign to field reference
|
||||
put "asdf" into field 1
|
||||
put "lorem ipsum" into cast 1
|
||||
|
||||
-- the property of reference
|
||||
put the text of cast 1
|
||||
put line 1 to 5 of field the number of cast "MasterList" into field the number of cast "InventoryList"
|
||||
|
||||
-- the loaded of cast
|
||||
|
||||
-- real casts
|
||||
scummvmAssert(the loaded of cast 1)
|
||||
set test to cast 1
|
||||
scummvmAssert(the loaded of test)
|
||||
|
||||
-- nonexistent casts
|
||||
scummvmAssert(not the loaded of cast 500)
|
||||
set test to cast 500
|
||||
scummvmAssert(not the loaded of test)
|
||||
|
||||
put the loaded of cast "fake"
|
||||
set test to cast "fake"
|
||||
|
||||
-- the following test should not be executed
|
||||
-- we are testing only compilation
|
||||
if scummvmCompileOnly = 1337 then
|
||||
|
||||
-- user-defined handlers/factories w/ reference name
|
||||
-- (mainly to test grammar, so no factory definition)
|
||||
set theWindow = Window(mNew,#noGrowDoc,"Window " & windowNumber)
|
||||
|
||||
-- other weird stuff with reference name
|
||||
-- FIXME: We need to find a way of clean execution of these
|
||||
put window("test")
|
||||
set window = 1
|
||||
put window
|
||||
window("test")
|
||||
window "test"
|
||||
window cast
|
||||
fi
|
||||
|
||||
put cast cast
|
||||
6
engines/director/lingo/tests/roman.lingo
Normal file
6
engines/director/lingo/tests/roman.lingo
Normal file
@@ -0,0 +1,6 @@
|
||||
set z = "foo bar baz"
|
||||
set z1 = z & " meow"
|
||||
set z1 = z1 && "woof"
|
||||
scummvmAssert(z1 contains "MeÍW")
|
||||
|
||||
scummvmAssert("meow" = "MeÍW")
|
||||
24
engines/director/lingo/tests/sort.lingo
Normal file
24
engines/director/lingo/tests/sort.lingo
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
-- Just ints, use numeric sort
|
||||
set test to [200, 100, 25, 4, 3, 2, 1]
|
||||
sort(test)
|
||||
scummvmAssertEqual(test, [1, 2, 3, 4, 25, 100, 200])
|
||||
|
||||
-- Just floats, use numeric sort
|
||||
set test to [200.5, 100.5, 25.5, 4.5, 3.5, 2.5, 1.5]
|
||||
sort(test)
|
||||
scummvmAssertEqual(test, [1.5, 2.5, 3.5, 4.5, 25.5, 100.5, 200.5])
|
||||
|
||||
-- ints and floats, use numeric sort
|
||||
set test to [200, 100, 25, 4, 3, 2, 1, 2.5]
|
||||
sort(test)
|
||||
scummvmAssertEqual(test, [1, 2, 2.5, 3, 4, 25, 100, 200])
|
||||
|
||||
-- Just strings, use string sort
|
||||
set test to ["200", "100", "25", "4", "3", "2", "1", "2.5", "oh no"]
|
||||
sort(test)
|
||||
scummvmAssertEqual(test, ["1", "100", "2", "2.5", "200", "25", "3", "4", "oh no"])
|
||||
|
||||
-- For combined types (e.g. ints and strings), the result is undefined.
|
||||
-- The real interpreter will give an answer that's nearly the same as the
|
||||
-- string sort order, or softlock.
|
||||
6
engines/director/lingo/tests/sound.lingo
Normal file
6
engines/director/lingo/tests/sound.lingo
Normal file
@@ -0,0 +1,6 @@
|
||||
Sound playfile 3, "Sound.AIF"
|
||||
|
||||
sound fadeIn 5
|
||||
sound fadeIn 5, 10
|
||||
sound stop 1
|
||||
sound close 1
|
||||
191
engines/director/lingo/tests/strings.lingo
Normal file
191
engines/director/lingo/tests/strings.lingo
Normal file
@@ -0,0 +1,191 @@
|
||||
set z = "foo bar baz"
|
||||
set z1 = z & " meow"
|
||||
set z1 = z1 && "woof"
|
||||
scummvmAssert(z1 contains "bar")
|
||||
|
||||
set c = chars("Macromedia", 6, 6)
|
||||
scummvmAssertEqual(c, "m")
|
||||
set c = chars("Macromedia", 6, 10)
|
||||
scummvmAssertEqual(c, "media")
|
||||
set c = chars("Macromedia", -1, 15)
|
||||
scummvmAssertEqual(c, "Macromedia")
|
||||
set save to the scummvmVersion
|
||||
set the scummvmVersion to 300
|
||||
set c = chars("Macromedia", 1, 1.1)
|
||||
scummvmAssertEqual(c, 0)
|
||||
set the scummvmVersion to save
|
||||
|
||||
put "That is the last line of the file." & return & "Click Done to exit." && return && "foo"
|
||||
|
||||
if the key = Return then
|
||||
dontPassEvent
|
||||
end if
|
||||
|
||||
when keydown then if the key=return then set the stagecolor to random (256)
|
||||
|
||||
put return
|
||||
|
||||
put "foo" into test
|
||||
put return after test
|
||||
put test
|
||||
scummvmAssertEqual(test, "foo" & return)
|
||||
|
||||
put return before test
|
||||
scummvmAssertEqual(test, return & "foo" & return)
|
||||
|
||||
put return into test
|
||||
scummvmAssertEqual(test, return)
|
||||
|
||||
-- coercing strings to numbers
|
||||
-- str(int) + int
|
||||
scummvmAssertEqual("2" + 5, 7.0)
|
||||
scummvmAssertEqual(5 + "2", 7.0)
|
||||
-- str(int) + float
|
||||
scummvmAssertEqual("2" + 5.5, 7.5)
|
||||
scummvmAssertEqual(5.5 + "2", 7.5)
|
||||
-- str(float) + int
|
||||
scummvmAssertEqual("2.5" + 5, 7.5)
|
||||
scummvmAssertEqual(5 + "2.5", 7.5)
|
||||
-- str(float) + float
|
||||
scummvmAssertEqual("2.25" + 5.5, 7.75)
|
||||
scummvmAssertEqual(5.5 + "2.25", 7.75)
|
||||
|
||||
-- str(int) + str(int)
|
||||
scummvmAssertEqual("2" + "5", 7.0)
|
||||
scummvmAssertEqual("5" + "2", 7.0)
|
||||
-- str(int) + str(float)
|
||||
scummvmAssertEqual("2" + "5.5", 7.5)
|
||||
scummvmAssertEqual("5.5" + "2", 7.5)
|
||||
-- str(float) + str(int)
|
||||
scummvmAssertEqual("2.5" + "5", 7.5)
|
||||
scummvmAssertEqual("5" + "2.5", 7.5)
|
||||
-- str(float) + str(float)
|
||||
scummvmAssertEqual("2.25" + "5.5", 7.75)
|
||||
scummvmAssertEqual("5.5" + "2.25", 7.75)
|
||||
|
||||
|
||||
|
||||
-- float syntax
|
||||
scummvmAssertEqual("-2" + 5, 3.0)
|
||||
scummvmAssertEqual("-2.5" + 5, 2.5)
|
||||
scummvmAssertEqual("+2" + 5, 7.0)
|
||||
scummvmAssertEqual("+2.5" + 5, 7.5)
|
||||
scummvmAssertEqual("2e3" + 5, 2005.0)
|
||||
scummvmAssertEqual("2.5e3" + 5, 2505.0)
|
||||
scummvmAssertEqual(" 2" + 5, 7.0)
|
||||
scummvmAssertEqual(" 2.5" + 5, 7.5)
|
||||
|
||||
-- non number strings should coerce to a pointer
|
||||
scummvmAssertEqual(ilk("incorrect" + 5), #integer)
|
||||
scummvmAssertEqual(ilk(" 2.5 " + 5), #integer)
|
||||
scummvmAssert(ilk("2 uhhh" + 5), #integer)
|
||||
scummvmAssert(ilk("2.5 uhhh" + 5), #integer)
|
||||
put "sausages" into testString
|
||||
put (testString + 0) into testPointer
|
||||
scummvmAssertEqual(ilk(testPointer), #integer)
|
||||
scummvmAssertEqual(testString + 4, testPointer + 4)
|
||||
scummvmAssertEqual(testString - 4, testPointer - 4)
|
||||
scummvmAssertEqual(testString * 4, testPointer * 4)
|
||||
scummvmAssertEqual(testString / 4, testPointer / 4)
|
||||
-- same horrible logic should apply to symbols
|
||||
put #haggis into testString
|
||||
put (testString + 0) into testPointer
|
||||
scummvmAssertEqual(ilk(testPointer), #integer)
|
||||
scummvmAssertEqual(testString + 4, testPointer + 4)
|
||||
scummvmAssertEqual(testString - 4, testPointer - 4)
|
||||
scummvmAssertEqual(testString * 4, testPointer * 4)
|
||||
scummvmAssertEqual(testString / 4, testPointer / 4)
|
||||
|
||||
-- casting to integer
|
||||
scummvmAssertEqual(integer("2"), 2)
|
||||
scummvmAssertEqual(integer("-2"), -2)
|
||||
scummvmAssertEqual(integer(" 2"), 2)
|
||||
scummvmAssertEqual(integer("2.5"), VOID)
|
||||
scummvmAssertEqual(integer(" 2.5"), VOID)
|
||||
scummvmAssertEqual(integer("incorrect"), VOID)
|
||||
scummvmAssertEqual(integer("2 extra"), 2)
|
||||
scummvmAssertEqual(integer("2.5 extra"), VOID)
|
||||
scummvmAssertEqual(integer(" 2 extra"), 2)
|
||||
scummvmAssertEqual(integer(" 2.5 extra"), VOID)
|
||||
scummvmAssertEqual(integer("2extra"), VOID)
|
||||
scummvmAssertEqual(integer(" 2extra"), VOID)
|
||||
|
||||
-- casting to float
|
||||
scummvmAssertEqual(float("2"), 2.0)
|
||||
scummvmAssertEqual(float("-2"), -2.0)
|
||||
scummvmAssertEqual(float(" 2"), 2.0)
|
||||
scummvmAssertEqual(float("2.5"), 2.5)
|
||||
scummvmAssertEqual(float(" 2.5"), 2.5)
|
||||
scummvmAssertEqual(float("incorrect"), "incorrect")
|
||||
scummvmAssertEqual(float("2 extra"), "2 extra")
|
||||
scummvmAssertEqual(float("2.5 extra"), "2.5 extra")
|
||||
scummvmAssertEqual(float(" 2 extra"), " 2 extra")
|
||||
scummvmAssertEqual(float(" 2.5 extra"), " 2.5 extra")
|
||||
scummvmAssertEqual(float("2extra"), "2extra")
|
||||
scummvmAssertEqual(float(" 2extra"), " 2extra")
|
||||
|
||||
|
||||
-- LC::charOF
|
||||
set string to "Macromedia"
|
||||
set res to char 6 of string
|
||||
scummvmAssertEqual(res, "m")
|
||||
|
||||
-- error and bounds checks
|
||||
set res to char 60 of string
|
||||
scummvmAssertEqual(res, EMPTY)
|
||||
set res to char 0 of string
|
||||
scummvmAssertEqual(res, string)
|
||||
-- Test D4, it does a floor
|
||||
set res to char 5.49 of string
|
||||
scummvmAssertEqual(res, "o")
|
||||
set res to char 5.5 of string
|
||||
scummvmAssertEqual(res, "o")
|
||||
-- Test D3, it does a round
|
||||
set save to the scummvmVersion
|
||||
set the scummvmVersion to 300
|
||||
set res to char 5.49 of string
|
||||
scummvmAssertEqual(res, "o")
|
||||
set res to char 5.5 of string
|
||||
scummvmAssertEqual(res, "m")
|
||||
set the scummvmVersion to save
|
||||
|
||||
-- LC::charToOf
|
||||
set string to "Macromedia"
|
||||
set res to char 6 to 9 of string
|
||||
scummvmAssertEqual(res, "medi")
|
||||
|
||||
-- error and bounds checks
|
||||
set res to char 5.4 to 7.9 of string
|
||||
scummvmAssertEqual(res, "ome")
|
||||
|
||||
set res to char 6 to 5 of string
|
||||
scummvmAssertEqual(res, "")
|
||||
|
||||
set res to char 6 to 60 of string
|
||||
scummvmAssertEqual(res, "media")
|
||||
|
||||
set res to char -1 to -2 of string
|
||||
scummvmAssertEqual(res, string)
|
||||
|
||||
set res to char 50 to 60 of string
|
||||
scummvmAssertEqual(res, "")
|
||||
|
||||
-- LB::b_lastcharof
|
||||
scummvmAssertEqual(the last char of "", "")
|
||||
scummvmAssertEqual(the last char of "hello", "o")
|
||||
|
||||
-- LB::b_lastitemof
|
||||
scummvmAssertEqual(the last item of "", "")
|
||||
scummvmAssertEqual(the last item of "onetwo", "onetwo")
|
||||
scummvmAssertEqual(the last item of "one,two", "two")
|
||||
set save to the itemDelimiter
|
||||
set the itemDelimiter to ":"
|
||||
scummvmAssertEqual(the last item of "one:two", "two")
|
||||
set the itemDelimiter to save
|
||||
scummvmAssertEqual(the last item of "onetwo", "onetwo")
|
||||
|
||||
-- LB::b_offset
|
||||
set pos to offset("mov", "mov")
|
||||
scummvmAssertEqual(pos, 1)
|
||||
set pos to offset("mov", "C:\GAMES\OPEN.MOV")
|
||||
scummvmAssertEqual(pos, 15)
|
||||
9
engines/director/lingo/tests/tell.lingo
Normal file
9
engines/director/lingo/tests/tell.lingo
Normal file
@@ -0,0 +1,9 @@
|
||||
tell window "ball" to puppettempo 5
|
||||
|
||||
tell window "hello" to continue
|
||||
|
||||
tell window childMovie
|
||||
go to frame 50
|
||||
set the stageColor to 100
|
||||
updateStage
|
||||
end tell
|
||||
95
engines/director/lingo/tests/the.lingo
Normal file
95
engines/director/lingo/tests/the.lingo
Normal file
@@ -0,0 +1,95 @@
|
||||
put 1.0 / 3
|
||||
set the floatPrecision to 6
|
||||
put 1.0 / 3
|
||||
put the loch of sprite 4
|
||||
set the loch of sprite 5 to 10
|
||||
set the castnum of sprite 8 to the number of cast "A Blank Castmember"
|
||||
|
||||
put the time
|
||||
put the abbrev time
|
||||
put the long time
|
||||
|
||||
put the date
|
||||
put the short date
|
||||
put the abbrev date
|
||||
put the long date
|
||||
|
||||
set a = 5
|
||||
|
||||
set gravityConst = the value of ( QUOTE & the text of cast 1 & QUOTE )
|
||||
set the hilite of cast 1 to (a = 3)
|
||||
set the text of cast 1 = string( gravityConst )
|
||||
|
||||
-- This is object setting. D4+
|
||||
set BlastWindow to window "Media Blast"
|
||||
set the filename of BlastWindow to "blastwin"
|
||||
set the titleVisible of BlastWindow to true
|
||||
set the modal of BlastWindow to true
|
||||
set the windowtype of BlastWindow to 5
|
||||
|
||||
set the bottom of sprite 1 to originV + (the number of lines in someText) * 16
|
||||
set the bottom of sprite 1 to originV + (the number of words in someText) * 16
|
||||
|
||||
put the number of words of field 1 into field 2
|
||||
|
||||
set pSprite to 1
|
||||
set pChangeH to 10
|
||||
|
||||
set h = the locH of sprite pSprite + pChangeH
|
||||
|
||||
set the volume of sound 1 to 255
|
||||
put the volume of sound 1 into field 1
|
||||
|
||||
set the checkMark of menuItem "Horizontal" of menu "The Ball" to False
|
||||
|
||||
put the number of castMembers into field 2
|
||||
|
||||
put the number of menuItems of menu "sam" into field 2
|
||||
|
||||
put abs( the locH of sprite 2 - the mouseH) into field 2
|
||||
|
||||
set the castNum of sprite the clickon = the number of cast 1
|
||||
|
||||
-- set castname = the name of cast(the castnum of sprite 1)
|
||||
|
||||
set res = the soundBusy of 1
|
||||
|
||||
put the sqrt of 9
|
||||
|
||||
put 5 into field the number of cast "MasterList"
|
||||
|
||||
set the text of field 1 = "Hello"
|
||||
|
||||
-- The next statement is valid lingo, however it's hard to parse.
|
||||
-- We have no indication that this one off type of code is used.
|
||||
-- set the text of field 0 + 1 = "Hello"
|
||||
|
||||
set h to "Hello"
|
||||
|
||||
set gMarkerName = the length of h + 2
|
||||
|
||||
scummvmAssertEqual(0, the length of 123)
|
||||
|
||||
-- test the itemDelimiter
|
||||
set save = the itemDelimiter
|
||||
scummvmAssert(save=",")
|
||||
set the itemDelimiter = ":"
|
||||
scummvmAssert(the itemDelimiter=":")
|
||||
set the itemDelimiter = ":,"
|
||||
scummvmAssert(the itemDelimiter=":")
|
||||
set the itemDelimiter = ""
|
||||
scummvmAssert(the itemDelimiter="")
|
||||
set the itemDelimiter = save
|
||||
|
||||
-- test number of items
|
||||
set chunkExpr to "one:two:three"
|
||||
scummvmAssertEqual(the number of items in chunkExpr, 1)
|
||||
set the itemDelimiter to ":"
|
||||
scummvmAssertEqual(the number of items in chunkExpr, 3)
|
||||
set the itemDelimiter to save
|
||||
|
||||
-- test initialisation
|
||||
scummvmAssertEqual(the beepOn, 0)
|
||||
scummvmAssertEqual(the keyDownScript, "")
|
||||
scummvmAssertEqual(the mouseDownScript, "")
|
||||
scummvmAssertEqual(the mouseUpScript, "")
|
||||
10
engines/director/lingo/tests/trailingcomma.lingo
Normal file
10
engines/director/lingo/tests/trailingcomma.lingo
Normal file
@@ -0,0 +1,10 @@
|
||||
on test a, b, c,
|
||||
put a
|
||||
end
|
||||
|
||||
global foo, bar,
|
||||
property baz,
|
||||
|
||||
test "foo", "bar", "baz",
|
||||
|
||||
put sqrt(4,)
|
||||
25
engines/director/lingo/tests/value.lingo
Normal file
25
engines/director/lingo/tests/value.lingo
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
-- int
|
||||
scummvmAssertEqual(55, value("55"))
|
||||
-- float
|
||||
scummvmAssertEqual(5.55, value("5.55"))
|
||||
-- array
|
||||
scummvmAssertEqual([1, 2, 3], value("[1, 2, 3]"))
|
||||
-- parray
|
||||
scummvmAssertEqual([#a: 1, #b: 2], value("[#a: 1, #b: 2]"))
|
||||
|
||||
-- expressions
|
||||
scummvmAssertEqual(9, value("3*3"))
|
||||
|
||||
-- the kicker; you are allowed to have garbage on the end!!!
|
||||
-- if it hits a token it doesn't understand, the parser should try again but stopping just before that token.
|
||||
scummvmNoFatalError(true)
|
||||
|
||||
scummvmAssertEqual(9, value("3*3[34]"))
|
||||
scummvmAssertEqual([1, 2, 3], value("[1, 2, 3],4]"))
|
||||
|
||||
scummvmNoFatalError(false)
|
||||
|
||||
-- if there's no valid expression at all, return void
|
||||
set test = value("#")
|
||||
scummvmAssert(voidP(test))
|
||||
7
engines/director/lingo/tests/varnames.lingo
Normal file
7
engines/director/lingo/tests/varnames.lingo
Normal file
@@ -0,0 +1,7 @@
|
||||
set a.1 = 2
|
||||
set a1 = 3
|
||||
set a1. = 4
|
||||
|
||||
scummvmAssert(a.1=2)
|
||||
scummvmAssert(a1=3)
|
||||
scummvmAssert(a1.=4)
|
||||
Reference in New Issue
Block a user