diff options
author | Eugene Sandulenko | 2016-07-10 13:05:30 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 1f0005c4e269ec8d9b848b85e40ab11d7d67a979 (patch) | |
tree | 934904e2099afcf9bc270c64eca03647598635dc /engines/director/lingo | |
parent | 6b4cff264588f73170da1b31121a9176efcadeba (diff) | |
download | scummvm-rg350-1f0005c4e269ec8d9b848b85e40ab11d7d67a979.tar.gz scummvm-rg350-1f0005c4e269ec8d9b848b85e40ab11d7d67a979.tar.bz2 scummvm-rg350-1f0005c4e269ec8d9b848b85e40ab11d7d67a979.zip |
DIRECTOR: Lingo: Initial code for Lingo test suite. Uses special game target
Diffstat (limited to 'engines/director/lingo')
-rw-r--r-- | engines/director/lingo/lingo.cpp | 20 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 2 | ||||
-rw-r--r-- | engines/director/lingo/tests/goto.lingo | 5 | ||||
-rw-r--r-- | engines/director/lingo/tests/if.lingo | 20 | ||||
-rw-r--r-- | engines/director/lingo/tests/lingotests.lingo | 0 | ||||
-rw-r--r-- | engines/director/lingo/tests/loops.lingo | 22 | ||||
-rw-r--r-- | engines/director/lingo/tests/macros.lingo | 55 | ||||
-rw-r--r-- | engines/director/lingo/tests/math.lingo | 12 | ||||
-rw-r--r-- | engines/director/lingo/tests/mci.lingo | 2 | ||||
-rw-r--r-- | engines/director/lingo/tests/strings.lingo | 13 |
10 files changed, 151 insertions, 0 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index c1116247b9..26fdfc2edb 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -296,4 +296,24 @@ Common::String *Lingo::toLowercaseMac(Common::String *s) { return res; } +void Lingo::runTests() { + Common::File inFile; + Common::ArchiveMemberList fileList; + SearchMan.listMatchingMembers(fileList, "*.lingo"); + + int counter = 1; + + for (Common::ArchiveMemberList::iterator it = fileList.begin(); it != fileList.end(); ++it) { + Common::ArchiveMember const &m = **it; + Common::SeekableReadStream *const stream = m.createReadStream(); + if (stream) { + uint size = stream->size(); + + warning("Executing file %s of size %d", m.getName().c_str(), size); + } + + inFile.close(); + } +} + } // End of namespace Director diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index d8cd64df0f..6aa7917ff4 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -144,6 +144,8 @@ public: Common::String *toLowercaseMac(Common::String *s); + void runTests(); + public: void execute(int pc); void pushContext(); diff --git a/engines/director/lingo/tests/goto.lingo b/engines/director/lingo/tests/goto.lingo new file mode 100644 index 0000000000..250ea24f8a --- /dev/null +++ b/engines/director/lingo/tests/goto.lingo @@ -0,0 +1,5 @@ +go to frame "Open23" of movie "OpenCabin23" +go "CARDBACK" +go movie "BAR 1" +go to "Open23" of movie "OpenCabin23" +go to "Chair" diff --git a/engines/director/lingo/tests/if.lingo b/engines/director/lingo/tests/if.lingo new file mode 100644 index 0000000000..c9bdacac52 --- /dev/null +++ b/engines/director/lingo/tests/if.lingo @@ -0,0 +1,20 @@ +-- +set x = 1 +if x = 5 then exit +else put 10.0 + +repeat with x = 1 to 5 + 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 + end if + if x = 4 then put 4 + else put 5 +end repeat diff --git a/engines/director/lingo/tests/lingotests.lingo b/engines/director/lingo/tests/lingotests.lingo new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/engines/director/lingo/tests/lingotests.lingo diff --git a/engines/director/lingo/tests/loops.lingo b/engines/director/lingo/tests/loops.lingo new file mode 100644 index 0000000000..0c7592a12a --- /dev/null +++ b/engines/director/lingo/tests/loops.lingo @@ -0,0 +1,22 @@ +set x = 5 +if x <= 5 then set x = 6 end if +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 diff --git a/engines/director/lingo/tests/macros.lingo b/engines/director/lingo/tests/macros.lingo new file mode 100644 index 0000000000..9167f1dffb --- /dev/null +++ b/engines/director/lingo/tests/macros.lingo @@ -0,0 +1,55 @@ +-- +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 +exit +end if + +-- +macro check par1, par2 +, par3 +if par1 = 3 then +put -3 +else +put 0 +end if +if par2 = 2 then +put 2 +else +put 0 +end if +put par1 +put par2 +put par3 +", kMovieScript, 1); + +_lingo->addCode("check(2, 3) +global x, y +set y = 8 +shipx +put x +zipx +put x +put y +check(1, 2, 3) +check 4, 5, 6 +check 7, 8 diff --git a/engines/director/lingo/tests/math.lingo b/engines/director/lingo/tests/math.lingo new file mode 100644 index 0000000000..d4b3d96105 --- /dev/null +++ b/engines/director/lingo/tests/math.lingo @@ -0,0 +1,12 @@ +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 diff --git a/engines/director/lingo/tests/mci.lingo b/engines/director/lingo/tests/mci.lingo new file mode 100644 index 0000000000..04130bf907 --- /dev/null +++ b/engines/director/lingo/tests/mci.lingo @@ -0,0 +1,2 @@ +mci "open MM\T005045a.wav type WaveAudio alias T005045a" +mci "play T005045a from 22710 to 32872" diff --git a/engines/director/lingo/tests/strings.lingo b/engines/director/lingo/tests/strings.lingo new file mode 100644 index 0000000000..568eb74640 --- /dev/null +++ b/engines/director/lingo/tests/strings.lingo @@ -0,0 +1,13 @@ +set z = "foo bar baz" +set z1 = z & " meow" +set z1 = z1 && "woof" +put z +put z1 +put chars("Macromedia", 6, 6) +put chars("Macromedia", 6, 10) +put chars("Macromedia", -1, 15) +if z1 contains "MeÍW" then + put "Contains" +else + put "Doesn't contain" +end if |