From 3ccf701ce99c86635e3070eec997fc2abee03bfd Mon Sep 17 00:00:00 2001 From: Kevin Eady <8634912+KevinEady@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:29:55 +0200 Subject: [PATCH] Format testsuite scripts, pol-core support modules (#713) * Format escript testsuite * Manual formatting for escript testsuite - Add format-off to places where formatter does what it should, but we don't like the results - Manually change places where formatter outputs weird things _without_ format-off, so next format-all would show changes if not fixed * Update .err files; add update_err.py helper script Use the format `:line:col: message` for all .err file checks. This allows us to change the file names without needing to edit the .err contents. Note that `in/inc0{1,2}.err` need have error messages between POSIX and Windows, so their messages are a bit more "generic" than the other errs. * Format pol testsuite * Manual formatting for pol testsuite * Format pol-core modules * Manual formatting for pol-core modules * Additional format pol-core modules Use FormatterLineWidth=10000 since module functions must be on one line because of the parse_modules target * Address Discord comments - Support multi-line module function declarations in parse_modules * Format on df07831 --- cmake/parse_modules.cmake | 2 + pol-core/support/scripts/attributes.em | 5 +- pol-core/support/scripts/basic.em | 83 +- pol-core/support/scripts/basicio.em | 31 +- pol-core/support/scripts/boat.em | 55 +- pol-core/support/scripts/cfgfile.em | 89 +- pol-core/support/scripts/cliloc.em | 16 +- pol-core/support/scripts/datafile.em | 13 +- pol-core/support/scripts/file.em | 10 +- pol-core/support/scripts/guilds.em | 2 +- pol-core/support/scripts/http.em | 8 +- pol-core/support/scripts/math.em | 34 +- pol-core/support/scripts/npc.em | 29 +- pol-core/support/scripts/os.em | 139 ++- pol-core/support/scripts/party.em | 2 +- pol-core/support/scripts/polsys.em | 26 +- pol-core/support/scripts/sql.em | 20 +- pol-core/support/scripts/storage.em | 2 +- pol-core/support/scripts/unicode.em | 26 +- pol-core/support/scripts/uo.em | 247 ++-- pol-core/support/scripts/util.em | 10 +- pol-core/support/scripts/vitals.em | 12 +- testsuite/escript/_dbg/dbg001.src | 16 +- testsuite/escript/_dbg/dbg002.src | 14 +- testsuite/escript/_dbg/dbg003.src | 24 +- testsuite/escript/_dbg/dbg004.src | 28 +- testsuite/escript/_dbg/dbg005.src | 10 +- testsuite/escript/_dbg/dbg006.src | 20 +- testsuite/escript/_dbg/dbg007.src | 14 +- testsuite/escript/_perf/perf.inc | 11 +- testsuite/escript/_perf/perf001.src | 6 +- testsuite/escript/_perf/perf001f.src | 6 +- testsuite/escript/_perf/perf002.src | 6 +- testsuite/escript/_perf/perf002f.src | 6 +- testsuite/escript/_perf/perf003.src | 6 +- testsuite/escript/_perf/perf003a.src | 6 +- testsuite/escript/_perf/perf003af.src | 6 +- testsuite/escript/_perf/perf003b.src | 4 +- testsuite/escript/_perf/perf003bf.src | 4 +- testsuite/escript/_perf/perf003f.src | 6 +- testsuite/escript/_perf/perf004.src | 4 +- testsuite/escript/_perf/perf004f.src | 4 +- testsuite/escript/_perf/perf005a.src | 4 +- testsuite/escript/_perf/perf005b.src | 20 +- testsuite/escript/_perf/perf005c.src | 14 +- testsuite/escript/_perf/perf006.src | 26 +- testsuite/escript/_perf/perf007.src | 26 +- testsuite/escript/_perf/perf008.src | 26 +- testsuite/escript/_perf/perfsetup.src | 2 +- .../arg/arg001-nonexistent-parameter.err | 2 +- .../arg/arg001-nonexistent-parameter.src | 2 +- .../escript/arg/arg002-too-many-arguments.err | 2 +- .../escript/arg/arg002-too-many-arguments.src | 4 +- testsuite/escript/array/array01.src | 1 - testsuite/escript/array/array02.src | 1 - testsuite/escript/array/array03.src | 28 +- testsuite/escript/array/array04.src | 6 +- testsuite/escript/array/array05.src | 10 +- testsuite/escript/array/array06.src | 10 +- testsuite/escript/array/array07.src | 12 +- testsuite/escript/array/array08.src | 10 +- testsuite/escript/array/array09.src | 6 +- testsuite/escript/array/array10.src | 6 +- testsuite/escript/array/array11.src | 6 +- testsuite/escript/array/array12.src | 14 +- testsuite/escript/array/array13.src | 10 +- testsuite/escript/array/array14.err | 2 +- testsuite/escript/array/array15.src | 6 +- testsuite/escript/array/array16.src | 8 +- testsuite/escript/array/array17.src | 6 +- testsuite/escript/array/array18.src | 24 +- testsuite/escript/array/array19.src | 80 +- testsuite/escript/array/array20.src | 46 +- testsuite/escript/array/filter-byref.src | 11 +- testsuite/escript/array/filter.src | 2 - testsuite/escript/array/find.src | 3 +- testsuite/escript/array/findIndex.src | 4 +- testsuite/escript/base64/base64001.src | 10 +- testsuite/escript/base64/base64002.src | 10 +- testsuite/escript/base64/base64003.src | 10 +- testsuite/escript/bfor/bfor001.src | 3 +- testsuite/escript/bfor/bfor002.src | 4 +- testsuite/escript/bfor/bfor003.src | 10 +- testsuite/escript/bfor/bfor004.src | 16 +- testsuite/escript/bfor/bfor005.src | 16 +- testsuite/escript/bfor/bfor006.src | 12 +- testsuite/escript/bitop/bitop002.src | 6 +- testsuite/escript/bitop/bitop003.src | 9 +- testsuite/escript/boolean/bool01.src | 42 +- testsuite/escript/boolean/bool02.src | 23 +- testsuite/escript/boolean/bool03.src | 50 +- testsuite/escript/boolean/bool04.src | 23 +- testsuite/escript/bracket/bracket.src | 66 +- testsuite/escript/bracket/bracket02.src | 11 +- testsuite/escript/bracket/bracket1.src | 29 +- testsuite/escript/bug/bug.err | 2 +- testsuite/escript/bug/bug001.src | 9 +- testsuite/escript/bug/bug002.src | 6 +- testsuite/escript/bug/bug003.src | 6 +- testsuite/escript/bug/bug004.err | 2 +- testsuite/escript/bug/bug005.src | 26 +- testsuite/escript/bug/bug006.err | 2 +- testsuite/escript/bug/bug007.err | 2 +- testsuite/escript/bug/bug008.err | 2 +- ...atement-optimization-offset-corruption.src | 10 +- ...ug011-module-function-param-name-clash.src | 11 +- .../bug012-function-as-named-parameter.src | 6 +- .../bug/bug013-local-variable-index.src | 19 +- testsuite/escript/bug/crash001.err | 2 +- testsuite/escript/bug/crash001.src | 2 +- testsuite/escript/cfg/appendcfgelem.src | 26 +- testsuite/escript/cfg/cfg.src | 23 +- .../compiler2/compiler2-001-hello-world.src | 3 +- .../compiler2-002-hello-world-program.src | 3 +- .../compiler2-003-print-global-var.src | 2 +- .../compiler2/compiler2-004-if-is-true.src | 5 +- .../compiler2/compiler2-005-if-is-false.src | 7 +- .../compiler2/compiler2-006-if-else-first.src | 7 +- .../compiler2-007-if-else-second.src | 7 +- .../compiler2-008-if-elseif-first.src | 9 +- .../compiler2-009-if-elseif-second.src | 9 +- .../compiler2-010-if-elseif-neither.src | 10 +- .../compiler2-011-if-elseif-else-first.src | 10 +- .../compiler2-012-if-elseif-else-second.src | 10 +- .../compiler2-013-if-elseif-else-third.src | 10 +- .../compiler2-014-print-local-var.src | 6 +- .../compiler2-015-local-vars-scoped.src | 12 +- .../compiler2-016-function-call-no-params.src | 2 +- ...er2-017-function-call-single-parameter.src | 6 +- ...ler2-018-function-call-multi-parameter.src | 8 +- ...019-function-call-single-default-param.src | 6 +- .../compiler2-020-function-return-value.src | 2 +- .../compiler2/compiler2-021-const-simple.src | 3 +- .../compiler2-022-integer-addition.src | 2 +- .../compiler2-023-const-optimized.src | 3 +- ...compiler2-024-const-of-const-optimized.src | 3 +- .../compiler2-025-if-is-true-optimized.src | 5 +- .../compiler2-026-if-is-false-optimized.src | 4 +- .../compiler2-027-if-else-first-optimized.src | 7 +- ...compiler2-028-if-else-second-optimized.src | 7 +- ...ompiler2-029-if-elseif-first-optimized.src | 9 +- ...mpiler2-030-if-elseif-second-optimized.src | 9 +- ...piler2-031-if-elseif-neither-optimized.src | 10 +- ...er2-032-if-elseif-else-first-optimized.src | 10 +- ...r2-033-if-elseif-else-second-optimized.src | 10 +- ...er2-034-if-elseif-else-third-optimized.src | 10 +- .../compiler2-035-while-is-false.src | 6 +- .../compiler2-036-assign-to-global-var.src | 4 +- .../compiler2-037-while-single-pass.src | 8 +- .../compiler2-038-while-loop-and-exit.src | 6 +- .../compiler2/compiler2-039-test-equality.src | 7 +- .../compiler2-040-early-exit-break.src | 14 +- .../compiler2-041-break-clean-up-locals.src | 6 +- .../compiler2-042-while-continue-simple.src | 12 +- .../compiler2-043-while-break-labeled.src | 17 +- ...mpiler2-044-integer-less-than-equal-to.src | 6 +- .../compiler2-045-integer-less-than.src | 6 +- ...ler2-046-integer-greater-than-equal-to.src | 6 +- .../compiler2-047-integer-greater-than.src | 6 +- .../compiler2-048-case-integer-simple.src | 10 +- ...r2-049-global-var-declaration-multiple.src | 4 +- .../compiler2-050-case-with-labeled-while.src | 23 +- ...ase-with-labeled-while-after-statement.src | 24 +- ...52-case-with-selector-attached-to-loop.src | 27 +- ...piler2-053-array-initialization-braces.src | 2 +- .../compiler2/compiler2-054-foreach-basic.src | 3 +- .../compiler2-055-do-while-basic.src | 8 +- .../compiler2-056-dictionary-empty.src | 2 +- ...mpiler2-057-dictionary-add-integer-key.src | 2 +- .../compiler2/compiler2-058-assign-float.src | 3 +- ...r2-059-dictionary-initializer-integers.src | 4 +- .../compiler2/compiler2-060-struct-empty.src | 2 +- ...ompiler2-061-struct-with-uninit-member.src | 4 +- .../compiler2-062-assign-to-struct-member.src | 4 +- ...er2-063-struct-with-initialized-member.src | 4 +- .../compiler2-064-get-struct-member.src | 4 +- .../compiler2-065-get-struct-known-member.src | 4 +- .../compiler2/compiler2-066-error-empty.src | 2 +- ...ler2-067-error-with-initialized-member.src | 4 +- .../compiler2-068-repeat-until-simple.src | 6 +- .../compiler2/compiler2-070-substring.src | 2 +- .../compiler2-071-exported-function.src | 8 +- .../compiler2/compiler2-072-negative-hex.src | 2 +- .../compiler2-073-integer-plusequals.src | 4 +- .../compiler2-074-negative-float.src | 2 +- .../compiler2/compiler2-075-modulus.src | 2 +- .../compiler2-076-struct-addmember.src | 2 +- ...er2-077-struct-addmember-by-expression.src | 4 +- .../compiler2-078-program-after-globals.src | 2 +- ...iler2-079-double-optimization-addition.src | 2 +- ...-080-string-optimization-concatenation.src | 2 +- .../compiler2-081-call-known-method.src | 2 +- .../compiler2-082-ambiguity-addition.src | 16 +- .../compiler2-083-declare-array-short.src | 2 +- .../compiler2-084-replace-substring.src | 4 +- .../compiler2-085-unicode-characters.src | 4 +- .../compiler2/compiler2-086-tilde-integer.src | 3 +- .../compiler2-087-pass-array-elem-byref.src | 12 +- ...compiler2-088-local-variable-shadowing.src | 16 +- ...timizer-removes-unreferenced-functions.src | 18 +- .../compiler2-090-basic-for-simple.src | 2 +- ...r2-091-optimize-increment-member-by-id.src | 4 +- .../compiler2-092-member-pre-decrement.src | 8 +- .../compiler2/compiler2-093-predecrement.src | 6 +- .../compiler2-094-funcref-assign-call.src | 4 +- .../compiler2-095-funcref-with-params.src | 10 +- ...ompiler2-097-modulefunc-register-order.src | 3 +- .../compiler2-098-embedded-quote.src | 6 +- .../compiler2-099-chained-method-call.src | 4 +- .../compiler2/compiler2-100-syntax-error.src | 13 +- ...piler2-101-case-group-with-empty-block.src | 8 +- ...iler2-103-navigation-by-string-literal.src | 3 +- .../escript/compiler2/compiler2-104-exit.src | 5 +- ...ompiler2-105-module-function-og-parity.src | 4 +- .../compiler2-106-exported-function.src | 5 +- .../compiler2-107-lower-case-method-names.src | 3 +- ...8-enum-after-constant-silently-ignored.src | 4 +- ...mpiler2-109-double-enum-second-ignored.src | 8 +- .../compiler2-110-return-assignment.src | 11 +- ...piler2-111-program-no-func-conversions.src | 5 +- ...compiler2-112-foreach-expression-scope.src | 3 +- ...mpiler2-113-basic-for-expression-scope.src | 2 +- .../compiler2-114-case-extra-jump.src | 32 +- testsuite/escript/condexpr/condexpr01.src | 32 +- testsuite/escript/condexpr/condexpr02.src | 10 +- testsuite/escript/condexpr/condexpr03.src | 2 +- testsuite/escript/condexpr/condexpr04.err | 2 +- testsuite/escript/const/const001-integer.src | 1 - .../const/const002-integer-optimized.src | 1 - ...const003-expression-of-const-optimized.src | 1 - ...nst004-cannot-shadow-const-with-global.err | 2 +- ...nst004-cannot-shadow-const-with-global.src | 1 - testsuite/escript/const/const005-string.src | 1 - testsuite/escript/const/const006-float.src | 1 - .../const/const007-call-module-func.src | 1 - .../const/const008-cannot-call-user-func.err | 2 +- .../const/const008-cannot-call-user-func.src | 7 +- .../escript/const/const009-string-alias.src | 1 - .../escript/const/const010-empty-array.src | 2 +- .../const/const011-populated-array.err | 2 +- .../const/const011-populated-array.src | 2 +- .../const/const012-empty-dictionary.src | 4 +- .../const/const013-populated-dictionary.err | 2 +- .../const/const013-populated-dictionary.src | 4 +- .../escript/const/const014-empty-error.src | 4 +- .../const/const015-populated-error.err | 2 +- .../const/const015-populated-error.src | 4 +- .../escript/const/const016-empty-struct.src | 4 +- .../const/const017-populated-struct.err | 2 +- .../const/const017-populated-struct.src | 4 +- testsuite/escript/dict/dict003.src | 2 +- testsuite/escript/dict/dict004.src | 6 +- testsuite/escript/dict/dict005.src | 13 +- testsuite/escript/dict/dict006.src | 11 +- testsuite/escript/dict/dict007.src | 11 +- testsuite/escript/dict/dict008.src | 17 +- testsuite/escript/dict/dict009.src | 4 +- testsuite/escript/dict/dict010.src | 4 +- testsuite/escript/dict/dict011.src | 14 +- testsuite/escript/dict/dict012.src | 4 +- testsuite/escript/dict/dict013.src | 4 +- testsuite/escript/dict/dict014.src | 4 +- testsuite/escript/dict/dict015.src | 24 +- testsuite/escript/enum/enum01.src | 6 +- testsuite/escript/enum/enum02.src | 6 +- testsuite/escript/enum/enum03.src | 8 +- testsuite/escript/enum/enum04.src | 8 +- testsuite/escript/enum/enum05.src | 8 +- testsuite/escript/enum/enum06.src | 14 +- testsuite/escript/error/error001.src | 2 +- .../errors001-two-functions-same-name.err | 2 +- .../errors001-two-functions-same-name.src | 10 +- .../errors002-var-same-name-as-function.err | 2 +- .../errors002-var-same-name-as-function.src | 6 +- ...nction-parameter-same-name-as-function.err | 2 +- ...nction-parameter-same-name-as-function.src | 6 +- ...rogram-parameter-same-name-as-function.err | 2 +- ...rogram-parameter-same-name-as-function.src | 2 +- ...rors004-reserved-word-as-argument-name.err | 2 +- .../errors005-const-same-name-as-function.err | 2 +- .../errors005-const-same-name-as-function.src | 2 +- .../errors/errors005-missing-open-paren.err | 2 +- ...or-loop-iterator-same-name-as-function.err | 2 +- ...or-loop-iterator-same-name-as-function.src | 2 +- ...foreach-iterator-same-name-as-function.err | 2 +- ...foreach-iterator-same-name-as-function.src | 2 +- ...rors008-var-same-name-as-user-function.err | 2 +- ...rors008-var-same-name-as-user-function.src | 6 +- .../errors/errors009-int-out-of-range.err | 2 +- .../errors/errors009-int-out-of-range.src | 2 +- .../errors010-reserved-word-syntax-error.err | 2 +- .../errors/errors011-const-no-init.err | 2 +- .../escript/export/export01-too-long.err | 2 +- .../escript/export/export01-too-long.src | 7 +- testsuite/escript/filemod/file.src | 10 +- testsuite/escript/filemod/xml.src | 83 +- testsuite/escript/for/for001.src | 6 +- testsuite/escript/for/for001b.src | 6 +- testsuite/escript/for/for002.src | 14 +- testsuite/escript/for/for002b.src | 18 +- testsuite/escript/for/for003.src | 14 +- testsuite/escript/for/for003b.src | 18 +- testsuite/escript/for/for004.src | 19 +- testsuite/escript/for/for004b.src | 19 +- testsuite/escript/for/for005.src | 6 +- testsuite/escript/for/for006.src | 8 +- testsuite/escript/for/for007.src | 8 +- testsuite/escript/for/for008.src | 16 +- testsuite/escript/for/for009.src | 14 +- testsuite/escript/for/for010.src | 14 +- testsuite/escript/for/for011.src | 16 +- testsuite/escript/for/for012.src | 8 +- testsuite/escript/for/for019.src | 6 +- testsuite/escript/for/foreach01.src | 6 +- testsuite/escript/for/foreach02.src | 12 +- testsuite/escript/for/foreach03.src | 24 +- testsuite/escript/for/foreach04.src | 12 +- testsuite/escript/for/foreach05.src | 14 +- testsuite/escript/for/foreach06.src | 30 +- testsuite/escript/for/foreach07.src | 19 +- testsuite/escript/for/foreach08.src | 19 +- testsuite/escript/for/foreach09.src | 21 +- testsuite/escript/for/foreach10.src | 18 +- testsuite/escript/for/foreach11.src | 20 +- .../escript/for/foreach12-bare-array.src | 2 +- .../escript/for/foreach13-explicit-array.src | 4 +- .../for/foreach14-over-user-function.src | 8 +- ...oreach15-over-user-function-extra-semi.src | 8 +- .../for/foreach16-over-module-function.src | 4 +- ...each17-over-module-function-extra-semi.src | 4 +- .../foreach18-over-scoped-module-function.src | 4 +- ...h19-over-method-call-result-disallowed.err | 2 +- ...h20-over-function-reference-disallowed.err | 2 +- ...oreach21-over-parenthesized-expression.src | 6 +- testsuite/escript/func/func0.src | 5 +- testsuite/escript/func/func001-oneline.src | 2 +- testsuite/escript/func/func002-multiline.src | 4 +- ...c010-non-optimizable-default-parameter.err | 2 +- ...c010-non-optimizable-default-parameter.src | 10 +- ...1-default-parameter-bare-function-call.err | 2 +- ...1-default-parameter-bare-function-call.src | 4 +- .../escript/func/func012-byref-unused.src | 6 +- .../escript/func/func013-double-semicolon.src | 5 +- .../func/func014-module-function-conflict.err | 2 +- .../func/func014-module-function-conflict.src | 3 +- .../func/func015-module-function-conflict.err | 2 +- .../func/func015-module-function-conflict.src | 3 +- testsuite/escript/func/func04.src | 2 +- testsuite/escript/func/func05.src | 2 +- testsuite/escript/func/func06.err | 2 +- testsuite/escript/func/func06.src | 4 +- testsuite/escript/func/func07.src | 13 +- testsuite/escript/func/func08.src | 20 +- testsuite/escript/func/func09.err | 2 +- testsuite/escript/func/func0a.src | 8 +- testsuite/escript/func/func0ab.src | 8 +- testsuite/escript/func/func0b.src | 5 +- testsuite/escript/func/func1.src | 54 +- testsuite/escript/func/func1b.src | 54 +- testsuite/escript/func/func2.err | 2 +- testsuite/escript/func/func2b.err | 2 +- testsuite/escript/func/funceof.err | 2 +- testsuite/escript/func/funcref01.src | 36 +- testsuite/escript/func/funcref02.src | 40 +- testsuite/escript/func/funcref04.err | 2 +- testsuite/escript/func/funcref05.err | 2 +- testsuite/escript/func/funcref08.src | 2 +- testsuite/escript/func/funcref09.src | 12 +- testsuite/escript/func/var-args-captures.src | 8 +- .../escript/func/var-args-continuation.src | 25 +- .../func/var-args-err-default-value.err | 2 +- .../escript/func/var-args-err-last-param.err | 2 +- testsuite/escript/funcexpr/assignment.src | 44 +- .../funcexpr/complex-nested-struct.src | 124 +- testsuite/escript/funcexpr/curry.inc | 6 +- testsuite/escript/funcexpr/curry.src | 1 + .../escript/funcexpr/listfile-complex-1.src | 43 +- .../escript/funcexpr/listfile-complex-2.src | 44 +- testsuite/escript/funcexpr/listfile-curry.src | 6 +- .../escript/funcexpr/listfile-nested-1.src | 20 +- .../escript/funcexpr/listfile-nested-2.src | 26 +- .../escript/funcexpr/listfile-nested-3.src | 18 +- .../escript/funcexpr/listfile-nested-4.src | 18 +- .../escript/funcexpr/listfile-simple.src | 12 +- .../escript/funcexpr/listfile-syntax.src | 9 +- testsuite/escript/funcexpr/listfile.inc | 28 +- testsuite/escript/funcexpr/nested-calls.src | 12 +- testsuite/escript/funcexpr/syntax.src | 8 +- testsuite/escript/if/if.src | 4 +- testsuite/escript/if/if01.src | 7 +- testsuite/escript/if/ifthen.src | 44 +- testsuite/escript/in/in001.src | 6 +- testsuite/escript/in/in002.src | 12 +- testsuite/escript/in/in003.src | 12 +- testsuite/escript/in/in004.src | 12 +- testsuite/escript/in/inc01.err | 2 +- testsuite/escript/in/inc01.src | 1 - testsuite/escript/in/inc02.err | 2 +- testsuite/escript/in/inc02.src | 1 - testsuite/escript/in/inctst01.inc | 12 +- .../escript/interstring/interstring01.src | 68 +- .../escript/interstring/interstring02.err | 2 +- .../escript/interstring/interstring03.err | 2 +- .../escript/interstring/interstring04.err | 2 +- .../escript/interstring/interstring05.err | 2 +- .../escript/interstring/interstring06.src | 6 +- .../escript/interstring/interstring07.err | 2 +- .../escript/interstring/interstring08.err | 2 +- .../escript/interstring/interstring09.err | 2 +- testsuite/escript/json/json01.src | 38 +- testsuite/escript/math/math0001.src | 1 - testsuite/escript/math/math0002.src | 1 - testsuite/escript/math/math0003.src | 3 +- testsuite/escript/math/math0004.src | 4 +- testsuite/escript/math/math0005.src | 2 +- testsuite/escript/math/relops.inc | 36 +- testsuite/escript/method/meth001.src | 8 +- testsuite/escript/method/method01.src | 2 +- testsuite/escript/method/setmember.src | 118 +- testsuite/escript/misc/assign.src | 18 +- testsuite/escript/misc/block001.src | 28 +- testsuite/escript/misc/casesensitivity.err | 2 +- testsuite/escript/misc/casesensitivity.inc | 1 - testsuite/escript/misc/cint001.src | 4 +- testsuite/escript/misc/comp001.err | 2 +- testsuite/escript/misc/comp002.src | 6 +- testsuite/escript/misc/convert.src | 17 +- testsuite/escript/misc/cvt001.src | 4 +- testsuite/escript/misc/do0.src | 8 +- testsuite/escript/misc/double01.src | 6 +- testsuite/escript/misc/double02.src | 22 +- testsuite/escript/misc/dt.src | 2 +- testsuite/escript/misc/dt1.inc | 13 +- testsuite/escript/misc/dt2.inc | 14 +- testsuite/escript/misc/dta.src | 2 +- testsuite/escript/misc/error01.src | 6 +- testsuite/escript/misc/export01.src | 10 +- testsuite/escript/misc/fcall001.err | 2 +- testsuite/escript/misc/fcall001.src | 2 +- testsuite/escript/misc/float001.src | 22 +- testsuite/escript/misc/glob001.src | 4 +- testsuite/escript/misc/globloc.src | 10 +- testsuite/escript/misc/hello.src | 2 +- testsuite/escript/misc/hello2.src | 2 +- testsuite/escript/misc/long001.src | 18 +- testsuite/escript/misc/lst001.src | 4 +- testsuite/escript/misc/lst002.src | 6 +- testsuite/escript/misc/lst003.src | 17 +- testsuite/escript/misc/not.src | 9 +- testsuite/escript/misc/numbers.src | 46 +- testsuite/escript/misc/rpterr.err | 2 +- testsuite/escript/misc/rpterr.src | 3 +- testsuite/escript/misc/ts.src | 17 +- testsuite/escript/narray/narray1.src | 1 - testsuite/escript/narray/narray10.src | 34 +- testsuite/escript/narray/narray11.src | 74 +- testsuite/escript/narray/narray12.src | 42 +- testsuite/escript/narray/narray13.src | 10 +- testsuite/escript/narray/narray14.src | 10 +- testsuite/escript/narray/narray15.src | 14 +- testsuite/escript/narray/narray16.src | 10 +- testsuite/escript/narray/narray17.src | 24 +- testsuite/escript/narray/narray18.src | 18 +- testsuite/escript/narray/narray2.src | 1 - testsuite/escript/narray/narray3.src | 28 +- testsuite/escript/narray/narray4.src | 6 +- testsuite/escript/narray/narray5.src | 10 +- testsuite/escript/narray/narray6.src | 10 +- testsuite/escript/narray/narray7.src | 12 +- testsuite/escript/narray/narray8.src | 10 +- testsuite/escript/narray/narray9.src | 6 +- .../oper-elvis/elvis005-chained-first.src | 1 + .../oper-elvis/elvis006-chained-middle.src | 1 + .../oper-elvis/elvis007-chained-last.src | 1 + .../elvis011-precedence-vs-equality.src | 1 + .../elvis013-precedence-struct-member.src | 8 +- testsuite/escript/oper-elvis/support.inc | 18 +- testsuite/escript/oper/minusminus01.src | 68 +- testsuite/escript/oper/minusminus03.src | 63 +- testsuite/escript/oper/minusminus05.src | 19 +- testsuite/escript/oper/op001.src | 12 +- testsuite/escript/oper/oper001.src | 76 +- testsuite/escript/oper/oper002.src | 25 +- testsuite/escript/oper/oper003.src | 6 +- testsuite/escript/oper/oper004.src | 8 +- testsuite/escript/oper/oper005.src | 2 +- testsuite/escript/oper/oper006.src | 4 +- testsuite/escript/oper/oper007.src | 122 +- testsuite/escript/oper/oper008.src | 5 +- testsuite/escript/oper/plusequal.src | 14 +- testsuite/escript/oper/plusplus01.src | 76 +- testsuite/escript/oper/plusplus02.src | 48 +- testsuite/escript/oper/plusplus03.src | 71 +- testsuite/escript/oper/plusplus04.src | 20 +- testsuite/escript/oper/plusplus05.src | 19 +- testsuite/escript/oper/singleequal01.err | 2 +- testsuite/escript/oper/singleequal02.err | 2 +- testsuite/escript/opt/opt001.src | 2 +- testsuite/escript/opt/opt002.src | 10 +- testsuite/escript/opt/opt003.src | 8 +- testsuite/escript/opt/opt004.src | 12 +- .../opt/opt005-stopped-optimizing-early.src | 6 +- testsuite/escript/opt/opt006.src | 28 +- testsuite/escript/pack/pack01.src | 4 +- ...ack011-double-with-exponent-then-error.src | 2 +- .../pack012-double-no-exponent-then-error.src | 6 +- testsuite/escript/pack/pack013-double.src | 1 - testsuite/escript/pack/pack04a.src | 2 +- testsuite/escript/pack/pack07.src | 2 +- testsuite/escript/pack/pack08.src | 6 +- testsuite/escript/pack/pack09.src | 9 +- testsuite/escript/pack/packtst.inc | 52 +- .../parity/parity001-identifier-module.src | 3 +- testsuite/escript/prec/prec01.src | 8 +- testsuite/escript/prec/prec02.src | 2 +- testsuite/escript/prec/prec03.src | 8 +- testsuite/escript/prog/prog01.src | 4 +- testsuite/escript/prog/prog02.src | 8 +- testsuite/escript/prog/prog03.src | 12 +- testsuite/escript/prog/prog04.src | 14 +- testsuite/escript/prog/prog05.src | 10 +- .../escript/prog/prog06-vars-are-local.src | 9 +- testsuite/escript/prog/surrounded.src | 2 +- testsuite/escript/quot/quot001.src | 2 +- testsuite/escript/recurs/recurs01.src | 14 +- testsuite/escript/recurs/recurs02.src | 16 +- testsuite/escript/reff/ref001.err | 2 +- testsuite/escript/reff/ref001a.src | 2 +- testsuite/escript/reff/ref002.err | 2 +- testsuite/escript/reff/reff001.src | 8 +- testsuite/escript/reff/reff002.src | 10 +- testsuite/escript/reff/reff003.src | 8 +- testsuite/escript/repeat/repeat01.src | 5 +- testsuite/escript/repeat/repeat02.src | 7 +- testsuite/escript/repeat/repeat03.src | 7 +- testsuite/escript/repeat/repeat04.src | 9 +- testsuite/escript/repeat/repeat05.src | 9 +- testsuite/escript/repeat/repeat06.src | 9 +- testsuite/escript/repeat/repeat07.src | 11 +- testsuite/escript/repeat/repeat08.src | 11 +- testsuite/escript/repeat/repeat09.src | 11 +- testsuite/escript/repeat/repeat10.src | 13 +- .../escript/reserved/non_reserved_words.src | 5 +- testsuite/escript/scope/scope01.src | 10 +- testsuite/escript/scope/scope02.err | 2 +- testsuite/escript/scope/scope02.src | 8 +- testsuite/escript/scope/scope03.src | 8 +- testsuite/escript/scope/scope04.src | 21 +- testsuite/escript/scope/scope05.err | 2 +- testsuite/escript/scope/scope05.src | 14 +- ...06-program-arg-same-level-var-conflict.err | 2 +- ...06-program-arg-same-level-var-conflict.src | 4 +- .../scope07-program-arg-scoped-var-ok.src | 12 +- ...8-function-arg-same-level-var-conflict.err | 2 +- ...8-function-arg-same-level-var-conflict.src | 6 +- .../scope09-function-arg-scoped-var-ok.src | 12 +- testsuite/escript/size/size001.src | 6 +- testsuite/escript/spread/doc-sample-1.src | 6 +- testsuite/escript/spread/doc-sample-2.src | 2 +- testsuite/escript/spread/doc-sample-3.src | 6 +- testsuite/escript/spread/doc-sample-4.src | 8 +- testsuite/escript/spread/equivalence.src | 108 +- testsuite/escript/spread/into-array.src | 10 +- testsuite/escript/spread/module-stubs.inc | 36 +- testsuite/escript/spread/print-spreads.src | 73 +- .../spread/resource-tracker-functional.src | 64 +- .../spread/resource-tracker-procedural.src | 30 +- testsuite/escript/spread/syntax-err-1.err | 2 +- testsuite/escript/spread/syntax-err-1.src | 5 +- testsuite/escript/spread/syntax-err-2.err | 2 +- testsuite/escript/spread/syntax-err-2.src | 2 +- testsuite/escript/spread/syntax-err-3.err | 2 +- testsuite/escript/spread/syntax-err-3.src | 5 +- testsuite/escript/spread/syntax-err-4.err | 2 +- testsuite/escript/spread/syntax-err-5.err | 2 +- testsuite/escript/spread/syntax.src | 21 +- testsuite/escript/string/string01.src | 5 +- testsuite/escript/string/string02.src | 12 +- testsuite/escript/string/string03.src | 12 +- testsuite/escript/string/string04.src | 12 +- testsuite/escript/string/string05.src | 12 +- testsuite/escript/string/string06.src | 24 +- testsuite/escript/string/string07.src | 8 +- testsuite/escript/string/string08.src | 8 +- testsuite/escript/string/string09.src | 12 +- testsuite/escript/string/string10.src | 4 +- testsuite/escript/string/string11.src | 19 +- testsuite/escript/string/string12.src | 11 +- testsuite/escript/string/string13.src | 3 +- testsuite/escript/string/string14.src | 7 +- testsuite/escript/string/string15.src | 6 +- testsuite/escript/string/string16.src | 12 +- testsuite/escript/string/string17.src | 12 +- testsuite/escript/string/string18.src | 63 +- testsuite/escript/string/string19.src | 2 +- testsuite/escript/string/string20.src | 331 +++--- testsuite/escript/string/string21.src | 2 +- testsuite/escript/string/string22.src | 2 +- testsuite/escript/string/string23.src | 4 +- testsuite/escript/struct/struct.src | 16 +- testsuite/escript/struct/struct002.src | 14 +- testsuite/escript/struct/struct003.src | 2 +- testsuite/escript/struct/struct004.src | 4 +- testsuite/escript/struct/struct005.src | 8 +- testsuite/escript/struct/struct006.src | 2 +- testsuite/escript/struct/struct007.src | 6 +- testsuite/escript/struct/struct008.src | 8 +- testsuite/escript/struct/struct009.src | 14 +- testsuite/escript/struct/struct010.src | 14 +- testsuite/escript/struct/struct011.src | 28 +- testsuite/escript/substr/substr01.src | 6 +- testsuite/escript/substr/substr02.src | 4 +- testsuite/escript/substr/substr03.src | 12 +- testsuite/escript/substr/substr04.src | 14 +- testsuite/escript/sw/sw001.src | 12 +- testsuite/escript/sw/sw002.src | 10 +- testsuite/escript/sw/sw003.src | 10 +- testsuite/escript/sw/sw004.src | 34 +- testsuite/escript/switch/switch01.src | 15 +- testsuite/escript/switch/switch02.src | 15 +- testsuite/escript/switch/switch03.src | 18 +- testsuite/escript/switch/switch04.src | 18 +- testsuite/escript/switch/switch05.src | 18 +- testsuite/escript/switch/switch06.src | 16 +- testsuite/escript/switch/switch07.src | 16 +- testsuite/escript/switch/switch08.src | 17 +- testsuite/escript/switch/switch09.src | 18 +- testsuite/escript/switch/switch10.src | 16 +- testsuite/escript/switch/switch11.src | 10 +- testsuite/escript/switch/switch12.src | 16 +- testsuite/escript/switch/switch13.src | 16 +- testsuite/escript/switch/switch14.src | 8 +- testsuite/escript/switch/switch15.src | 13 +- .../escript/switch/switch16-negative-case.err | 2 +- testsuite/escript/switch/switch16.src | 34 +- .../switch/switch17-duplicate-default.err | 2 +- .../switch/switch17-duplicate-default.src | 10 +- .../switch/switch18-duplicate-string.err | 2 +- .../switch/switch18-duplicate-string.src | 10 +- .../switch/switch19-duplicate-integer.err | 2 +- .../switch/switch19-duplicate-integer.src | 10 +- testsuite/escript/syntax/syntax01.err | 2 +- testsuite/escript/syntax/syntax02.err | 2 +- testsuite/escript/syntax/syntax03.err | 2 +- testsuite/escript/syntax/syntax04.err | 2 +- testsuite/escript/syntax/syntax05.err | 2 +- testsuite/escript/syntax/syntax06.err | 2 +- testsuite/escript/syntax/syntax07.err | 2 +- testsuite/escript/syntax/syntax08.src | 4 +- testsuite/escript/syntax/syntax09.err | 2 +- testsuite/escript/syntax/syntax10.err | 2 +- .../syntax/syntax11-final-semi-required.err | 2 +- .../syntax12-unterminated-expression.err | 2 +- testsuite/escript/test/test.src | 83 +- testsuite/escript/test/test2.src | 11 +- testsuite/escript/test/test3.src | 2 +- testsuite/escript/test/test6.src | 16 +- testsuite/escript/test/testutil.inc | 4 +- testsuite/escript/unicode/unicode01.src | 4 +- testsuite/escript/unicode/unicode02.src | 310 ++--- testsuite/escript/unicode/unicode03.src | 4 +- testsuite/escript/unicode/unicode04.inc | 2 +- testsuite/escript/unicode/unicode04.src | 2 +- testsuite/escript/unicode/unicode05.src | 14 +- testsuite/escript/unicode/unicode06.src | 2 +- .../unicode/unicode07-unicode-lower-case.src | 2 +- testsuite/escript/uninit/uninit01.src | 24 +- testsuite/escript/uninit/uninit02.err | 2 +- testsuite/escript/uninit/uninit03.err | 2 +- testsuite/escript/update_err.py | 62 + testsuite/escript/utilmod/strftime.src | 15 +- testsuite/escript/var/var001.err | 2 +- testsuite/escript/var/var001.src | 2 - testsuite/escript/var/var01.src | 2 +- testsuite/escript/var/var02.src | 6 +- testsuite/escript/var/var03.src | 4 +- testsuite/escript/while/while01.src | 6 +- testsuite/escript/while/while02.src | 6 +- testsuite/escript/while/while03.src | 8 +- testsuite/escript/while/while04.src | 14 +- testsuite/escript/while/while05.src | 29 +- testsuite/escript/while/while06.src | 10 +- testsuite/escript/while/while07.src | 10 +- testsuite/escript/while/while08.src | 10 +- testsuite/escript/while/while09.src | 12 +- testsuite/escript/while/while10.src | 14 +- testsuite/escript/while/while11.src | 18 +- testsuite/escript/while/while12.src | 26 +- testsuite/escript/while/while13.src | 10 +- testsuite/pol/scripts/busyloop.src | 6 +- testsuite/pol/scripts/include/sysevent.inc | 2 +- testsuite/pol/scripts/include/testutil.inc | 42 +- testsuite/pol/scripts/misc/boat.src | 5 +- testsuite/pol/scripts/start.src | 6 +- testsuite/pol/scripts/tests.src | 112 +- testsuite/pol/testpkgs/attack/ai_attack.src | 5 +- .../pol/testpkgs/attack/attackhitscript.src | 22 +- .../pol/testpkgs/attack/test_npc_attack.src | 35 +- testsuite/pol/testpkgs/boat/boat.src | 12 +- testsuite/pol/testpkgs/boat/cleanup.src | 4 +- .../testpkgs/boat/method-scripts/itemdesc.src | 12 +- .../testpkgs/boat/method-scripts/syshook.src | 12 +- testsuite/pol/testpkgs/boat/test_boat.src | 332 +++--- testsuite/pol/testpkgs/boat/walkon.src | 3 +- testsuite/pol/testpkgs/char/cleanup.src | 6 +- testsuite/pol/testpkgs/char/setup.src | 4 +- testsuite/pol/testpkgs/char/test_aos.src | 182 ++- testsuite/pol/testpkgs/char/test_chr.src | 142 +-- testsuite/pol/testpkgs/client/cleanup.src | 30 +- .../pol/testpkgs/client/clientconnection.src | 30 +- .../pol/testpkgs/client/communication.inc | 36 +- testsuite/pol/testpkgs/client/onSnoop.src | 4 +- testsuite/pol/testpkgs/client/packethook.src | 1 - testsuite/pol/testpkgs/client/setup.src | 140 +-- testsuite/pol/testpkgs/client/test_client.src | 211 ++-- .../pol/testpkgs/client/test_client_boat.src | 530 ++++----- .../client/test_client_container_events.src | 83 +- .../pol/testpkgs/client/test_client_demo.src | 81 +- .../pol/testpkgs/client/test_client_gump.src | 26 +- .../testpkgs/client/test_client_item_move.src | 714 ++++++------ .../pol/testpkgs/client/test_client_range.src | 203 ++-- .../pol/testpkgs/client/test_client_snoop.src | 160 ++- testsuite/pol/testpkgs/debugger/debuggee.src | 78 +- .../pol/testpkgs/debugger/debugger_client.src | 1016 +++++++++-------- .../pol/testpkgs/debugger/test_debugger.src | 66 +- testsuite/pol/testpkgs/funcref/external.src | 4 +- testsuite/pol/testpkgs/funcref/test_call.src | 15 +- testsuite/pol/testpkgs/house/cleanup.src | 4 +- testsuite/pol/testpkgs/house/test_house.src | 78 +- .../testpkgs/house/test_house_set_multiid.src | 205 ++-- .../pol/testpkgs/house/test_houserange.src | 32 +- testsuite/pol/testpkgs/house/walkon.src | 7 +- .../item/container_events/caninsert.src | 16 +- .../item/container_events/canremove.src | 21 +- .../item/container_events/oninsert.src | 16 +- .../item/container_events/onremove.src | 12 +- .../pol/testpkgs/item/control_destroy.src | 10 +- testsuite/pol/testpkgs/item/control_echo.src | 10 +- .../pol/testpkgs/item/control_restartable.src | 18 +- testsuite/pol/testpkgs/item/method.src | 9 +- testsuite/pol/testpkgs/item/test_item.src | 317 ++--- testsuite/pol/testpkgs/item/test_load.src | 21 +- testsuite/pol/testpkgs/map/test_findpath.src | 143 ++- .../map/test_getstandingcoordinates.src | 108 +- .../pol/testpkgs/map/test_liststatics.src | 16 +- testsuite/pol/testpkgs/map/test_mapinfo.src | 44 +- testsuite/pol/testpkgs/misc/test_cmds.src | 7 +- testsuite/pol/testpkgs/misc/test_env.src | 26 +- .../pol/testpkgs/misc/test_httprequest.src | 50 +- testsuite/pol/testpkgs/misc/test_polcore.src | 6 +- .../pol/testpkgs/misc/test_polsystem.src | 6 +- testsuite/pol/testpkgs/misc/test_www.src | 91 +- .../testpkgs/misc/textcmd/test/dummycmd.src | 2 +- testsuite/pol/testpkgs/npc/ai_enteredarea.src | 54 +- testsuite/pol/testpkgs/npc/ai_movement.src | 18 +- testsuite/pol/testpkgs/npc/ai_speech.src | 18 +- testsuite/pol/testpkgs/npc/cleanup.src | 6 +- testsuite/pol/testpkgs/npc/test_npc.src | 373 +++--- .../pol/testpkgs/restart/test_account.src | 65 +- testsuite/pol/testpkgs/restart/test_armor.src | 45 +- testsuite/pol/testpkgs/restart/test_boat.src | 52 +- testsuite/pol/testpkgs/restart/test_char.src | 259 +++-- .../pol/testpkgs/restart/test_container.src | 55 +- .../pol/testpkgs/restart/test_corpse.src | 57 +- .../pol/testpkgs/restart/test_datafile.src | 98 +- testsuite/pol/testpkgs/restart/test_guild.src | 70 +- testsuite/pol/testpkgs/restart/test_house.src | 90 +- testsuite/pol/testpkgs/restart/test_item.src | 375 +++--- .../pol/testpkgs/restart/test_lockable.src | 38 +- testsuite/pol/testpkgs/restart/test_map.src | 95 +- testsuite/pol/testpkgs/restart/test_npc.src | 297 +++-- testsuite/pol/testpkgs/restart/test_party.src | 36 +- testsuite/pol/testpkgs/restart/test_realm.src | 16 +- .../pol/testpkgs/restart/test_resource.src | 2 +- .../pol/testpkgs/restart/test_spellbook.src | 34 +- .../pol/testpkgs/restart/test_storage.src | 38 +- .../pol/testpkgs/restart/test_uobject.src | 192 +++- .../pol/testpkgs/restart/test_weapon.src | 50 +- testsuite/pol/testpkgs/scheduler/exported.src | 4 +- .../pol/testpkgs/scheduler/exportedargs.src | 24 +- .../scheduler/simultaneous_loadexported.src | 10 +- .../testpkgs/scheduler/test_loadexported.src | 170 ++- .../testpkgs/scheduler/test_run_script.src | 4 +- testsuite/pol/testpkgs/sql/setup.src | 2 +- testsuite/pol/testpkgs/sql/test_sql.src | 13 +- .../pol/testpkgs/storage/test_storage.src | 136 +-- testsuite/pol/testpkgs/webserver/www/test.src | 58 +- 787 files changed, 8912 insertions(+), 8525 deletions(-) create mode 100755 testsuite/escript/update_err.py diff --git a/cmake/parse_modules.cmake b/cmake/parse_modules.cmake index 0f367cc48..f1d276646 100644 --- a/cmake/parse_modules.cmake +++ b/cmake/parse_modules.cmake @@ -85,6 +85,8 @@ function (read_def MODCLASS CONTENT OUT_APPEND_TO) string(APPEND funcdefs " { \"${funcname}\", &${MODCLASS}::mf_${funcname}, ") if (CMAKE_MATCH_2) set(paramstr "${CMAKE_MATCH_2}") + string(REGEX REPLACE "\r?\n" " " paramstr "${paramstr}") + string(REGEX REPLACE "[ ]+" " " paramstr "${paramstr}") # message(${paramstr}) string(REGEX MATCHALL "," params "${paramstr}") list(LENGTH params n) diff --git a/pol-core/support/scripts/attributes.em b/pol-core/support/scripts/attributes.em index 65d28d6a6..05b7d3bf0 100644 --- a/pol-core/support/scripts/attributes.em +++ b/pol-core/support/scripts/attributes.em @@ -2,6 +2,7 @@ // Attribute related functions // +// format-off const ATTRIBUTE_LOCK_UP := 0; const ATTRIBUTE_LOCK_DOWN := 1; const ATTRIBUTE_LOCK_LOCKED := 2; @@ -10,6 +11,7 @@ const ATTRIBUTE_PRECISION_NORMAL := 0; const ATTRIBUTE_PRECISION_TENTHS := 1; const ATTRIBUTE_MAX_BASE := 60000; +// format-on CheckSkill( character, skillid_or_attrname, difficulty, points ); @@ -25,13 +27,12 @@ GetAttributeTemporaryMod( character, attrname ); GetAttributeLock( character, attrname ); SetAttributeLock( character, attrname, lockstate ); -GetAttributeDefaultCap ( attrname ); +GetAttributeDefaultCap( attrname ); GetAttributeCap( character, attrname ); SetAttributeCap( character, attrname, capvalue ); SetAttributeBaseValue( character, attrname, basevalue_tenths ); // obsoletes SetRawSkill SetAttributeTemporaryMod( character, attrname, tempmod_tenths ); // obsoletes mob.strength_mod etc - BaseSkillToRawSkill( baseskill ); RawSkillToBaseSkill( rawskill ); diff --git a/pol-core/support/scripts/basic.em b/pol-core/support/scripts/basic.em index 7d97d42fe..2547651e9 100644 --- a/pol-core/support/scripts/basic.em +++ b/pol-core/support/scripts/basic.em @@ -1,3 +1,4 @@ +// format-off const TRIM_LEFT := 0x1; // Trim whitespace from Left of string. const TRIM_RIGHT := 0x2; // Trim whitespace from Right of string. const TRIM_BOTH := 0x3; // Trim whitespace from Left and Right of string. @@ -38,66 +39,64 @@ const OT_ITEMREF := 31; const OT_BOATREF := 32; const OT_MULTIREF := 33; const OT_CLIENTREF := 34; - // Only applicable if SQL is active and compiled. -const OT_SQLCONN := 35; +const OT_SQLCONN := 35; // Only applicable if SQL is active and compiled. const OT_SQLRESULT := 36; const OT_SQLROW := 37; - const OT_BOOLEAN := 38; const OT_FUNCOBJECT := 39; const OT_EXPORTEDSCRIPT := 40; const OT_STORAGEAREA := 41; +// format-on - // returns the one-based index of Search within Str after position Start +// returns the one-based index of Search within Str after position Start Find( Str, Search, Start ); - - // len(): For strings, returns string length - // For arrays, returns number of elements. +// len(): For strings, returns string length +// For arrays, returns number of elements. Len( Str_or_array ); - // upper(): Convert whole string to upper-case - // lower(): Convert whole string to lower-case +// upper(): Convert whole string to upper-case +// lower(): Convert whole string to lower-case Upper( Str ); Lower( Str ); - // Various Conversion Functions - // -CInt( expr ); // Convert to integer -CDbl( expr ); // Convert to double -CStr( expr ); // Convert to string -CAsc( str ); // Convert first character to Ascii value (0-255) -CChr( number ); // Convert Ascii value to character (type: string) -CAscZ( str, nullterm := 0 ); // Convert string to array of Ascii values (0-255) -CChrZ( intarray, break_at_first_null := 0 ); // Convert array of Ascii values to a string +// Various Conversion Functions +// +CInt( expr ); // Convert to integer +CDbl( expr ); // Convert to double +CStr( expr ); // Convert to string +CAsc( str ); // Convert first character to Ascii value (0-255) +CChr( number ); // Convert Ascii value to character (type: string) +CAscZ( str, nullterm := 0 ); // Convert string to array of Ascii values (0-255) +CChrZ( intarray, break_at_first_null := 0 ); // Convert array of Ascii values to a string -Bin( number) ; // Convert 25 to 11001 -Hex( number ); // Convert to 0x[hex val] - 0x0 to 0xFFFFFFFF +Bin( number ); // Convert 25 to 11001 +Hex( number ); // Convert to 0x[hex val] - 0x0 to 0xFFFFFFFF - // Compare(): Compares 2 strings and returns based results. - // 1 = Match - // 0 = Not a match -Compare(str1, str2, pos1_start:=0, pos1_end:=0, pos2_start:=0, pos2_end:=0); - - // SplitWords: returns an array of words contained in str, based - // on optional delimiter. Default delim is blank space. - // on optional max_split. Default -1 for unlimited. +// Compare(): Compares 2 strings and returns based results. +// 1 = Match +// 0 = Not a match +Compare( str1, str2, pos1_start := 0, pos1_end := 0, pos2_start := 0, pos2_end := 0 ); + +// SplitWords: returns an array of words contained in str, based +// on optional delimiter. Default delim is blank space. +// on optional max_split. Default -1 for unlimited. SplitWords( str, delimiter := " ", max_split := -1 ); - // SubStr(): Returns substring beginning at start until length. -SubStr(str, start, length); - // Trim(): Returns string with whitespace cleared based on Type and Character to trim. - // set: Character set to trim - // type: 1 = Trim Leading, 2 = Trim Trailing, 3 = Trim Both. -Trim(str, type:=TRIM_BOTH, to_trim:=" "); - // StrReplace(): Replace instance of to_replace with replace_with in str. -StrReplace(str, to_replace, replace_with); - // SubStrReplace(): Replace portion of string using replace_with, beginning at start for length. -SubStrReplace(str, replace_with, start, length:=0); +// SubStr(): Returns substring beginning at start until length. +SubStr( str, start, length ); +// Trim(): Returns string with whitespace cleared based on Type and Character to trim. +// set: Character set to trim +// type: 1 = Trim Leading, 2 = Trim Trailing, 3 = Trim Both. +Trim( str, type := TRIM_BOTH, to_trim := " " ); +// StrReplace(): Replace instance of to_replace with replace_with in str. +StrReplace( str, to_replace, replace_with ); +// SubStrReplace(): Replace portion of string using replace_with, beginning at start for length. +SubStrReplace( str, replace_with, start, length := 0 ); - // Pack and Unpack: convert an object to a storable string form - // Pack( 5 ) returns "i5" - // Unpack( "i5" ) returns 5 - // strings, integers, reals, and arrays and dictionaries of these can be packed. +// Pack and Unpack: convert an object to a storable string form +// Pack( 5 ) returns "i5" +// Unpack( "i5" ) returns 5 +// strings, integers, reals, and arrays and dictionaries of these can be packed. Pack( expr ); Unpack( str ); diff --git a/pol-core/support/scripts/basicio.em b/pol-core/support/scripts/basicio.em index 39909993c..8c6583b6d 100644 --- a/pol-core/support/scripts/basicio.em +++ b/pol-core/support/scripts/basicio.em @@ -1,21 +1,20 @@ -//xterm text color constants for print and syslog -const CONSOLE_COLOR_RED:="\x1b[31m"; -const CONSOLE_COLOR_GREEN:="\x1b[32m"; -const CONSOLE_COLOR_YELLOW:="\x1b[33m"; -const CONSOLE_COLOR_BLUE:="\x1b[34m"; -const CONSOLE_COLOR_MAGENTA:="\x1b[35m"; -const CONSOLE_COLOR_CYAN:="\x1b[36m"; +// format-off +// xterm text color constants for print and syslog +const CONSOLE_COLOR_RED := "\x1b[31m"; +const CONSOLE_COLOR_GREEN := "\x1b[32m"; +const CONSOLE_COLOR_YELLOW := "\x1b[33m"; +const CONSOLE_COLOR_BLUE := "\x1b[34m"; +const CONSOLE_COLOR_MAGENTA := "\x1b[35m"; +const CONSOLE_COLOR_CYAN := "\x1b[36m"; +// format-on - -Print( anything, console_color:="" ); +Print( anything, console_color := "" ); // below this point not yet implemented -//input(); -//inkey(); - -//newline(); - -//redirectin( filename ); -//redirectout( filename ); +// input(); +// inkey(); +// newline(); +// redirectin( filename ); +// redirectout( filename ); diff --git a/pol-core/support/scripts/boat.em b/pol-core/support/scripts/boat.em index 4bcae2f52..5aa49dc1f 100644 --- a/pol-core/support/scripts/boat.em +++ b/pol-core/support/scripts/boat.em @@ -1,42 +1,39 @@ +// format-off // MoveBoat flags +const BOAT_SPEED_ONE_TILE := 1; +const BOAT_SPEED_SLOW := 2; +const BOAT_SPEED_MEDIUM := 3; +const BOAT_SPEED_FAST := 4; +// format-on -const BOAT_SPEED_ONE_TILE := 1; -const BOAT_SPEED_SLOW := 2; -const BOAT_SPEED_MEDIUM := 3; -const BOAT_SPEED_FAST := 4; - - // MoveBoat: moves a boat in the direction of an absolute facing - // 0=N, 1=NE, 2=E, etc - // speed to determine how fast the boat movement should be animated for smooth move +// MoveBoat: moves a boat in the direction of an absolute facing +// 0=N, 1=NE, 2=E, etc +// speed to determine how fast the boat movement should be animated for smooth move MoveBoat( boat, facing, speed := BOAT_SPEED_ONE_TILE ); - - // MoveBoatRelative: move a boat in the direction of a relative facing - // same as MoveBoat, but adjusted for boat's facing. - // If boat faces East, 0 will move E, 1 will move SE, etc. - // speed to determine how fast the boat movement should be animated for smooth move +// MoveBoatRelative: move a boat in the direction of a relative facing +// same as MoveBoat, but adjusted for boat's facing. +// If boat faces East, 0 will move E, 1 will move SE, etc. +// speed to determine how fast the boat movement should be animated for smooth move MoveBoatRelative( boat, direction, speed := BOAT_SPEED_ONE_TILE ); - // MoveBoatXY: moves a boat to the specified X,Y coordinate. Careful moving - // close to the world edge where a part of the boat might be out of bounds. -MoveBoatXY( boat, x, y ); +// MoveBoatXY: moves a boat to the specified X,Y coordinate. Careful moving +// close to the world edge where a part of the boat might be out of bounds. +MoveBoatXY( boat, x, y ); - // RegisterItemWithBoat:'registering' an item with a boat causes the boat - // to move the item when it moves, iff the item is still on the boat. +// RegisterItemWithBoat:'registering' an item with a boat causes the boat +// to move the item when it moves, iff the item is still on the boat. RegisterItemWithBoat( boat, item ); - - // BoatFromItem: if you have an itemref referring to a boat (typically - // in a doubleclick script) this will convert it into a boatref. - // Note that this should not be necessary anymore. +// BoatFromItem: if you have an itemref referring to a boat (typically +// in a doubleclick script) this will convert it into a boatref. +// Note that this should not be necessary anymore. BoatFromItem( item ); - - // TurnBoat: Turn a boat in a direction, relative to its current directon. - // direction is 0=none, 1=right, 2=around, 3=left +// TurnBoat: Turn a boat in a direction, relative to its current directon. +// direction is 0=none, 1=right, 2=around, 3=left TurnBoat( boat, direction ); - - // SystemFindBoatBySerial: given the serial number of a boat, return - // a boatref that can be used with MoveBoat, TurnBoat, etc. -SystemFindBoatBySerial( serial ); \ No newline at end of file +// SystemFindBoatBySerial: given the serial number of a boat, return +// a boatref that can be used with MoveBoat, TurnBoat, etc. +SystemFindBoatBySerial( serial ); diff --git a/pol-core/support/scripts/cfgfile.em b/pol-core/support/scripts/cfgfile.em index 9dbce640f..fd621e2f0 100644 --- a/pol-core/support/scripts/cfgfile.em +++ b/pol-core/support/scripts/cfgfile.em @@ -1,66 +1,61 @@ ReadConfigFile( filename ); // not including ".cfg" - // File scope functions +// File scope functions FindConfigElem( config_file, key ); // key may be an integer or a string. GetConfigMaxIntKey( config_file ); GetConfigStringKeys( config_file ); // return an array of all the keys as strings -GetConfigIntKeys( config_file ); // return an array of all the int keys +GetConfigIntKeys( config_file ); // return an array of all the int keys - // Element scope functions -ListConfigElemProps( element ); // : array of the element's property-names (unique strings) -GetConfigInt( element, property_name ); // : integer; -GetConfigReal( element, property_name ); // : real; -GetConfigString( element, property_name ); // : string; +// Element scope functions +ListConfigElemProps( element ); // : array of the element's property-names (unique strings) +GetConfigInt( element, property_name ); // : integer; +GetConfigReal( element, property_name ); // : real; +GetConfigString( element, property_name ); // : string; - - // For elements with multiple occurrences of a given property, - // return an array containing each occurrence. +// For elements with multiple occurrences of a given property, +// return an array containing each occurrence. GetConfigStringArray( element, property_name ); // : array of strings; GetConfigIntArray( element, property_name ); // array of ints GetConfigStringDictionary( element, property_name ); - - - // Appends an element to the config file specified. - // Properties must be an array of structures, where each element - // is a structure containing a name member first, and a value member - // second. +// Appends an element to the config file specified. +// Properties must be an array of structures, where each element +// is a structure containing a name member first, and a value member +// second. AppendConfigFileElem( filename, elemtype, elemkey, properties ); - - // Unloads a config file from memory. If other scripts reference the - // config file specified, it will remain in memory until they no longer - // reference it. Scripts which call ReadConfigFile() after this, however, - // will re-read the config file and use the newer version. +// Unloads a config file from memory. If other scripts reference the +// config file specified, it will remain in memory until they no longer +// reference it. Scripts which call ReadConfigFile() after this, however, +// will re-read the config file and use the newer version. UnloadConfigFile( filename ); - // - // Load a TUS .SCP file as a config file - // - // Filename must be alphanumeric only. The file must exist - // in pol/import/tus. So LoadTusScpFile( "grayacct" ) will - // try to load "/pol/import/tus/grayacct.scp" - // - // Header properties, if any, in cfgfile[0] - // Other elements numbered sequentially from 1 - // The part in brackets ("[WORLDITEM 04000]") will appear in two ways: - // 1) as a "_key" property - // 2) as a property itself (name=WORLDITEM, value=0x4000) - // - // - // So,if you had the following as the first element - // [WORLDITEM 04000] - // SERIAL=080 - // P=1,2,3 - // And 'var tusfile' was the result of LoadTusScpFile, then - // tusfile[1]._key is "WORLDITEM 04000" - // tusfile[1].worlditem is 0x4000 - // tusfile[1].serial is 0x80 - // tusfile[1].p is "1,2,3" - // +// +// Load a TUS .SCP file as a config file +// +// Filename must be alphanumeric only. The file must exist +// in pol/import/tus. So LoadTusScpFile( "grayacct" ) will +// try to load "/pol/import/tus/grayacct.scp" +// +// Header properties, if any, in cfgfile[0] +// Other elements numbered sequentially from 1 +// The part in brackets ("[WORLDITEM 04000]") will appear in two ways: +// 1) as a "_key" property +// 2) as a property itself (name=WORLDITEM, value=0x4000) +// +// +// So,if you had the following as the first element +// [WORLDITEM 04000] +// SERIAL=080 +// P=1,2,3 +// And 'var tusfile' was the result of LoadTusScpFile, then +// tusfile[1]._key is "WORLDITEM 04000" +// tusfile[1].worlditem is 0x4000 +// tusfile[1].serial is 0x80 +// tusfile[1].p is "1,2,3" +// LoadTusScpFile( filename ); - // deprecated by GetConfigString: -GetElemProperty( element, property_name ); // : string; +GetElemProperty( element, property_name ); // : string; diff --git a/pol-core/support/scripts/cliloc.em b/pol-core/support/scripts/cliloc.em index d4a6c4599..a22ca4488 100644 --- a/pol-core/support/scripts/cliloc.em +++ b/pol-core/support/scripts/cliloc.em @@ -2,11 +2,13 @@ // Cliloc Message related functions // +// format-off // // CONSTANTS // const _DEFAULT_CLFONT := 3; const _DEFAULT_CLCOLOR := 0x3B2; +// format-on // // Functions @@ -19,14 +21,14 @@ const _DEFAULT_CLCOLOR := 0x3B2; // Font : Font // Color : Color // -// Argument example: -// take number 1042762: -// "Only ~1_AMOUNT~ gold could be deposited. A check for ~2_CHECK_AMOUNT~ gold was returned to you." -// the arguments string may have "100 thousand\t25 hundred", which in turn would modify the string: +// Argument example: +// take number 1042762: +// "Only ~1_AMOUNT~ gold could be deposited. A check for ~2_CHECK_AMOUNT~ gold was returned to you." +// the arguments string may have "100 thousand\t25 hundred", which in turn would modify the string: // "Only 100 thousand gold could be deposited. A check for 25 hundred gold was returned to you." -SendSysMessageCL( character, cliloc_num, uc_text:="", font:=_DEFAULT_CLFONT , color:=_DEFAULT_CLCOLOR); +SendSysMessageCL( character, cliloc_num, uc_text := "", font := _DEFAULT_CLFONT, color := _DEFAULT_CLCOLOR ); -PrintTextAboveCL( character, cliloc_num, uc_text:="", font:=_DEFAULT_CLFONT , color:=_DEFAULT_CLCOLOR); +PrintTextAboveCL( character, cliloc_num, uc_text := "", font := _DEFAULT_CLFONT, color := _DEFAULT_CLCOLOR ); // Object : Object text is to appear over. -PrintTextAbovePrivateCL( character, object, cliloc_num, uc_text:="", font:=_DEFAULT_CLFONT , color:=_DEFAULT_CLCOLOR); +PrintTextAbovePrivateCL( character, object, cliloc_num, uc_text := "", font := _DEFAULT_CLFONT, color := _DEFAULT_CLCOLOR ); diff --git a/pol-core/support/scripts/datafile.em b/pol-core/support/scripts/datafile.em index 3c71ceb0a..386cccb98 100644 --- a/pol-core/support/scripts/datafile.em +++ b/pol-core/support/scripts/datafile.em @@ -1,10 +1,11 @@ +// format-off // // OpenDataFile flags: // // can specify only one of the following: -const DF_KEYTYPE_STRING := 0x00; // default -const DF_KEYTYPE_INTEGER := 0x01; - +const DF_KEYTYPE_STRING := 0x00; // default +const DF_KEYTYPE_INTEGER := 0x01; +// format-on // // Functions @@ -12,9 +13,9 @@ const DF_KEYTYPE_INTEGER := 0x01; ListDataFiles(); CreateDataFile( filespec, flags := DF_KEYTYPE_STRING ); OpenDataFile( filespec ); // fails if does not exist -//DataFileExists( filespec ); -//DeleteDataFile( filespec ); -//RenameDataFile( oldfilespec, newfilespec ); +// DataFileExists( filespec ); +// DeleteDataFile( filespec ); +// RenameDataFile( oldfilespec, newfilespec ); UnloadDataFile( filespec ); // Object: DataFile datafile; diff --git a/pol-core/support/scripts/file.em b/pol-core/support/scripts/file.em index 14acdaa69..a8ccfb1e3 100644 --- a/pol-core/support/scripts/file.em +++ b/pol-core/support/scripts/file.em @@ -1,13 +1,14 @@ //////////////////////////////////////////////////////////////// // -// CONSTANTS +// CONSTANTS // //////////////////////////////////////////////////////////////// +// format-off // LogToFile constants const LOG_DATETIME := 1; // log Core-Style DateTimeStr in front of log entry -//BinaryFile constants +// BinaryFile constants const OPENMODE_IN := 0x01; // (input) Allow input operations on the stream const OPENMODE_OUT := 0x02; // (output) Allow output operations on the stream const OPENMODE_ATE := 0x04; // (at end) Set the stream's position indicator to the end of the stream on opening @@ -26,10 +27,11 @@ const LISTDIR_LIST_DIRS := 0x1; const LISTDIR_DONT_LIST_DIRS := 0x0; const LISTDIR_NO_FILES := ""; const LISTDIR_ALL_FILES := "*"; +// format-on //////////////////////////////////////////////////////////////// // -// FUNCTIONS +// FUNCTIONS // //////////////////////////////////////////////////////////////// @@ -45,4 +47,4 @@ CreateDirectory( dirname ); ListDirectory( dirname, extension := LISTDIR_ALL_FILES, listdirs := LISTDIR_DONT_LIST_DIRS ); OpenXMLFile( filename ); -CreateXMLFile( ); \ No newline at end of file +CreateXMLFile(); diff --git a/pol-core/support/scripts/guilds.em b/pol-core/support/scripts/guilds.em index ad2bf59ea..c40796cd3 100644 --- a/pol-core/support/scripts/guilds.em +++ b/pol-core/support/scripts/guilds.em @@ -4,7 +4,7 @@ ListGuilds(); -FindGuild( guildid ); +FindGuild( guildid ); CreateGuild(); DestroyGuild( guild ); diff --git a/pol-core/support/scripts/http.em b/pol-core/support/scripts/http.em index 6a4a7cce6..d0c681a2c 100644 --- a/pol-core/support/scripts/http.em +++ b/pol-core/support/scripts/http.em @@ -1,6 +1,6 @@ // WriteStatus( code, reason = "" ) // -// Writes the HTTP status code with optional reason. Can only be used before any +// Writes the HTTP status code with optional reason. Can only be used before any // WriteHeader(), WriteHtml(), and WriteHtmlRaw() functions. If data has already // been sent via these calls, then WriteStatus() will return an // error. @@ -9,12 +9,12 @@ WriteStatus( code, reason := "" ); // WriteHeader( name, value ) // // Writes a header to the "virtual webpage" that's to be sent -// to the connecting browser. Can only be used before any +// to the connecting browser. Can only be used before any // WriteHtml() or WriteHtmlRaw() commands and after optionally WriteStatus(). If data has already // been sent via these calls, then WriteHeader() will return an // error. // -// This function can also be used to change the content type from +// This function can also be used to change the content type from // the default "text/html" by writing a Content-Type header name. WriteHeader( name, value ); @@ -51,4 +51,4 @@ QueryParam( param ); // // QueryIP() --> "192.168.0.5" // -QueryIP(); \ No newline at end of file +QueryIP(); diff --git a/pol-core/support/scripts/math.em b/pol-core/support/scripts/math.em index 020c87f6f..266e37410 100644 --- a/pol-core/support/scripts/math.em +++ b/pol-core/support/scripts/math.em @@ -1,33 +1,33 @@ // Trig Functions // Sin, Cos, Tan take arguments in Radians // ASin, ACos, ATan return results in Radians -Sin(x); -Cos(x); -Tan(x); -ASin(x); -ACos(x); -ATan(x); +Sin( x ); +Cos( x ); +Tan( x ); +ASin( x ); +ACos( x ); +ATan( x ); // Radian <-> Degrees Conversion RadToDeg( radians ); DegToRad( degrees ); -Min(x,y:=0); // returns minumum of x and y or lowest Element in given array -Max(x,y:=0); // returns maximum of x and y or biggest Element in given array -Pow(x,y); // returns x ^ y -Sqrt(x); // returns square root of x -Root(x,y); // returns y root of x (same as Pow(x,1.0/y)) -Abs(x); // returns absolute value (works on Reals and Integers) -Log10(x); // Returns log(base 10) of x -LogE(x); // Returns natural log of x +Min( x, y := 0 ); // returns minumum of x and y or lowest Element in given array +Max( x, y := 0 ); // returns maximum of x and y or biggest Element in given array +Pow( x, y ); // returns x ^ y +Sqrt( x ); // returns square root of x +Root( x, y ); // returns y root of x (same as Pow(x,1.0/y)) +Abs( x ); // returns absolute value (works on Reals and Integers) +Log10( x ); // Returns log(base 10) of x +LogE( x ); // Returns natural log of x // rounding functions -Ceil(x); // returns Real that is smallest integer >= x -Floor(x); // returns Real that is largest integer <= x +Ceil( x ); // returns Real that is smallest integer >= x +Floor( x ); // returns Real that is largest integer <= x // functions to return some constants ConstPi(); ConstE(); // I'm just playing with this one... -FormatRealToString( value, precision ); \ No newline at end of file +FormatRealToString( value, precision ); diff --git a/pol-core/support/scripts/npc.em b/pol-core/support/scripts/npc.em index 50ac08cc3..4898b0df6 100644 --- a/pol-core/support/scripts/npc.em +++ b/pol-core/support/scripts/npc.em @@ -1,27 +1,28 @@ //////////////////////////////////////////////////////////////// // -// CONSTANTS +// CONSTANTS // //////////////////////////////////////////////////////////////// - +// format-off // Constants for texttype flags in the Say() and SayUC() functions const SAY_TEXTTYPE_DEFAULT := "default"; const SAY_TEXTTYPE_WHISPER := "whisper"; -const SAY_TEXTTYPE_YELL := "yell"; +const SAY_TEXTTYPE_YELL := "yell"; // Constant for Unicode Language flag in the SayUC() function const SAY_LANG := "ENU"; // Constants for doevent flag in Say() and SayUC() functions const SAY_DOEVENT_DISABLE := 0x0; -const SAY_DOEVENT_ENABLE := 0x1; +const SAY_DOEVENT_ENABLE := 0x1; const FACE_NORMAL := 0x0; -const FACE_FORCE := 0x1; +const FACE_FORCE := 0x1; +// format-on //////////////////////////////////////////////////////////////// // -// FUNCTIONS +// FUNCTIONS // //////////////////////////////////////////////////////////////// @@ -42,8 +43,7 @@ Face( direction, flags := FACE_NORMAL ); // N, S, E, W, NW, NE, SW, SE // a boundingbox is okay, too -Move( direction ); - +Move( direction ); // Move toward, or away from, something. // When a pathfinding algorith exists, these functions will use if necessary. @@ -63,14 +63,12 @@ RunAwayFromLocation( x, y ); TurnTowardLocation( x, y, flags := FACE_NORMAL ); TurnAwayFromLocation( x, y, flags := FACE_NORMAL ); - // Set your opponent. If you are in range (or are carrying // a projectile weapon and have LOS), you will attack. If // a player character is connected, the NPC will highlight. // Implicitly sets war mode. SetOpponent( character ); - // SetWarMode: Usually used to leave warmode, but can be used // to enter warmode independently of setting an opponent. // Setting war mode to 0 clears your opponent. @@ -79,7 +77,7 @@ SetWarMode( warmode ); // Instructs an npc to speak // Texttype is the type of speech the npc will make (Whisper, Normal, Yell) // If doevent is enabled, it will send a system event to other npcs. -Say( text, text_type:=SAY_TEXTTYPE_DEFAULT, do_event:=SAY_DOEVENT_DISABLE ); +Say( text, text_type := SAY_TEXTTYPE_DEFAULT, do_event := SAY_DOEVENT_DISABLE ); // Instructs an npc to speak in Unicode // Texttype is the type of speech the npc will make (Whisper, Normal, Yell) @@ -88,8 +86,7 @@ Say( text, text_type:=SAY_TEXTTYPE_DEFAULT, do_event:=SAY_DOEVENT_DISABLE ); // where each integer is a Unicode character! // 'langcode' is a 3-character "Originating Language" code // e.g. ENG, ENU, CHT, DEU, FRA, JPN, RUS, KOR (etc??) -SayUC(uc_text, text_type:=SAY_TEXTTYPE_DEFAULT, langcode:=SAY_LANG, do_event:=SAY_DOEVENT_DISABLE ); - +SayUC( uc_text, text_type := SAY_TEXTTYPE_DEFAULT, langcode := SAY_LANG, do_event := SAY_DOEVENT_DISABLE ); // * deprecated ( use Self().x, Self().y, Self().z ) - Do not use position(); @@ -97,14 +94,14 @@ position(); // Get a custom property. Equivalent to GetObjProperty( Self(), propertyname ) GetProperty( propertyname ); -// Set a custom property. +// Set a custom property. // Equivalent to SetObjProperty( Self(), propertyname, propertyvalue ) SetProperty( propertyname, propertyvalue ); -// Make a bounding box from an area string. +// Make a bounding box from an area string. // An area string is a number of 'x1 y1 x2 y2' entries. // "1 1 10 10 10 3 20 6" would create a walk area something like this: -// XXX +// XXX // XXXXXX // XXX MakeBoundingBox( areastring ); diff --git a/pol-core/support/scripts/os.em b/pol-core/support/scripts/os.em index ea4b0e829..275bae065 100644 --- a/pol-core/support/scripts/os.em +++ b/pol-core/support/scripts/os.em @@ -1,112 +1,111 @@ Create_Debug_Context(); - // get a process scripting object by PID - // If no PID is supplied will use parent script pid. +// get a process scripting object by PID +// If no PID is supplied will use parent script pid. GetProcess( pid := -1 ); - // getpid: get this script's pid +// getpid: get this script's pid GetPid(); - // - // unload_scripts: unload scripts from the script cache (they will be - // reloaded from disk on demand) currently running - // scripts will continue as normal. - // Passing "" will unload all scripts. - // +// +// unload_scripts: unload scripts from the script cache (they will be +// reloaded from disk on demand) currently running +// scripts will continue as normal. +// Passing "" will unload all scripts. +// Unload_Scripts( scriptname := "" ); - // - // set_script_option: Set script options - // -Set_Script_Option( optnum, optval ); // return value is the value that is currently set for that option, or error -const SCRIPTOPT_NO_INTERRUPT := 1; // if 1, script runs until it sleeps -const SCRIPTOPT_DEBUG := 2; // if 1, prints any debug info included -const SCRIPTOPT_NO_RUNAWAY := 3; // if 1, doesn't warn about runaway conditions -const SCRIPTOPT_CAN_ACCESS_OFFLINE_MOBILES := 4; -const SCRIPTOPT_AUXSVC_ASSUME_STRING := 5; +// +// set_script_option: Set script options +// +Set_Script_Option( optnum, optval ); // return value is the value that is currently set for that option, or error +// format-off +const SCRIPTOPT_NO_INTERRUPT := 1; // if 1, script runs until it sleeps +const SCRIPTOPT_DEBUG := 2; // if 1, prints any debug info included +const SCRIPTOPT_NO_RUNAWAY := 3; // if 1, doesn't warn about runaway conditions +const SCRIPTOPT_CAN_ACCESS_OFFLINE_MOBILES := 4; +const SCRIPTOPT_AUXSVC_ASSUME_STRING := 5; const SCRIPTOPT_SURVIVE_ATTACHED_DISCONNECT := 6; // if 1, do not kill script if attached character's client disconnects +// format-on - // - // set_script_option(SCRIPTOPT_NO_INTERRUPT,1) is the same as set_critical(1) - // set_script_option(SCRIPTOPT_DEBUG,1) is the same as set_debug(1) - // +// +// set_script_option(SCRIPTOPT_NO_INTERRUPT,1) is the same as set_critical(1) +// set_script_option(SCRIPTOPT_DEBUG,1) is the same as set_debug(1) +// Sleep( num_seconds ); Sleepms( num_milliseconds ); - // - // wait_for_event: sleep for a number of seconds until an event shows up - // if timeout is 0, return immediately - // returns 0 if no event was ready - // +// +// wait_for_event: sleep for a number of seconds until an event shows up +// if timeout is 0, return immediately +// returns 0 if no event was ready +// Wait_For_Event( num_seconds_timeout ); - // - // events_waiting: the number of events waiting, 0+ - // +// +// events_waiting: the number of events waiting, 0+ +// Events_Waiting(); - // - // set_priority: the priority of a script is how many instructions it - // executes before switching to another script. - // default script priority is 1. - // priority range is 1 to 255. - // Returns previous priority. +// +// set_priority: the priority of a script is how many instructions it +// executes before switching to another script. +// default script priority is 1. +// priority range is 1 to 255. +// Returns previous priority. Set_Priority( priority ); - // - // set_critical: critical scripts run if they are not blocked, without - // interruption. An infinite loop in a critical script - // will hang the server - // +// +// set_critical: critical scripts run if they are not blocked, without +// interruption. An infinite loop in a critical script +// will hang the server +// Set_Critical( critical ); - - // - // set_debug(debug): if debug=1, and the script was compiled with - // 'ecompile -i [script].src', each script source line - // will be printed as it is executed. - // if debug=0, disables this output. - // +// +// set_debug(debug): if debug=1, and the script was compiled with +// 'ecompile -i [script].src', each script source line +// will be printed as it is executed. +// if debug=0, disables this output. +// Set_Debug( debug ); - Start_Script( script_name, param := 0 ); Start_Skill_Script( chr, attr_name, script_name := "", param := 0 ); Run_Script_To_Completion( script_name, param := 0 ); Run_Script( script_name, param := 0 ); +// +// syslog(text): write text to the console, and to the log file +// includes context (calling script name) +// +SysLog( text, log_verbose := 1, console_color := "" ); - // - // syslog(text): write text to the console, and to the log file - // includes context (calling script name) - // -SysLog( text, log_verbose:=1, console_color:="" ); - - // - // clear_event_queue(): Empties the event queue of the current script. - // +// +// clear_event_queue(): Empties the event queue of the current script. +// Clear_Event_Queue(); - // - // set_event_queue_size(size): Sets the event queue size of the current script (default 20) - // -Set_Event_Queue_Size(size); +// +// set_event_queue_size(size): Sets the event queue size of the current script (default 20) +// +Set_Event_Queue_Size( size ); - // - // is_critical(): returns 1 if the calling script is set critical, else 0. - // +// +// is_critical(): returns 1 if the calling script is set critical, else 0. +// Is_Critical(); OpenURL( character, url ); -OpenConnection( host, port, scriptdef, params := 0, assume_string := 0, keep_connection := 0, ignore_line_breaks := 0); +OpenConnection( host, port, scriptdef, params := 0, assume_string := 0, keep_connection := 0, ignore_line_breaks := 0 ); Debugger(); // put script in debug state -PerformanceMeasure(delta_seconds := 10, max_scripts := 100); +PerformanceMeasure( delta_seconds := 10, max_scripts := 100 ); -HTTPRequest(url, method := "GET", options := struct{}, flags := 0); +HTTPRequest( url, method := "GET", options := struct{}, flags := 0 ); const HTTPREQUEST_EXTENDED_RESPONSE := 0x0001; // return Dictionary with various response data instead of a String of response body -LoadExportedScript(name, args:={}); +LoadExportedScript( name, args := {} ); -GetEnvironmentVariable(name:=""); +GetEnvironmentVariable( name := "" ); diff --git a/pol-core/support/scripts/party.em b/pol-core/support/scripts/party.em index fe24b71c7..a6167fea6 100644 --- a/pol-core/support/scripts/party.em +++ b/pol-core/support/scripts/party.em @@ -4,7 +4,7 @@ CreateParty( leader, firstmember ); -DisbandParty( partyref ); +DisbandParty( partyref ); SendPartyMsg( party, character, uctext ); diff --git a/pol-core/support/scripts/polsys.em b/pol-core/support/scripts/polsys.em index a03db5675..856f53568 100644 --- a/pol-core/support/scripts/polsys.em +++ b/pol-core/support/scripts/polsys.em @@ -2,21 +2,21 @@ const MSGLEN_VARIABLE := -1; -AddRealm(realm_name,base_realm); -CreatePacket(type,size); -DeleteRealm(realm); -GetCmdLevelName(number); -GetCmdLevelNumber(name); -GetItemDescriptor(objtype); -FormatItemDescription(desc, amount := 1, suffix := ""); -GetPackageByName(name); -IncRevision(object); -ListTextCommands(max_cmdlevel := -1); // the default (-1) returns all +AddRealm( realm_name, base_realm ); +CreatePacket( type, size ); +DeleteRealm( realm ); +GetCmdLevelName( number ); +GetCmdLevelNumber( name ); +GetItemDescriptor( objtype ); +FormatItemDescription( desc, amount := 1, suffix := "" ); +GetPackageByName( name ); +IncRevision( object ); +ListTextCommands( max_cmdlevel := -1 ); // the default (-1) returns all ListenPoints(); -MD5Encrypt(str); +MD5Encrypt( str ); Packages(); ReadMillisecondClock(); -Realms(realm:=""); +Realms( realm := "" ); ReloadConfiguration(); // reloads pol.cfg and npcdesc.cfg -SetSysTrayPopupText(text); +SetSysTrayPopupText( text ); LogCPropProfile(); diff --git a/pol-core/support/scripts/sql.em b/pol-core/support/scripts/sql.em index 687706c95..19704f33d 100644 --- a/pol-core/support/scripts/sql.em +++ b/pol-core/support/scripts/sql.em @@ -1,13 +1,13 @@ // // SQL related functions // -mysql_connect(host,username,password := "", port := 0); -mysql_query(connection,query,parameters := array{}); -mysql_fetch_row(result); -mysql_affected_rows(result); -mysql_num_fields(result); -mysql_num_rows(result); -mysql_select_db(connection,database); -mysql_field_name(result,column_index); -mysql_close(connection); -mysql_escape_string(connection, str); +mysql_connect( host, username, password := "", port := 0 ); +mysql_query( connection, query, parameters := array{} ); +mysql_fetch_row( result ); +mysql_affected_rows( result ); +mysql_num_fields( result ); +mysql_num_rows( result ); +mysql_select_db( connection, database ); +mysql_field_name( result, column_index ); +mysql_close( connection ); +mysql_escape_string( connection, str ); diff --git a/pol-core/support/scripts/storage.em b/pol-core/support/scripts/storage.em index f438de462..6437c8e6e 100644 --- a/pol-core/support/scripts/storage.em +++ b/pol-core/support/scripts/storage.em @@ -10,4 +10,4 @@ FindRootItemInStorageArea( area, itemname ); CreateStorageArea( areaname ); CreateRootItemInStorageArea( area, itemname, objtype ); -DestroyRootItemInStorageArea( area, itemname ); \ No newline at end of file +DestroyRootItemInStorageArea( area, itemname ); diff --git a/pol-core/support/scripts/unicode.em b/pol-core/support/scripts/unicode.em index 28253db7f..25c517ed7 100644 --- a/pol-core/support/scripts/unicode.em +++ b/pol-core/support/scripts/unicode.em @@ -1,24 +1,25 @@ //////////////////////////////////////////////////////////////// // -// CONSTANTS +// CONSTANTS // //////////////////////////////////////////////////////////////// +// format-off // // Constants for PrintTextAbove* // -const JOURNAL_UC_PRINT_NAME := 0x00; // Implicit. Print's the object's description / npc's name in the journal. -const JOURNAL_UC_PRINT_YOU_SEE := 0x01; // Will print "You see:" in the journal. - +const JOURNAL_UC_PRINT_NAME := 0x00; // Implicit. Print's the object's description / npc's name in the journal. +const JOURNAL_UC_PRINT_YOU_SEE := 0x01; // Will print "You see:" in the journal. // Don't use these outside this file, use FONT_* from client.inc -const _DEFAULT_UCFONT := 3; -const _DEFAULT_UCCOLOR := 0x3B2; +const _DEFAULT_UCFONT := 3; +const _DEFAULT_UCCOLOR := 0x3B2; const _DEFAULT_UCTEXT_REQUIREDCMD := 0; +// format-on //////////////////////////////////////////////////////////////// // -// FUNCTIONS +// FUNCTIONS // //////////////////////////////////////////////////////////////// @@ -28,9 +29,8 @@ const _DEFAULT_UCTEXT_REQUIREDCMD := 0; // 'langcode' is a 3-character "Originating Language" code // e.g. ENG, ENU, CHT, DEU, FRA, JPN, RUS, KOR (etc??) -BroadcastUC(uc_text, langcode, font:=_DEFAULT_UCFONT, color:=_DEFAULT_UCCOLOR, required_cmdlevel := _DEFAULT_UCTEXT_REQUIREDCMD ); -PrintTextAbovePrivateUC(above_object, uc_text, langcode, character, font:=_DEFAULT_UCFONT, color:=_DEFAULT_UCCOLOR, journal_print := JOURNAL_UC_PRINT_NAME); -PrintTextAboveUC(above_object, uc_text, langcode, font:=_DEFAULT_UCFONT, color:=_DEFAULT_UCCOLOR, journal_print := JOURNAL_UC_PRINT_NAME); -RequestInputUC(character, item, uc_prompt, langcode); // item is a placeholder, pass anything -SendSysMessageUC(character, uc_text, langcode, font:=_DEFAULT_UCFONT, color:=_DEFAULT_UCCOLOR); - +BroadcastUC( uc_text, langcode, font := _DEFAULT_UCFONT, color := _DEFAULT_UCCOLOR, required_cmdlevel := _DEFAULT_UCTEXT_REQUIREDCMD ); +PrintTextAbovePrivateUC( above_object, uc_text, langcode, character, font := _DEFAULT_UCFONT, color := _DEFAULT_UCCOLOR, journal_print := JOURNAL_UC_PRINT_NAME ); +PrintTextAboveUC( above_object, uc_text, langcode, font := _DEFAULT_UCFONT, color := _DEFAULT_UCCOLOR, journal_print := JOURNAL_UC_PRINT_NAME ); +RequestInputUC( character, item, uc_prompt, langcode ); // item is a placeholder, pass anything +SendSysMessageUC( character, uc_text, langcode, font := _DEFAULT_UCFONT, color := _DEFAULT_UCCOLOR ); diff --git a/pol-core/support/scripts/uo.em b/pol-core/support/scripts/uo.em index 23b598867..84a40dc3c 100644 --- a/pol-core/support/scripts/uo.em +++ b/pol-core/support/scripts/uo.em @@ -1,60 +1,61 @@ //////////////////////////////////////////////////////////////// // -// CONSTANTS +// CONSTANTS // //////////////////////////////////////////////////////////////// +// format-off // CreateMulti flags // only for house creation and house.set_multiid(): -const CRMULTI_IGNORE_MULTIS := 0x0001; // ignore intersecting multis -const CRMULTI_IGNORE_OBJECTS := 0x0002; // ignore dynamic objects -const CRMULTI_IGNORE_WORLDZ := 0x0004; // ignore standability, relative Z, world height -const CRMULTI_IGNORE_ALL := 0x0007; +const CRMULTI_IGNORE_MULTIS := 0x0001; // ignore intersecting multis +const CRMULTI_IGNORE_OBJECTS := 0x0002; // ignore dynamic objects +const CRMULTI_IGNORE_WORLDZ := 0x0004; // ignore standability, relative Z, world height +const CRMULTI_IGNORE_ALL := 0x0007; // only for house.set_multiid(): const CRMULTI_KEEP_COMPONENTS := 0x0000; const CRMULTI_RECREATE_COMPONENTS := 0x0008; // only for boat creation: -const CRMULTI_FACING_NORTH := 0x0000; -const CRMULTI_FACING_EAST := 0x0100; -const CRMULTI_FACING_SOUTH := 0x0200; -const CRMULTI_FACING_WEST := 0x0300; +const CRMULTI_FACING_NORTH := 0x0000; +const CRMULTI_FACING_EAST := 0x0100; +const CRMULTI_FACING_SOUTH := 0x0200; +const CRMULTI_FACING_WEST := 0x0300; -// ListHostiles exclusions +// ListHostiles exclusions -const LH_FLAG_LOS := 1; // only include those in LOS -const LH_FLAG_INCLUDE_HIDDEN := 2; // include hidden characters +const LH_FLAG_LOS := 1; // only include those in LOS +const LH_FLAG_INCLUDE_HIDDEN := 2; // include hidden characters // FindPath flags -const FP_IGNORE_MOBILES := 0x01; // ignore Mobiles -const FP_IGNORE_DOORS := 0x02; // ignore Doors (you've to open doors by yourself) +const FP_IGNORE_MOBILES := 0x01; // ignore Mobiles +const FP_IGNORE_DOORS := 0x02; // ignore Doors (you've to open doors by yourself) // Send*Window flags -const VENDOR_SEND_AOS_TOOLTIP := 0x01; // send Item Description using AoS Tooltips +const VENDOR_SEND_AOS_TOOLTIP := 0x01; // send Item Description using AoS Tooltips const VENDOR_BUYABLE_CONTAINER_FILTER := 0x02; // filter items in the SendSellWindow() by what is in the buyable container -const SENDDIALOGMENU_FORCE_OLD := 0x01; // send UnCompressed Gump +const SENDDIALOGMENU_FORCE_OLD := 0x01; // send UnCompressed Gump // RegisterForSpeechEvents flags -const LISTENPT_HEAR_GHOSTS := 0x01; // hear ghost speech in addition to living speech -const LISTENPT_HEAR_TOKENS := 0x02; // hear also speechtokens (only with ssopt.SeperateSpeechTokens) -const LISTENPT_NO_SPEECH := 0x04; // hear no normal speech (only with ssopt.SeperateSpeechTokens) +const LISTENPT_HEAR_GHOSTS := 0x01; // hear ghost speech in addition to living speech +const LISTENPT_HEAR_TOKENS := 0x02; // hear also speechtokens (only with ssopt.SeperateSpeechTokens) +const LISTENPT_NO_SPEECH := 0x04; // hear no normal speech (only with ssopt.SeperateSpeechTokens) // List[Statics/Items]* flags -const ITEMS_IGNORE_STATICS := 0x01; // Don't list Static Items -const ITEMS_IGNORE_MULTIS := 0x02; // Don't list Multi Items +const ITEMS_IGNORE_STATICS := 0x01; // Don't list Static Items +const ITEMS_IGNORE_MULTIS := 0x02; // Don't list Multi Items // special value for List[Items/Mobiles/Statics]* -const LIST_IGNORE_Z := 0x40000000; // Ignore Z-Value and list everything +const LIST_IGNORE_Z := 0x40000000; // Ignore Z-Value and list everything -// ListMobilesNearLocationEx exclusions -const LISTEX_FLAG_NORMAL := 0x01; -const LISTEX_FLAG_HIDDEN := 0x02; -const LISTEX_FLAG_GHOST := 0x04; -const LISTEX_FLAG_CONCEALED := 0x08; +// ListMobilesNearLocationEx exclusions +const LISTEX_FLAG_NORMAL := 0x01; +const LISTEX_FLAG_HIDDEN := 0x02; +const LISTEX_FLAG_GHOST := 0x04; +const LISTEX_FLAG_CONCEALED := 0x08; const LISTEX_FLAG_PLAYERS_ONLY := 0x10; -const LISTEX_FLAG_NPC_ONLY := 0x20; +const LISTEX_FLAG_NPC_ONLY := 0x20; // ListItemsNearLocationWithFlag( x,y,z, range, flags ); tiledata flags // Thanks to Alazane: http://dkbush.cablenet-va.com/alazane/file_formats.html#3.17 @@ -92,34 +93,33 @@ const TILEDATA_FLAG_STAIRBACK := 0x40000000; //StairBack const TILEDATA_FLAG_STAIRRIGHT := 0x80000000; //StairRight // GetStandingLayers( x, y, flags, realm := _DEFAULT_REALM, includeitems := 1 ); mapdata flags -const MAPDATA_FLAG_NONE := 0x0000; // Nothing -const MAPDATA_FLAG_MOVELAND := 0x0001; // Move Land -const MAPDATA_FLAG_MOVESEA := 0x0002; // Move Sea -const MAPDATA_FLAG_BLOCKSIGHT := 0x0004; // Block Sight -const MAPDATA_FLAG_OVERFLIGHT := 0x0008; // Over Flight (gargoyle flying) -const MAPDATA_FLAG_ALLOWDROPON := 0x0010; // Allow DropOn -const MAPDATA_FLAG_GRADUAL := 0x0020; // Gradual -const MAPDATA_FLAG_BLOCKING := 0x0040; // Blocking -const MAPDATA_FLAG_MORE_SOLIDS := 0x0080; // List more Solids +const MAPDATA_FLAG_NONE := 0x0000; // Nothing +const MAPDATA_FLAG_MOVELAND := 0x0001; // Move Land +const MAPDATA_FLAG_MOVESEA := 0x0002; // Move Sea +const MAPDATA_FLAG_BLOCKSIGHT := 0x0004; // Block Sight +const MAPDATA_FLAG_OVERFLIGHT := 0x0008; // Over Flight (gargoyle flying) +const MAPDATA_FLAG_ALLOWDROPON := 0x0010; // Allow DropOn +const MAPDATA_FLAG_GRADUAL := 0x0020; // Gradual +const MAPDATA_FLAG_BLOCKING := 0x0040; // Blocking +const MAPDATA_FLAG_MORE_SOLIDS := 0x0080; // List more Solids -const MAPDATA_FLAG_WALKBLOCK := 0x0057; // Move Land, Move Sea, Blocking, Block Sight, Allow DropOn -const MAPDATA_FLAG_MOVE_FLAGS := 0x0063; // Move Land, Move Sea, Blocking, Gradual -const MAPDATA_FLAG_DROP_FLAGS := 0x0050; // Blocking, Allow DropOn -const MAPDATA_FLAG_ALL := 0xffffffff; // All +const MAPDATA_FLAG_WALKBLOCK := 0x0057; // Move Land, Move Sea, Blocking, Block Sight, Allow DropOn +const MAPDATA_FLAG_MOVE_FLAGS := 0x0063; // Move Land, Move Sea, Blocking, Gradual +const MAPDATA_FLAG_DROP_FLAGS := 0x0050; // Blocking, Allow DropOn +const MAPDATA_FLAG_ALL := 0xffffffff; // All // // Constants for MoveObjectToLocation // -const MOVEOBJECT_NORMAL := 0x0; // Implicit. Will move if able. -const MOVEITEM_IGNOREMOVABLE := 0x20000000; // Will ignore the movable property on items. -const MOVEOBJECT_FORCELOCATION := 0x40000000; // Force Z location +const MOVEOBJECT_NORMAL := 0x0; // Implicit. Will move if able. +const MOVEITEM_IGNOREMOVABLE := 0x20000000; // Will ignore the movable property on items. +const MOVEOBJECT_FORCELOCATION := 0x40000000; // Force Z location // // Constants for PrintTextAbove* // -const JOURNAL_PRINT_NAME := 0x00; // Implicit. Print's the object's description / npc's name in the journal. -const JOURNAL_PRINT_YOU_SEE := 0x01; // Will print "You see:" in the journal. - +const JOURNAL_PRINT_NAME := 0x00; // Implicit. Print's the object's description / npc's name in the journal. +const JOURNAL_PRINT_YOU_SEE := 0x01; // Will print "You see:" in the journal. // Resurrect options const RESURRECT_FORCELOCATION := 0x01; @@ -131,16 +131,16 @@ const MOVETYPE_COREMOVE := 1; // Moved with MoveItem*() (or equiv) const MOVETYPE_CORECREATE := 2; // Created with CreateItemIn*() (or equiv) // InsertType constants for CanInsert/OnInsert scripts -const INSERT_ADD_ITEM := 1; -const INSERT_INCREASE_STACK := 2; +const INSERT_ADD_ITEM := 1; +const INSERT_INCREASE_STACK := 2; // DeleteBy constants for CanDelete script const DELETE_BY_PLAYER := 0; const DELETE_BY_SCRIPT := 1; // EnumerateItemsInContainer constants -const ENUMERATE_IGNORE_LOCKED := 0x1; // List content of locked container. -const ENUMERATE_ROOT_ONLY := 0x2; // Do not list contents of sub-containers. +const ENUMERATE_IGNORE_LOCKED := 0x1; // List content of locked container. +const ENUMERATE_ROOT_ONLY := 0x2; // Do not list contents of sub-containers. // FindObjtypeInContainer constants const FINDOBJTYPE_RECURSIVE := 0x0; // Search in sub-containers (DEFAULT). @@ -152,48 +152,46 @@ const FINDSUBSTANCE_IGNORE_LOCKED := 0x1; // Find matches in locked containers const FINDSUBSTANCE_ROOT_ONLY := 0x2; // Do not find matches in sub-containers. const FINDSUBSTANCE_FIND_ALL := 0x4; // Find all matches ignoring given amount -// SendTextEntryGump options +// SendTextEntryGump options const TE_CANCEL_DISABLE := 0; const TE_CANCEL_ENABLE := 1; -const TE_STYLE_DISABLE := 0; -const TE_STYLE_NORMAL := 1; -const TE_STYLE_NUMERICAL:= 2; +const TE_STYLE_DISABLE := 0; +const TE_STYLE_NORMAL := 1; +const TE_STYLE_NUMERICAL := 2; - -// SystemFindObjectBySerial options: +// SystemFindObjectBySerial options: const SYSFIND_SEARCH_OFFLINE_MOBILES := 1; - -// Target Options - add these together and pass as second -// param to Target() +// Target Options - add these together and pass as second +// param to Target() const TGTOPT_CHECK_LOS := 0x0001; -const TGTOPT_NOCHECK_LOS := 0x0000; // to be explicit +const TGTOPT_NOCHECK_LOS := 0x0000; // to be explicit const TGTOPT_HARMFUL := 0x0002; -const TGTOPT_NEUTRAL := 0x0000; // to be explicit +const TGTOPT_NEUTRAL := 0x0000; // to be explicit const TGTOPT_HELPFUL := 0x0004; const TGTOPT_ALLOW_NONLOCAL := 0x0008; // POLCLASS_* constants - use with obj.isa(POLCLASS_*) -const POLCLASS_UOBJECT := 1; -const POLCLASS_ITEM := 2; -const POLCLASS_MOBILE := 3; -const POLCLASS_NPC := 4; -const POLCLASS_LOCKABLE := 5; -const POLCLASS_CONTAINER := 6; -const POLCLASS_CORPSE := 7; -const POLCLASS_DOOR := 8; -const POLCLASS_SPELLBOOK := 9; -const POLCLASS_MAP := 10; -const POLCLASS_MULTI := 11; -const POLCLASS_BOAT := 12; -const POLCLASS_HOUSE := 13; -const POLCLASS_EQUIPMENT := 14; -const POLCLASS_ARMOR := 15; -const POLCLASS_WEAPON := 16; +const POLCLASS_UOBJECT := 1; +const POLCLASS_ITEM := 2; +const POLCLASS_MOBILE := 3; +const POLCLASS_NPC := 4; +const POLCLASS_LOCKABLE := 5; +const POLCLASS_CONTAINER := 6; +const POLCLASS_CORPSE := 7; +const POLCLASS_DOOR := 8; +const POLCLASS_SPELLBOOK := 9; +const POLCLASS_MAP := 10; +const POLCLASS_MULTI := 11; +const POLCLASS_BOAT := 12; +const POLCLASS_HOUSE := 13; +const POLCLASS_EQUIPMENT := 14; +const POLCLASS_ARMOR := 15; +const POLCLASS_WEAPON := 16; // mobile.race constants const RACE_HUMAN := 0; @@ -202,20 +200,20 @@ const RACE_GARGOYLE := 2; // Don't use these outside this file, use FONT_* from client.inc // (and I don't know what for color) -const _DEFAULT_TEXT_FONT := 3; -const _DEFAULT_TEXT_COLOR := 1000; -const _DEFAULT_TEXT_REQUIREDCMD := 0; +const _DEFAULT_TEXT_FONT := 3; +const _DEFAULT_TEXT_COLOR := 1000; +const _DEFAULT_TEXT_REQUIREDCMD := 0; // Realms -const _DEFAULT_REALM := "britannia"; -const REALM_BRITANNIA := _DEFAULT_REALM; -const REALM_BRITANNIA_ALT := "britannia_alt"; -const REALM_ILSHENAR := "ilshenar"; -const REALM_MALAS := "malas"; -const REALM_TOKUNO := "tokuno"; -const REALM_TERMUR := "termur"; +const _DEFAULT_REALM := "britannia"; +const REALM_BRITANNIA := _DEFAULT_REALM; +const REALM_BRITANNIA_ALT := "britannia_alt"; +const REALM_ILSHENAR := "ilshenar"; +const REALM_MALAS := "malas"; +const REALM_TOKUNO := "tokuno"; +const REALM_TERMUR := "termur"; -//PerformAction +// PerformAction const ACTION_DIR_FORWARD := 0; const ACTION_DIR_BACKWARD := 1; const ACTION_NOREPEAT := 0; @@ -226,42 +224,43 @@ const EVMASK_ALL := 0; const EVMASK_ONLY_PC := 1; const EVMASK_ONLY_NPC := 2; -//CanWalk +// CanWalk const CANWALK_DIR := -1; -//UpdateMobile +// UpdateMobile const UPDATEMOBILE_RECREATE := 1; const UPDATEMOBILE_UPDATE := 0; -//CloseWindow +// CloseWindow const CLOSE_PAPERDOLL := 1; const CLOSE_STATUS := 2; const CLOSE_PROFILE := 8; const CLOSE_CONTAINER := 12; -//SendCharProfile +// SendCharProfile const CHARPROFILE_NO_UNEDITABLE_TEXT := ""; -const CHARPROFILE_NO_EDITABLE_TEXT := ""; +const CHARPROFILE_NO_EDITABLE_TEXT := ""; -//Accessible -const ACCESSIBLE_DEFAULT := -1; // uses the default from ssopt +// Accessible +const ACCESSIBLE_DEFAULT := -1; // uses the default from ssopt const ACCESSIBLE_IGNOREDISTANCE := -2; // ignores the range check +// format-on //////////////////////////////////////////////////////////////// // -// FUNCTIONS +// FUNCTIONS // //////////////////////////////////////////////////////////////// Accessible( by_character, item, range := ACCESSIBLE_DEFAULT ); AddAmount( item, amount ); -AddMenuItem( menu, objtype, text, color:=0 ); +AddMenuItem( menu, objtype, text, color := 0 ); ApplyConstraint( objlist, configfile, propertyname, minvalue ); AssignRectToWeatherRegion( region, xwest, ynorth, xeast, ysouth ); Attach( character ); Broadcast( text, font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEXT_COLOR, required_cmdlevel := _DEFAULT_TEXT_REQUIREDCMD ); CancelTarget( of_whom ); -CanWalk(movemode, x1, y1, z1, x2_or_dir, y2 := CANWALK_DIR, realm := _DEFAULT_REALM); +CanWalk( movemode, x1, y1, z1, x2_or_dir, y2 := CANWALK_DIR, realm := _DEFAULT_REALM ); CheckLineOfSight( object1, object2 ); CheckLosAt( character, x, y, z ); CheckLosBetween( x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM ); @@ -270,25 +269,25 @@ CloseTradeWindow( character ); CloseWindow( character, type, object ); ConsumeReagents( who, spellid ); ConsumeSubstance( container, objtype, amount ); -CoordinateDistance(x1, y1, x2, y2); -CoordinateDistanceEuclidean(x1, y1, x2, y2); +CoordinateDistance( x1, y1, x2, y2 ); +CoordinateDistanceEuclidean( x1, y1, x2, y2 ); CreateAccount( acctname, password, enabled ); CreateItemAtLocation( x, y, z, objtype, amount := 1, realm := _DEFAULT_REALM ); -CreateItemCopyAtLocation(x, y, z, item, realm := _DEFAULT_REALM); +CreateItemCopyAtLocation( x, y, z, item, realm := _DEFAULT_REALM ); CreateItemInBackpack( of_character, objtype, amount := 1, x := -1, y := -1 ); CreateItemInContainer( container, objtype, amount := 1, x := -1, y := -1 ); CreateItemInInventory( container, objtype, amount := 1, x := -1, y := -1 ); CreateMenu( title ); CreateMultiAtLocation( x, y, z, objtype, flags := 0, realm := _DEFAULT_REALM ); -CreateNpcFromTemplate( template, x, y, z, override_properties := 0, realm := _DEFAULT_REALM, forcelocation := 0); +CreateNpcFromTemplate( template, x, y, z, override_properties := 0, realm := _DEFAULT_REALM, forcelocation := 0 ); DestroyItem( item ); DestroyMulti( multi ); Detach(); -DisableEvents( eventtype ); // eventtype combination of constants from SYSEVENT.INC +DisableEvents( eventtype ); // eventtype combination of constants from SYSEVENT.INC DisconnectClient( character ); Distance( obj1, obj2 ); DistanceEuclidean( obj1, obj2 ); -EnableEvents( eventtype, range := -1, evmask := EVMASK_ALL ); // eventtype combination of constants from SYSEVENT.INC +EnableEvents( eventtype, range := -1, evmask := EVMASK_ALL ); // eventtype combination of constants from SYSEVENT.INC EnumerateItemsInContainer( container, flags := 0 ); EnumerateOnlineCharacters(); EquipFromTemplate( character, template ); // reads from equip.cfg @@ -301,9 +300,9 @@ FindPath( x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM, flags := FP_IGNORE_MO FindSubstance( container, objtype, amount, makeinuse := 0, flags := 0 ); GetAmount( item ); GetCommandHelp( character, command ); -GetCoordsInLine(x1, y1, x2, y2); +GetCoordsInLine( x1, y1, x2, y2 ); GetEquipmentByLayer( character, layer ); -GetFacing(from_x, from_y, to_x, to_y); +GetFacing( from_x, from_y, to_x, to_y ); GetGlobalProperty( propname ); GetGlobalPropertyNames(); GetHarvestDifficulty( resource, x, y, tiletype, realm := _DEFAULT_REALM ); @@ -321,33 +320,33 @@ GetRegionString( resource, x, y, propertyname, realm := _DEFAULT_REALM ); GetSpellDifficulty( spellid ); GetStandingHeight( x, y, startz, realm := _DEFAULT_REALM ); GetStandingLayers( x, y, flags := MAPDATA_FLAG_ALL, realm := _DEFAULT_REALM, includeitems := 1 ); -GetStandingCoordinates( x, y, radius := 0, minz := -128, maxz := 127, realm := _DEFAULT_REALM, movemode := "L", doors_block := 0); +GetStandingCoordinates( x, y, radius := 0, minz := -128, maxz := 127, realm := _DEFAULT_REALM, movemode := "L", doors_block := 0 ); GetWorldHeight( x, y, realm := _DEFAULT_REALM ); GrantPrivilege( character, privilege ); HarvestResource( resource, x, y, b, n, realm := _DEFAULT_REALM ); // returns b*a where 0 <= a <= n IsStackable( item1, item2 ); // checks if items can stack -ListAccounts( ); +ListAccounts(); ListEquippedItems( who ); ListGhostsNearLocation( x, y, z, range, realm := _DEFAULT_REALM ); ListHostiles( character, range := 20, flags := 0 ); ListItemsAtLocation( x, y, z, realm := _DEFAULT_REALM ); -ListItemsInBoxOfObjType( objtype, x1,y1,z1, x2,y2,z2, realm := _DEFAULT_REALM ); +ListItemsInBoxOfObjType( objtype, x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM ); ListItemsNearLocation( x, y, z, range, realm := _DEFAULT_REALM ); -ListItemsNearLocationOfType( x,y,z, range, objtype, realm := _DEFAULT_REALM ); -ListItemsNearLocationWithFlag( x,y,z, range, flags, realm := _DEFAULT_REALM ); +ListItemsNearLocationOfType( x, y, z, range, objtype, realm := _DEFAULT_REALM ); +ListItemsNearLocationWithFlag( x, y, z, range, flags, realm := _DEFAULT_REALM ); ListMobilesInLineOfSight( object, range ); ListMobilesNearLocation( x, y, z, range, realm := _DEFAULT_REALM ); -ListMobilesNearLocationEx( x,y,z, range, flags, realm := _DEFAULT_REALM ); -ListMultisInBox( x1,y1,z1, x2,y2,z2, realm := _DEFAULT_REALM ); -ListMobilesInBox( x1,y1,z1, x2,y2,z2, realm := _DEFAULT_REALM ); -ListObjectsInBox( x1,y1,z1, x2,y2,z2, realm := _DEFAULT_REALM ); +ListMobilesNearLocationEx( x, y, z, range, flags, realm := _DEFAULT_REALM ); +ListMultisInBox( x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM ); +ListMobilesInBox( x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM ); +ListObjectsInBox( x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM ); ListObjectsInBoxOfClass( POL_Class, x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM ); -ListOfflineMobilesInRealm(realm := _DEFAULT_REALM); +ListOfflineMobilesInRealm( realm := _DEFAULT_REALM ); ListStaticsAtLocation( x, y, z, flags := 0, realm := _DEFAULT_REALM ); -ListStaticsInBox( x1,y1,z1, x2,y2,z2, flags := 0, realm := _DEFAULT_REALM ); +ListStaticsInBox( x1, y1, z1, x2, y2, z2, flags := 0, realm := _DEFAULT_REALM ); ListStaticsNearLocation( x, y, z, range, flags := 0, realm := _DEFAULT_REALM ); -ListStaticsNearLocationOfType( x,y,z, range, objtype, flags := 0, realm := _DEFAULT_REALM ); -ListStaticsNearLocationWithFlag( x,y,z, range, flags, realm := _DEFAULT_REALM ); +ListStaticsNearLocationOfType( x, y, z, range, objtype, flags := 0, realm := _DEFAULT_REALM ); +ListStaticsNearLocationWithFlag( x, y, z, range, flags, realm := _DEFAULT_REALM ); MoveItemToContainer( item, container, x := -1, y := -1, add_to_existing_stack := 0 ); MoveItemToSecureTradeWin( item, character ); MoveObjectToLocation( object, x, y, z, realm := _DEFAULT_REALM, flags := MOVEOBJECT_NORMAL ); @@ -404,7 +403,7 @@ SetGlobalProperty( propname, propval ); SetName( object, name ); SetObjProperty( object, property_name, property_value ); SetRegionLightLevel( regionname, lightlevel ); -SetRegionWeatherLevel( region, type, severity, aux := 0, lightoverride := -1); +SetRegionWeatherLevel( region, type, severity, aux := 0, lightoverride := -1 ); SetScriptController( who ); SingleClick( who, what ); Shutdown( exit_code := 0 ); @@ -412,11 +411,11 @@ SpeakPowerWords( who, spellid, font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEX StartSpellEffect( who, spellid ); SubtractAmount( item, amount ); SystemFindObjectBySerial( serial, sysfind_flags := 0 ); -Target( by_character, options := TGTOPT_CHECK_LOS+TGTOPT_NEUTRAL); +Target( by_character, options := TGTOPT_CHECK_LOS + TGTOPT_NEUTRAL ); TargetCoordinates( by_character ); TargetMultiPlacement( character, objtype, flags := 0, xoffset := 0, yoffset := 0, hue := 0 ); UpdateItem( item ); UpdateMobile( mobile, recreate := UPDATEMOBILE_UPDATE ); -UseItem(item, character); +UseItem( item, character ); POLCore(); -GetMidpointCircleCoords(xcenter, ycenter, radius); +GetMidpointCircleCoords( xcenter, ycenter, radius ); diff --git a/pol-core/support/scripts/util.em b/pol-core/support/scripts/util.em index a07bed6b5..5b0bd2c73 100644 --- a/pol-core/support/scripts/util.em +++ b/pol-core/support/scripts/util.em @@ -1,6 +1,6 @@ -RandomInt( below_this_number ); // returns integer R such that 0 <= R < B -RandomIntMinMax( minValue, maxValue); // returns integer R such that minValue<=R= 0 -RandomDiceRoll( dice_string ); +RandomDiceRoll( dice_string ); -StrFormatTime(format_string, time_stamp:=0); +StrFormatTime( format_string, time_stamp := 0 ); diff --git a/pol-core/support/scripts/vitals.em b/pol-core/support/scripts/vitals.em index 4f4b31205..2f98255f3 100644 --- a/pol-core/support/scripts/vitals.em +++ b/pol-core/support/scripts/vitals.em @@ -1,16 +1,18 @@ -//Apply*Damage constants +// format-off +// Apply*Damage constants const DAMAGE_USE_REPSYS := 1; -const DAMAGE_NO_REPSYS := 0; +const DAMAGE_NO_REPSYS := 0; -const DAMAGE_NO_SHOW := 0; -const DAMAGE_SHOW := 1; +const DAMAGE_NO_SHOW := 0; +const DAMAGE_SHOW := 1; const DAMAGE_USE_DEFAULT := 2; -//RecalcVital constants +// RecalcVital constants const RECALC_INTRINSIC_MOD := 1; const RECALC_NO_INTRINSIC_MOD := 0; const RECALC_VITALS := 1; const RECALC_NO_VITALS := 0; +// format-on // // Vital related functions diff --git a/testsuite/escript/_dbg/dbg001.src b/testsuite/escript/_dbg/dbg001.src index 9027d530d..4440d56dd 100644 --- a/testsuite/escript/_dbg/dbg001.src +++ b/testsuite/escript/_dbg/dbg001.src @@ -1,13 +1,11 @@ var x; x := 2; -if (x > 3) - var a; - a := 6; +if ( x > 3 ) + var a; + a := 6; else - var b; - b := 7; - var a; - a := 8; + var b; + b := 7; + var a; + a := 8; endif - - \ No newline at end of file diff --git a/testsuite/escript/_dbg/dbg002.src b/testsuite/escript/_dbg/dbg002.src index ea364b358..bc1ce6427 100644 --- a/testsuite/escript/_dbg/dbg002.src +++ b/testsuite/escript/_dbg/dbg002.src @@ -1,14 +1,14 @@ function fooa() - var a; - a := 2; - return a; + var a; + a := 2; + return a; endfunction function foob() - var b; - b := 4; - return b; + var b; + b := 4; + return b; endfunction fooa(); -foob(); \ No newline at end of file +foob(); diff --git a/testsuite/escript/_dbg/dbg003.src b/testsuite/escript/_dbg/dbg003.src index 159394ae1..53321fa10 100644 --- a/testsuite/escript/_dbg/dbg003.src +++ b/testsuite/escript/_dbg/dbg003.src @@ -1,19 +1,19 @@ function fooa() - var a; - a := 2; - return a; + var a; + a := 2; + return a; endfunction function foob() - var b; - b := 4; - if (b) - var x; - x := 2; - return x; - endif - return b; + var b; + b := 4; + if ( b ) + var x; + x := 2; + return x; + endif + return b; endfunction fooa(); -foob(); \ No newline at end of file +foob(); diff --git a/testsuite/escript/_dbg/dbg004.src b/testsuite/escript/_dbg/dbg004.src index 31afd885c..6fd3fd0be 100644 --- a/testsuite/escript/_dbg/dbg004.src +++ b/testsuite/escript/_dbg/dbg004.src @@ -1,26 +1,26 @@ var a; function fooa() - var a; - a := 2; - return a; + var a; + a := 2; + return a; endfunction function foob() - var b; - b := 4; - if (b) - var x; - x := 2; - return x; - endif - return b; + var b; + b := 4; + if ( b ) + var x; + x := 2; + return x; + endif + return b; endfunction var c; -if (a) - var d; +if ( a ) + var d; endif fooa(); -foob(); \ No newline at end of file +foob(); diff --git a/testsuite/escript/_dbg/dbg005.src b/testsuite/escript/_dbg/dbg005.src index 3e98e4e38..daf77d3f7 100644 --- a/testsuite/escript/_dbg/dbg005.src +++ b/testsuite/escript/_dbg/dbg005.src @@ -1,11 +1,11 @@ var a; function foo() - var b; - foreach c in a - var x; - endforeach - var d; + var b; + foreach c in a + var x; + endforeach + var d; endfunction foo(); diff --git a/testsuite/escript/_dbg/dbg006.src b/testsuite/escript/_dbg/dbg006.src index 753575843..95200b15d 100644 --- a/testsuite/escript/_dbg/dbg006.src +++ b/testsuite/escript/_dbg/dbg006.src @@ -1,16 +1,16 @@ var a; function foo() - foreach c in a - var x; - endforeach - if (a) - // var d; - endif - var e; - while(1) - e := a; - endwhile + foreach c in a + var x; + endforeach + if ( a ) + // var d; + endif + var e; + while ( 1 ) + e := a; + endwhile endfunction foo(); diff --git a/testsuite/escript/_dbg/dbg007.src b/testsuite/escript/_dbg/dbg007.src index 35129f508..2e484d7e3 100644 --- a/testsuite/escript/_dbg/dbg007.src +++ b/testsuite/escript/_dbg/dbg007.src @@ -1,10 +1,10 @@ -var a,b,c; -if (a) - b := 2; -elseif (b) - c := 3; -elseif (c) - a := 4; +var a, b, c; +if ( a ) + b := 2; +elseif ( b ) + c := 3; +elseif ( c ) + a := 4; endif c := 2; diff --git a/testsuite/escript/_perf/perf.inc b/testsuite/escript/_perf/perf.inc index 838587208..19c421dd8 100644 --- a/testsuite/escript/_perf/perf.inc +++ b/testsuite/escript/_perf/perf.inc @@ -3,11 +3,10 @@ const PERF_ARRAY_SIZE := 5000000; var arr := array; function setup() - arr[1] := 1; - arr[PERF_ARRAY_SIZE] := 1; + arr[1] := 1; + arr[PERF_ARRAY_SIZE] := 1; - for i := 1 to PERF_ARRAY_SIZE - arr[i] := i+2007; - endfor + for i := 1 to PERF_ARRAY_SIZE + arr[i] := i + 2007; + endfor endfunction - diff --git a/testsuite/escript/_perf/perf001.src b/testsuite/escript/_perf/perf001.src index c97d5f1a5..e5934b349 100644 --- a/testsuite/escript/_perf/perf001.src +++ b/testsuite/escript/_perf/perf001.src @@ -4,7 +4,7 @@ arr[1] := 1; arr[10000] := 1000; var i; -for( i := 1; i <= 10000; i := i + 1 ) - arr[i] := i; +for ( i := 1; i <= 10000; i := i + 1 ) + arr[i] := i; endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf001f.src b/testsuite/escript/_perf/perf001f.src index a0c08d438..1758c6c43 100644 --- a/testsuite/escript/_perf/perf001f.src +++ b/testsuite/escript/_perf/perf001f.src @@ -4,7 +4,7 @@ arr[1] := 1; arr[10000] := 1000; var i; -for( i := 1; i <= 10000; i += 1 ) - arr[i] := i; +for ( i := 1; i <= 10000; i += 1 ) + arr[i] := i; endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf002.src b/testsuite/escript/_perf/perf002.src index de889e35e..90bbbb01d 100644 --- a/testsuite/escript/_perf/perf002.src +++ b/testsuite/escript/_perf/perf002.src @@ -5,8 +5,8 @@ arr[10000] := 1000; var wi := 1; foreach i in arr - i := wi; - wi := wi + 1; + i := wi; + wi := wi + 1; endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf002f.src b/testsuite/escript/_perf/perf002f.src index d152da0c5..b73b7e136 100644 --- a/testsuite/escript/_perf/perf002f.src +++ b/testsuite/escript/_perf/perf002f.src @@ -5,8 +5,8 @@ arr[10000] := 1000; var wi := 1; foreach i in arr - i := wi; - wi += 1; + i := wi; + wi += 1; endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf003.src b/testsuite/escript/_perf/perf003.src index ec7682a06..7a45c221f 100644 --- a/testsuite/escript/_perf/perf003.src +++ b/testsuite/escript/_perf/perf003.src @@ -4,8 +4,8 @@ include "perf"; setup(); var i, x := 0; -for( i := 1; i <= PERF_ARRAY_SIZE; i := i + 1 ) - x := x + i; +for ( i := 1; i <= PERF_ARRAY_SIZE; i := i + 1 ) + x := x + i; endfor print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf003a.src b/testsuite/escript/_perf/perf003a.src index 0f5c69c8f..7da3bffeb 100644 --- a/testsuite/escript/_perf/perf003a.src +++ b/testsuite/escript/_perf/perf003a.src @@ -4,8 +4,8 @@ include "perf"; setup(); var i, x := 0; -for( i := 1; i <= PERF_ARRAY_SIZE; i := i + 1 ) - x := x + arr[i]; +for ( i := 1; i <= PERF_ARRAY_SIZE; i := i + 1 ) + x := x + arr[i]; endfor print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf003af.src b/testsuite/escript/_perf/perf003af.src index f328d1b82..38db66024 100644 --- a/testsuite/escript/_perf/perf003af.src +++ b/testsuite/escript/_perf/perf003af.src @@ -4,8 +4,8 @@ include "perf"; setup(); var i, x := 0; -for( i := 1; i <= PERF_ARRAY_SIZE; i += 1 ) - x += arr[i]; +for ( i := 1; i <= PERF_ARRAY_SIZE; i += 1 ) + x += arr[i]; endfor print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf003b.src b/testsuite/escript/_perf/perf003b.src index fd3874e06..2dc29117c 100644 --- a/testsuite/escript/_perf/perf003b.src +++ b/testsuite/escript/_perf/perf003b.src @@ -5,7 +5,7 @@ setup(); var x := 0; foreach i in arr - x := x + i; + x := x + i; endforeach print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf003bf.src b/testsuite/escript/_perf/perf003bf.src index e631d5c79..60327fd93 100644 --- a/testsuite/escript/_perf/perf003bf.src +++ b/testsuite/escript/_perf/perf003bf.src @@ -5,7 +5,7 @@ setup(); var x := 0; foreach i in arr - x += i; + x += i; endforeach print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf003f.src b/testsuite/escript/_perf/perf003f.src index 0a648f1b4..6d0b945af 100644 --- a/testsuite/escript/_perf/perf003f.src +++ b/testsuite/escript/_perf/perf003f.src @@ -4,8 +4,8 @@ include "perf"; setup(); var i, x := 0; -for( i := 1; i <= PERF_ARRAY_SIZE; i += 1 ) - x += i; +for ( i := 1; i <= PERF_ARRAY_SIZE; i += 1 ) + x += i; endfor print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf004.src b/testsuite/escript/_perf/perf004.src index fd3874e06..2dc29117c 100644 --- a/testsuite/escript/_perf/perf004.src +++ b/testsuite/escript/_perf/perf004.src @@ -5,7 +5,7 @@ setup(); var x := 0; foreach i in arr - x := x + i; + x := x + i; endforeach print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf004f.src b/testsuite/escript/_perf/perf004f.src index e631d5c79..60327fd93 100644 --- a/testsuite/escript/_perf/perf004f.src +++ b/testsuite/escript/_perf/perf004f.src @@ -5,7 +5,7 @@ setup(); var x := 0; foreach i in arr - x += i; + x += i; endforeach print( "X=" + x ); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf005a.src b/testsuite/escript/_perf/perf005a.src index 54226ec16..e85a5b3cc 100644 --- a/testsuite/escript/_perf/perf005a.src +++ b/testsuite/escript/_perf/perf005a.src @@ -6,7 +6,7 @@ setup(); var x; foreach elem in arr - x := elem; + x := elem; endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf005b.src b/testsuite/escript/_perf/perf005b.src index 62e03f0be..7c0056395 100644 --- a/testsuite/escript/_perf/perf005b.src +++ b/testsuite/escript/_perf/perf005b.src @@ -6,15 +6,15 @@ setup(); var x; foreach elem in arr - if (elem == 5) - x := elem; - elseif (elem == 37) - x := elem; - elseif (elem == 40) - x := elem; - else - x := elem; - endif + if ( elem == 5 ) + x := elem; + elseif ( elem == 37 ) + x := elem; + elseif ( elem == 40 ) + x := elem; + else + x := elem; + endif endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf005c.src b/testsuite/escript/_perf/perf005c.src index 41dfa5a25..836732e99 100644 --- a/testsuite/escript/_perf/perf005c.src +++ b/testsuite/escript/_perf/perf005c.src @@ -6,12 +6,12 @@ setup(); var x; foreach elem in arr - case (elem) - 5: x := elem; - 37: x := elem; - 40: x := elem; - default: x := elem; - endcase + case ( elem ) + 5: x := elem; + 37: x := elem; + 40: x := elem; + default: x := elem; + endcase endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/_perf/perf006.src b/testsuite/escript/_perf/perf006.src index 6e27d0937..52e5a79ab 100644 --- a/testsuite/escript/_perf/perf006.src +++ b/testsuite/escript/_perf/perf006.src @@ -1,20 +1,20 @@ include "perf"; var n := PERF_ARRAY_SIZE; -var a,b,c,d,t; +var a, b, c, d, t; a := 7.6; b := 2.3; c := 5; d := 8; -while( n ) - t := a-b; - t := a+c; - t := c+d; - d := c+b; - if (d < c) - t := a; - else - t := c; - endif - n := n - 1; -endwhile \ No newline at end of file +while ( n ) + t := a - b; + t := a + c; + t := c + d; + d := c + b; + if ( d < c ) + t := a; + else + t := c; + endif + n := n - 1; +endwhile diff --git a/testsuite/escript/_perf/perf007.src b/testsuite/escript/_perf/perf007.src index dcc4b4fa1..ae952a877 100644 --- a/testsuite/escript/_perf/perf007.src +++ b/testsuite/escript/_perf/perf007.src @@ -1,20 +1,20 @@ include "perf"; var n := PERF_ARRAY_SIZE; -var a,b,c,d,t; +var a, b, c, d, t; a := 7; b := 2; c := 5; d := 8; -while( n ) - t := a-b; - t := a+c; - t := c+d; - d := c+b; - if (d < c) - t := a; - else - t := c; - endif - n := n - 1; -endwhile \ No newline at end of file +while ( n ) + t := a - b; + t := a + c; + t := c + d; + d := c + b; + if ( d < c ) + t := a; + else + t := c; + endif + n := n - 1; +endwhile diff --git a/testsuite/escript/_perf/perf008.src b/testsuite/escript/_perf/perf008.src index 90d1359aa..7aa454185 100644 --- a/testsuite/escript/_perf/perf008.src +++ b/testsuite/escript/_perf/perf008.src @@ -1,19 +1,19 @@ var n := 10000; -var a,b,c,d,t; +var a, b, c, d, t; a := 7; b := 2; c := 5; d := 8; -while( n ) - t := a-b; - t := a+c; - t := c+d; - d := c+b; - if (d < c) - t := a; - else - t := c; - endif - n := n - 1; -endwhile \ No newline at end of file +while ( n ) + t := a - b; + t := a + c; + t := c + d; + d := c + b; + if ( d < c ) + t := a; + else + t := c; + endif + n := n - 1; +endwhile diff --git a/testsuite/escript/_perf/perfsetup.src b/testsuite/escript/_perf/perfsetup.src index 3bc0f7e3d..2fede97f5 100644 --- a/testsuite/escript/_perf/perfsetup.src +++ b/testsuite/escript/_perf/perfsetup.src @@ -7,4 +7,4 @@ include "perf"; setup(); -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/arg/arg001-nonexistent-parameter.err b/testsuite/escript/arg/arg001-nonexistent-parameter.err index 69a53f592..593e6be8e 100644 --- a/testsuite/escript/arg/arg001-nonexistent-parameter.err +++ b/testsuite/escript/arg/arg001-nonexistent-parameter.err @@ -1 +1 @@ -arg001-nonexistent-parameter.src:5:13: error: In call to 'foo': Parameter 'baz' passed by name, but the function has no such parameter. \ No newline at end of file +:5:13: error: In call to 'foo': Parameter 'baz' passed by name, but the function has no such parameter. \ No newline at end of file diff --git a/testsuite/escript/arg/arg001-nonexistent-parameter.src b/testsuite/escript/arg/arg001-nonexistent-parameter.src index 34e59214a..7454790ee 100644 --- a/testsuite/escript/arg/arg001-nonexistent-parameter.src +++ b/testsuite/escript/arg/arg001-nonexistent-parameter.src @@ -1,5 +1,5 @@ function foo( bar := "a" ) - print( bar ); + print( bar ); endfunction foo( baz := "b" ); diff --git a/testsuite/escript/arg/arg002-too-many-arguments.err b/testsuite/escript/arg/arg002-too-many-arguments.err index 684b3d4b5..7057a39c0 100644 --- a/testsuite/escript/arg/arg002-too-many-arguments.err +++ b/testsuite/escript/arg/arg002-too-many-arguments.err @@ -1 +1 @@ -arg002-too-many-arguments.src:4:39: error: In call to 'SendSysMessage': Too many arguments passed. Expected 4, got 5. \ No newline at end of file +:4:38: error: In call to 'SendSysMessage': Too many arguments passed. Expected 4, got 5. \ No newline at end of file diff --git a/testsuite/escript/arg/arg002-too-many-arguments.src b/testsuite/escript/arg/arg002-too-many-arguments.src index a8d2ac807..ec905f0ef 100644 --- a/testsuite/escript/arg/arg002-too-many-arguments.src +++ b/testsuite/escript/arg/arg002-too-many-arguments.src @@ -1,5 +1,5 @@ use uo; -program test_ecompile(who) - SendSysMessage(who, "text", 0, 1, 1); // too many params for SendSysMessage +program test_ecompile( who ) + SendSysMessage( who, "text", 0, 1, 1 ); // too many params for SendSysMessage endprogram diff --git a/testsuite/escript/array/array01.src b/testsuite/escript/array/array01.src index fd6d24451..4585be9da 100644 --- a/testsuite/escript/array/array01.src +++ b/testsuite/escript/array/array01.src @@ -5,4 +5,3 @@ a[4] := "world"; print( a[1] ); print( a[4] ); - diff --git a/testsuite/escript/array/array02.src b/testsuite/escript/array/array02.src index 652fa9e3e..15847dfe0 100644 --- a/testsuite/escript/array/array02.src +++ b/testsuite/escript/array/array02.src @@ -9,4 +9,3 @@ print( a[4] ); a[4] := "hey"; print( a[1] ); print( a[4] ); - diff --git a/testsuite/escript/array/array03.src b/testsuite/escript/array/array03.src index 906dd005b..236ba7edc 100644 --- a/testsuite/escript/array/array03.src +++ b/testsuite/escript/array/array03.src @@ -3,27 +3,27 @@ var a array; a[1] := "hello"; a[4] := "world"; -print( a[1]); -print( a[4]); +print( a[1] ); +print( a[4] ); a[4] := "hey"; -print( a[1]); -print( a[4]); +print( a[1] ); +print( a[4] ); var b; b := a; -print( "b created, initialized"); -print( a[1]); -print( a[4]); -print( b[1]); -print( b[4]); +print( "b created, initialized" ); +print( a[1] ); +print( a[4] ); +print( b[1] ); +print( b[4] ); a[1] := "changed a"; -print( "a modified"); -print( a[1]); -print( a[4]); -print( b[1]); -print( b[4]); +print( "a modified" ); +print( a[1] ); +print( a[4] ); +print( b[1] ); +print( b[4] ); diff --git a/testsuite/escript/array/array04.src b/testsuite/escript/array/array04.src index c7e90243d..53dcc079c 100644 --- a/testsuite/escript/array/array04.src +++ b/testsuite/escript/array/array04.src @@ -1,10 +1,10 @@ var a array; a[1] := "hello"; -print( len(a)); +print( len( a ) ); a[4] := "world"; -print( len(a)); +print( len( a ) ); a[2] := "there"; -print( len(a)); \ No newline at end of file +print( len( a ) ); diff --git a/testsuite/escript/array/array05.src b/testsuite/escript/array/array05.src index f2ecd12f6..d6dd780d7 100644 --- a/testsuite/escript/array/array05.src +++ b/testsuite/escript/array/array05.src @@ -1,11 +1,11 @@ program test() - var a := array; + var a := array; - a[1] := "hello"; - a[4] := "world"; + a[1] := "hello"; + a[4] := "world"; - print( a[1] ); - print( a[4] ); + print( a[1] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/array/array06.src b/testsuite/escript/array/array06.src index 4bfb09136..dce0f7c39 100644 --- a/testsuite/escript/array/array06.src +++ b/testsuite/escript/array/array06.src @@ -1,11 +1,11 @@ program test() - var a := array(); + var a := array(); - a[1] := "hello"; - a[4] := "world"; + a[1] := "hello"; + a[4] := "world"; - print( a[1] ); - print( a[4] ); + print( a[1] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/array/array07.src b/testsuite/escript/array/array07.src index 54dbf5cdd..8ff5c8675 100644 --- a/testsuite/escript/array/array07.src +++ b/testsuite/escript/array/array07.src @@ -1,12 +1,12 @@ program test() - var a := array(1); + var a := array( 1 ); - a[2] := "hello"; - a[4] := "world"; + a[2] := "hello"; + a[4] := "world"; - print( a[1] ); - print( a[2] ); - print( a[4] ); + print( a[1] ); + print( a[2] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/array/array08.src b/testsuite/escript/array/array08.src index d5b822c8d..6114e584f 100644 --- a/testsuite/escript/array/array08.src +++ b/testsuite/escript/array/array08.src @@ -1,10 +1,10 @@ program test() - var a := array(1,5,8,12); + var a := array( 1, 5, 8, 12 ); - print( a[1] ); - print( a[2] ); - print( a[3] ); - print( a[4] ); + print( a[1] ); + print( a[2] ); + print( a[3] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/array/array09.src b/testsuite/escript/array/array09.src index 737f3917f..286851489 100644 --- a/testsuite/escript/array/array09.src +++ b/testsuite/escript/array/array09.src @@ -1,7 +1,7 @@ program test() - foreach i in array( 1,12,3,32,57 ) - print( i ); - endforeach + foreach i in array( 1, 12, 3, 32, 57 ) + print( i ); + endforeach endprogram /**** Expected Output Begins: ***** diff --git a/testsuite/escript/array/array10.src b/testsuite/escript/array/array10.src index a7cd41c44..a54538fd4 100644 --- a/testsuite/escript/array/array10.src +++ b/testsuite/escript/array/array10.src @@ -1,4 +1,4 @@ -var a1 := { 1,2,3,4 }; -var a2 := { 1,2,3,4,5 }; +var a1 := { 1, 2, 3, 4 }; +var a2 := { 1, 2, 3, 4, 5 }; -print (a1 == a2 ); +print( a1 == a2 ); diff --git a/testsuite/escript/array/array11.src b/testsuite/escript/array/array11.src index 9371c4607..1450aa2c9 100644 --- a/testsuite/escript/array/array11.src +++ b/testsuite/escript/array/array11.src @@ -1,4 +1,4 @@ -var a1 := { 1,3,8,4 }; -var a2 := { 1,3,8,4 }; +var a1 := { 1, 3, 8, 4 }; +var a2 := { 1, 3, 8, 4 }; -print (a1 == a2); +print( a1 == a2 ); diff --git a/testsuite/escript/array/array12.src b/testsuite/escript/array/array12.src index 42db43b27..f6e9efe38 100644 --- a/testsuite/escript/array/array12.src +++ b/testsuite/escript/array/array12.src @@ -1,11 +1,11 @@ function foo( byref elem ) - print( elem ); - elem := 12; + print( elem ); + elem := 12; endfunction program array12() - var a := { 82, 43, 56, 23, 51 }; - print(a); - foo( a[2] ); - print(a); -endprogram \ No newline at end of file + var a := { 82, 43, 56, 23, 51 }; + print( a ); + foo( a[2] ); + print( a ); +endprogram diff --git a/testsuite/escript/array/array13.src b/testsuite/escript/array/array13.src index 27ea47fb5..8cafd0c30 100644 --- a/testsuite/escript/array/array13.src +++ b/testsuite/escript/array/array13.src @@ -1,10 +1,10 @@ program test() - var a := array { 1, 5, 8, 12 }; + var a := array{ 1, 5, 8, 12 }; - print( a[1] ); - print( a[2] ); - print( a[3] ); - print( a[4] ); + print( a[1] ); + print( a[2] ); + print( a[3] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/array/array14.err b/testsuite/escript/array/array14.err index 646106f92..c895e7b42 100644 --- a/testsuite/escript/array/array14.err +++ b/testsuite/escript/array/array14.err @@ -1 +1 @@ -Expected expression following comma before right-brace in array initializer list \ No newline at end of file +:1:25: error: Expected expression following comma before right-brace in array initializer list \ No newline at end of file diff --git a/testsuite/escript/array/array15.src b/testsuite/escript/array/array15.src index 61bafb81f..9eed156ff 100644 --- a/testsuite/escript/array/array15.src +++ b/testsuite/escript/array/array15.src @@ -1,4 +1,4 @@ -var x := array { 4, 3 }; -var y := array { 5, 2, 3 }; +var x := array{ 4, 3 }; +var y := array{ 5, 2, 3 }; var z := x + y; -print(z); +print( z ); diff --git a/testsuite/escript/array/array16.src b/testsuite/escript/array/array16.src index c190b242d..eeef6bca4 100644 --- a/testsuite/escript/array/array16.src +++ b/testsuite/escript/array/array16.src @@ -1,7 +1,7 @@ -var x := array { 4, 3 }; +var x := array{ 4, 3 }; var y := array; y[4] := 6; var z := x + y; -print(x); -print(y); -print(z); +print( x ); +print( y ); +print( z ); diff --git a/testsuite/escript/array/array17.src b/testsuite/escript/array/array17.src index 7325bde9d..62fe08a28 100644 --- a/testsuite/escript/array/array17.src +++ b/testsuite/escript/array/array17.src @@ -1,4 +1,4 @@ -var x := array { 4, 3 }; +var x := array{ 4, 3 }; var z := x + 5; -print(x); -print(z); +print( x ); +print( z ); diff --git a/testsuite/escript/array/array18.src b/testsuite/escript/array/array18.src index 18206ca21..6cf054459 100644 --- a/testsuite/escript/array/array18.src +++ b/testsuite/escript/array/array18.src @@ -1,14 +1,14 @@ program foo() - var i:=1; - var a1 := array{i}; - var a2 := array{}; - var a3 := array{}; - a2.append(i); - a2.insert(i,i); - a3[i]:=i; - i+=1; - print(i); - print(a1); // arrays should not change - print(a2); - print(a3); + var i := 1; + var a1 := array{ i }; + var a2 := array{}; + var a3 := array{}; + a2.append( i ); + a2.insert( i, i ); + a3[i] := i; + i += 1; + print( i ); + print( a1 ); // arrays should not change + print( a2 ); + print( a3 ); endprogram diff --git a/testsuite/escript/array/array19.src b/testsuite/escript/array/array19.src index 9feca2046..aac563693 100644 --- a/testsuite/escript/array/array19.src +++ b/testsuite/escript/array/array19.src @@ -1,48 +1,48 @@ -var a:={{1,2},{0,1,2}}; -a[1][4]:=2; -print("sort with null entry"); -print(a.sort(3)); -//print(a); // disabled due to non deterministic (ptr compare) -a:={{1,2},{0,1,2}}; +var a := { { 1, 2 }, { 0, 1, 2 } }; +a[1][4] := 2; +print( "sort with null entry" ); +print( a.sort( 3 ) ); +// print(a); // disabled due to non deterministic (ptr compare) +a := { { 1, 2 }, { 0, 1, 2 } }; -print("sort with index too large"); -print(a.sort(4)); -//print(a); // see above +print( "sort with index too large" ); +print( a.sort( 4 ) ); +// print(a); // see above -print("sort strings"); -a[1][4]:="bb"; -a[2][4]:="aa"; -print(a.sort(4)); -print(a); +print( "sort strings" ); +a[1][4] := "bb"; +a[2][4] := "aa"; +print( a.sort( 4 ) ); +print( a ); -print("sort mixed"); -a[1][5]:=5.6; -a[2][5]:=5; -print(a.sort(5)); -print(a); +print( "sort mixed" ); +a[1][5] := 5.6; +a[2][5] := 5; +print( a.sort( 5 ) ); +print( a ); -print("sort mixed"); -a[1][6]:=5; -a[2][6]:="5a"; -print(a.sort(6)); -print(a); +print( "sort mixed" ); +a[1][6] := 5; +a[2][6] := "5a"; +print( a.sort( 6 ) ); +print( a ); -print("sort invalid"); -a.append(5); -print(a.sort(6)); -print(a); +print( "sort invalid" ); +a.append( 5 ); +print( a.sort( 6 ) ); +print( a ); -print("sort invalid"); -print(a.sort(0)); -print(a); +print( "sort invalid" ); +print( a.sort( 0 ) ); +print( a ); -print("sort invalid"); -a[3]:={}; -print(a.sort(6)); -print(a); +print( "sort invalid" ); +a[3] := {}; +print( a.sort( 6 ) ); +print( a ); -print("sort invalid"); -a[3]:={1}; -a[5]:={1}; -print(a.sort(1)); -print(a); +print( "sort invalid" ); +a[3] := { 1 }; +a[5] := { 1 }; +print( a.sort( 1 ) ); +print( a ); diff --git a/testsuite/escript/array/array20.src b/testsuite/escript/array/array20.src index 2a02ea1a6..0a0f9815f 100644 --- a/testsuite/escript/array/array20.src +++ b/testsuite/escript/array/array20.src @@ -1,30 +1,30 @@ -var a:={1,2,3,5}; -a.sorted_insert(4); -print(a); +var a := { 1, 2, 3, 5 }; +a.sorted_insert( 4 ); +print( a ); -print("reverse"); -a:={1,2,3,5}; +print( "reverse" ); +a := { 1, 2, 3, 5 }; a.reverse(); -a.sorted_insert(4,0,1); -print(a); +a.sorted_insert( 4, 0, 1 ); +print( a ); -a:={1,2,3,5}; +a := { 1, 2, 3, 5 }; a.reverse(); -print("wrong"); -a.sorted_insert(4,0,0); -print(a); +print( "wrong" ); +a.sorted_insert( 4, 0, 0 ); +print( a ); -print("sub index"); -a:={{1,5},{2,4},{3,3},{5,1}}; -a.sorted_insert({4,2},1); -print(a); +print( "sub index" ); +a := { { 1, 5 }, { 2, 4 }, { 3, 3 }, { 5, 1 } }; +a.sorted_insert( { 4, 2 }, 1 ); +print( a ); -print("sub index reverse"); -a:={{1,5},{2,4},{3,3},{5,1}}; -a.sorted_insert({4,2},2,1); -print(a); +print( "sub index reverse" ); +a := { { 1, 5 }, { 2, 4 }, { 3, 3 }, { 5, 1 } }; +a.sorted_insert( { 4, 2 }, 2, 1 ); +print( a ); -print("sub index reverse wrong"); -a:={{1,5},{2,4},{3,3},{5,1}}; -a.sorted_insert({4,2},2); -print(a); +print( "sub index reverse wrong" ); +a := { { 1, 5 }, { 2, 4 }, { 3, 3 }, { 5, 1 } }; +a.sorted_insert( { 4, 2 }, 2 ); +print( a ); diff --git a/testsuite/escript/array/filter-byref.src b/testsuite/escript/array/filter-byref.src index 2677a845f..f844873b1 100644 --- a/testsuite/escript/array/filter-byref.src +++ b/testsuite/escript/array/filter-byref.src @@ -15,7 +15,6 @@ function filter_array( byref arr, func ) return result; endfunction - // Some functions with alternating byref options var filter_func1 := @( element, index, arr ) { arr[index] := element * 2; @@ -24,14 +23,14 @@ var filter_func1 := @( element, index, arr ) { return true; }; -var filter_func2 := @(byref element, index, arr) { +var filter_func2 := @( byref element, index, arr ) { arr[index] := element * 2; element := arr[index]; arr[index + 1] := element * 3; return true; }; -var filter_func3 := @(element, index, byref arr) { +var filter_func3 := @( element, index, byref arr ) { arr[index] := element * 2; element := arr[index]; arr[index + 1] := element * 3; @@ -42,14 +41,14 @@ foreach func in ( array{ filter_func1, filter_func2, filter_func3 } ) var f, filtered_poly, filtered_builtin; // Filter using "polyfill" - f := array{ 1,2,3,4,5 }; + f := array{ 1, 2, 3, 4, 5 }; filtered_poly := filter_array( f, func ); print( $"filtered_poly={filtered_poly}" ); print( $"f={f}" ); // Filter using built-in - f := array{ 1,2,3,4,5 }; - filtered_builtin := f.filter(func); + f := array{ 1, 2, 3, 4, 5 }; + filtered_builtin := f.filter( func ); print( $"filtered_builtin={filtered_builtin}" ); print( $"f={f}" ); diff --git a/testsuite/escript/array/filter.src b/testsuite/escript/array/filter.src index fa44bacfc..143ef6ce7 100644 --- a/testsuite/escript/array/filter.src +++ b/testsuite/escript/array/filter.src @@ -9,7 +9,6 @@ print( arr.filter( @ModifyArrayByrefAdd ) ); print( arr ); print( array{ 1, 2, 3, 4, 5 }.filter( @ModifyElementByref ) ); - print( array{}.find( @DoNotCall ) ); // Returns new, empty array // Test with a name_arr'd array @@ -21,7 +20,6 @@ print( arr.map( @DoNotCall ) ); print( array{}.filter() ); print( array{}.filter( "foo" ) ); - function Always() return true; endfunction diff --git a/testsuite/escript/array/find.src b/testsuite/escript/array/find.src index 52eb6449f..5e77ba9a7 100644 --- a/testsuite/escript/array/find.src +++ b/testsuite/escript/array/find.src @@ -1,6 +1,6 @@ print( array{ 1, 2, 3, 4, 5 }.find( @Always ) ); print( array{ 1, 2, 3, 4, 5 }.find( @{ return 0; } ) ); // Never -print( array{ 1, 2, 3, 4, 5 }.find( @( element ) { return ( element % 2 ) == 0; })); // IfEven +print( array{ 1, 2, 3, 4, 5 }.find( @( element ) { return ( element % 2 ) == 0; } ) ); // IfEven print( array{ 1, 2, 3, 4, 5 }.find( @IfHighestIndex ) ); print( array{}.find( @DoNotCall ) ); // Returns new, empty array @@ -14,7 +14,6 @@ print( arr.map( @DoNotCall ) ); print( array{}.find() ); print( array{}.find( "foo" ) ); - function Always() return true; endfunction diff --git a/testsuite/escript/array/findIndex.src b/testsuite/escript/array/findIndex.src index 1ab853ce8..84a50a4b2 100644 --- a/testsuite/escript/array/findIndex.src +++ b/testsuite/escript/array/findIndex.src @@ -1,6 +1,8 @@ print( array{ "a", "b", "c", "D", "e" }.findIndex( @Always ) ); print( array{ "a", "b", "c", "D", "e" }.findIndex( @{ return 0; } ) ); // Never -print( array{ "a", "b", "c", "D", "e" }.findIndex( @( element ) { return element == "D"; })); // IfEquals +print( array{ "a", "b", "c", "D", "e" }.findIndex( @( element ) { + return element == "D"; +} ) ); // IfEquals print( array{ "a", "b", "c", "D", "e" }.findIndex( @IfHighestIndex ) ); print( array{}.findIndex( @DoNotCall ) ); // Returns 0 diff --git a/testsuite/escript/base64/base64001.src b/testsuite/escript/base64/base64001.src index 17a7e5425..6fa2b76a6 100644 --- a/testsuite/escript/base64/base64001.src +++ b/testsuite/escript/base64/base64001.src @@ -1,7 +1,7 @@ var str := "test"; -var encoded := encodeBase64(str); -print(str); -print(encoded); +var encoded := encodeBase64( str ); +print( str ); +print( encoded ); if ( encoded == "dGVzdA==" ) -print("success"); -endif \ No newline at end of file + print( "success" ); +endif diff --git a/testsuite/escript/base64/base64002.src b/testsuite/escript/base64/base64002.src index dce57e6fa..85775f3f5 100644 --- a/testsuite/escript/base64/base64002.src +++ b/testsuite/escript/base64/base64002.src @@ -1,7 +1,7 @@ var str := "dGVzdA=="; -var decoded := decodeBase64(str); -print(str); -print(decoded); +var decoded := decodeBase64( str ); +print( str ); +print( decoded ); if ( decoded == "test" ) -print("success"); -endif \ No newline at end of file + print( "success" ); +endif diff --git a/testsuite/escript/base64/base64003.src b/testsuite/escript/base64/base64003.src index ed32fe075..e7f4b4404 100644 --- a/testsuite/escript/base64/base64003.src +++ b/testsuite/escript/base64/base64003.src @@ -1,5 +1,5 @@ -var a:=decodeBase64("0JfQtNGA0LDQstC+"); -var b:=encodeBase64("Здраво"); -print(a); -print(b); -print(decodeBase64(b)==a); +var a := decodeBase64( "0JfQtNGA0LDQstC+" ); +var b := encodeBase64( "Здраво" ); +print( a ); +print( b ); +print( decodeBase64( b ) == a ); diff --git a/testsuite/escript/bfor/bfor001.src b/testsuite/escript/bfor/bfor001.src index 3afe4547e..7e9a7bfe4 100644 --- a/testsuite/escript/bfor/bfor001.src +++ b/testsuite/escript/bfor/bfor001.src @@ -1,4 +1,3 @@ for i := 1 to 3 - print(i); + print( i ); endfor - diff --git a/testsuite/escript/bfor/bfor002.src b/testsuite/escript/bfor/bfor002.src index 4cc08632e..228e54c54 100644 --- a/testsuite/escript/bfor/bfor002.src +++ b/testsuite/escript/bfor/bfor002.src @@ -1,4 +1,4 @@ for i := 1 to 3 - var b := 2*i; - print(b); + var b := 2 * i; + print( b ); endfor diff --git a/testsuite/escript/bfor/bfor003.src b/testsuite/escript/bfor/bfor003.src index 201288228..9d1c76891 100644 --- a/testsuite/escript/bfor/bfor003.src +++ b/testsuite/escript/bfor/bfor003.src @@ -1,7 +1,7 @@ for i := 1 to 5 - var b := 2*i; - print(b); - if (i > 3) - break; - endif + var b := 2 * i; + print( b ); + if ( i > 3 ) + break; + endif endfor diff --git a/testsuite/escript/bfor/bfor004.src b/testsuite/escript/bfor/bfor004.src index 089ec092f..9e2d5bc64 100644 --- a/testsuite/escript/bfor/bfor004.src +++ b/testsuite/escript/bfor/bfor004.src @@ -1,10 +1,10 @@ for i := 1 to 5 - var b := 2*i; - print(b); - if (i > 3) - break; - endif - var c; - c := 2; - print(c+b); + var b := 2 * i; + print( b ); + if ( i > 3 ) + break; + endif + var c; + c := 2; + print( c + b ); endfor diff --git a/testsuite/escript/bfor/bfor005.src b/testsuite/escript/bfor/bfor005.src index 1033732ef..7398170cf 100644 --- a/testsuite/escript/bfor/bfor005.src +++ b/testsuite/escript/bfor/bfor005.src @@ -1,10 +1,10 @@ for i := 1 to 5 - var b := 2*i; - print(b); - if (i == 3) - continue; - endif - var c; - c := 2; - print(c+b); + var b := 2 * i; + print( b ); + if ( i == 3 ) + continue; + endif + var c; + c := 2; + print( c + b ); endfor diff --git a/testsuite/escript/bfor/bfor006.src b/testsuite/escript/bfor/bfor006.src index 9f460060a..f9518099a 100644 --- a/testsuite/escript/bfor/bfor006.src +++ b/testsuite/escript/bfor/bfor006.src @@ -1,13 +1,13 @@ -function txtcmd_addpath ( params ) +function txtcmd_addpath( params ) params := SplitWords( params ); - var phrase := ""; - var arraylength := len( params ); + var phrase := ""; + var arraylength := len( params ); - for a := 3 to arraylength - phrase := phrase + params[a] + " "; - endfor + for a := 3 to arraylength + phrase := phrase + params[a] + " "; + endfor print( phrase ); endfunction diff --git a/testsuite/escript/bitop/bitop002.src b/testsuite/escript/bitop/bitop002.src index 8a141dbcc..d1c140859 100644 --- a/testsuite/escript/bitop/bitop002.src +++ b/testsuite/escript/bitop/bitop002.src @@ -3,6 +3,6 @@ const bit02 := 0x02; const bit03 := bit01 | bit02; -print(bit01); -print(bit02); -print(bit03); +print( bit01 ); +print( bit02 ); +print( bit03 ); diff --git a/testsuite/escript/bitop/bitop003.src b/testsuite/escript/bitop/bitop003.src index 7e5230e9b..28538ac83 100644 --- a/testsuite/escript/bitop/bitop003.src +++ b/testsuite/escript/bitop/bitop003.src @@ -1,7 +1,6 @@ const bit01 := 0x01; -const bitNot01 := ~ (bit01); +const bitNot01 := ~( bit01 ); - -print(bit01); -print(bitNot01); -print(Hex(bitNot01)); \ No newline at end of file +print( bit01 ); +print( bitNot01 ); +print( Hex( bitNot01 ) ); diff --git a/testsuite/escript/boolean/bool01.src b/testsuite/escript/boolean/bool01.src index b3ae1be89..acb1740c3 100644 --- a/testsuite/escript/boolean/bool01.src +++ b/testsuite/escript/boolean/bool01.src @@ -1,24 +1,24 @@ -var a:=Boolean(1); -var b:=Boolean(0); -print(a); // true -print(b); // false -print(pack(a)); -print(pack(b)); -print(unpack(pack(a))); // true -print(unpack(pack(b))); // false -print(typeof(a)); -print(typeofint(a)); -print(cstr(a)); -print(!b); // true -print(a==b); // false -var c:=a; -a:= Boolean(0); -print(a); // false -print(c); // true +var a := Boolean( 1 ); +var b := Boolean( 0 ); +print( a ); // true +print( b ); // false +print( pack( a ) ); +print( pack( b ) ); +print( unpack( pack( a ) ) ); // true +print( unpack( pack( b ) ) ); // false +print( typeof( a ) ); +print( typeofint( a ) ); +print( cstr( a ) ); +print( !b ); // true +print( a == b ); // false +var c := a; +a := Boolean( 0 ); +print( a ); // false +print( c ); // true -if (c) - print("c is true"); +if ( c ) + print( "c is true" ); endif -if (!a) - print("a is false"); +if ( !a ) + print( "a is false" ); endif diff --git a/testsuite/escript/boolean/bool02.src b/testsuite/escript/boolean/bool02.src index 5ee3335c6..a11bb9791 100644 --- a/testsuite/escript/boolean/bool02.src +++ b/testsuite/escript/boolean/bool02.src @@ -1,14 +1,13 @@ -var a:=Boolean(1); -print(a==1); // true -print(a==0); // false -print(a!=2); // false -print(a==1.0); // true -print(a=="x"); // true +var a := Boolean( 1 ); +print( a == 1 ); // true +print( a == 0 ); // false +print( a != 2 ); // false +print( a == 1.0 ); // true +print( a == "x" ); // true -print(1==a); // true -print(""==Boolean(0)); // true - -var b:= struct{b:=a}; -print(b); -print(b.b); +print( 1 == a ); // true +print( "" == Boolean( 0 ) ); // true +var b := struct{ b := a }; +print( b ); +print( b.b ); diff --git a/testsuite/escript/boolean/bool03.src b/testsuite/escript/boolean/bool03.src index 82859ae41..a07e0e2db 100644 --- a/testsuite/escript/boolean/bool03.src +++ b/testsuite/escript/boolean/bool03.src @@ -1,31 +1,31 @@ -var a:=true; -var b:=false; -print(a); // true -print(b); // false -print(pack(a)); -print(pack(b)); -print(unpack(pack(a))); // true -print(unpack(pack(b))); // false -print(typeof(a)); -print(typeofint(a)); -print(cstr(a)); -print(!b); // true -print(a==b); // false -var c:=a; -a:= false; -print(a); // false -print(c); // true +var a := true; +var b := false; +print( a ); // true +print( b ); // false +print( pack( a ) ); +print( pack( b ) ); +print( unpack( pack( a ) ) ); // true +print( unpack( pack( b ) ) ); // false +print( typeof( a ) ); +print( typeofint( a ) ); +print( cstr( a ) ); +print( !b ); // true +print( a == b ); // false +var c := a; +a := false; +print( a ); // false +print( c ); // true -if (c) - print("c is true"); +if ( c ) + print( "c is true" ); endif -if (!a) - print("a is false"); +if ( !a ) + print( "a is false" ); endif const foo := true; -print(foo); -case (true) -true: print("case: true"); -false: print("case: false"); +print( foo ); +case ( true ) + true: print( "case: true" ); + false: print( "case: false" ); endcase diff --git a/testsuite/escript/boolean/bool04.src b/testsuite/escript/boolean/bool04.src index 3f24b1644..245d50639 100644 --- a/testsuite/escript/boolean/bool04.src +++ b/testsuite/escript/boolean/bool04.src @@ -1,14 +1,13 @@ -var a:=true; -print(a==1); // true -print(a==0); // false -print(a!=2); // false -print(a==1.0); // true -print(a=="x"); // true +var a := true; +print( a == 1 ); // true +print( a == 0 ); // false +print( a != 2 ); // false +print( a == 1.0 ); // true +print( a == "x" ); // true -print(1==a); // true -print(""==false); // true - -var b:= struct{b:=a}; -print(b); -print(b.b); +print( 1 == a ); // true +print( "" == false ); // true +var b := struct{ b := a }; +print( b ); +print( b.b ); diff --git a/testsuite/escript/bracket/bracket.src b/testsuite/escript/bracket/bracket.src index 4a7cf302f..c792779b9 100644 --- a/testsuite/escript/bracket/bracket.src +++ b/testsuite/escript/bracket/bracket.src @@ -1,62 +1,56 @@ print( "Testing Simple IF:" ); -if (5 < 3) - print("1a: failure 1"); +if ( 5 < 3 ) + print( "1a: failure 1" ); endif -if (3 < 5) - print("1b: ok"); +if ( 3 < 5 ) + print( "1b: ok" ); endif -print("Testing IF..ELSEIF..ENDIF"); +print( "Testing IF..ELSEIF..ENDIF" ); -if (3 < 5) - print("2: ok"); -elseif (3 < 5) - print("2: failure 1"); +if ( 3 < 5 ) + print( "2: ok" ); +elseif ( 3 < 5 ) + print( "2: failure 1" ); endif print( "Testing IF..ELSE..ENDIF" ); - -if (3 < 5) - print( "3a: ok" ); +if ( 3 < 5 ) + print( "3a: ok" ); else - print( "3a: failure 1" ); + print( "3a: failure 1" ); endif - - -if (5 < 3) - print( "3b: failed" ); +if ( 5 < 3 ) + print( "3b: failed" ); else - print( "3b: ok" ); + print( "3b: ok" ); endif - - print( "Testing IF..ELSEIF..ELSE..ENDIF" ); -if (3 < 5) - print("4a: ok"); -elseif (4 < 6) - print("4a: failure 1"); +if ( 3 < 5 ) + print( "4a: ok" ); +elseif ( 4 < 6 ) + print( "4a: failure 1" ); else - print("4a: failure 2"); + print( "4a: failure 2" ); endif -if (7 < 5) - print("4b: faiure 1"); -elseif (4 < 6) - print("4b: ok"); +if ( 7 < 5 ) + print( "4b: faiure 1" ); +elseif ( 4 < 6 ) + print( "4b: ok" ); else - print("4b: failure 2"); + print( "4b: failure 2" ); endif -if (7 < 5) - print("4c: faiure 1"); -elseif (9 < 6) - print("4c: failure 2"); +if ( 7 < 5 ) + print( "4c: faiure 1" ); +elseif ( 9 < 6 ) + print( "4c: failure 2" ); else - print("4c: ok"); + print( "4c: ok" ); endif - diff --git a/testsuite/escript/bracket/bracket02.src b/testsuite/escript/bracket/bracket02.src index 59e3bb921..da72532cd 100644 --- a/testsuite/escript/bracket/bracket02.src +++ b/testsuite/escript/bracket/bracket02.src @@ -1,9 +1,8 @@ -if (7 < 5) - print("4c: failure 1"); -elseif (9 < 6) - print("4c: failure 2"); +if ( 7 < 5 ) + print( "4c: failure 1" ); +elseif ( 9 < 6 ) + print( "4c: failure 2" ); else - print("4c: ok"); + print( "4c: ok" ); endif - diff --git a/testsuite/escript/bracket/bracket1.src b/testsuite/escript/bracket/bracket1.src index a4f8b682d..e4972e30b 100644 --- a/testsuite/escript/bracket/bracket1.src +++ b/testsuite/escript/bracket/bracket1.src @@ -1,19 +1,18 @@ -print( "Testing Multilevel IF:"); -if (3 < 5) - print("1.1: ok"); - if (3 < 4) - print("1.1.1: ok"); - endif - print("1.2: ok"); +print( "Testing Multilevel IF:" ); +if ( 3 < 5 ) + print( "1.1: ok" ); + if ( 3 < 4 ) + print( "1.1.1: ok" ); + endif + print( "1.2: ok" ); endif -if (3 < 5) - print("2.1: ok"); - if (4 < 2) - print("2.1.1: failure"); - else - print("2.1.1: ok"); - endif +if ( 3 < 5 ) + print( "2.1: ok" ); + if ( 4 < 2 ) + print( "2.1.1: failure" ); + else + print( "2.1.1: ok" ); + endif endif - \ No newline at end of file diff --git a/testsuite/escript/bug/bug.err b/testsuite/escript/bug/bug.err index 75563d46c..44a76c177 100644 --- a/testsuite/escript/bug/bug.err +++ b/testsuite/escript/bug/bug.err @@ -1 +1 @@ -bug.src:4:17: error: missing ';' at '(' \ No newline at end of file +:4:17: error: missing ';' at '(' \ No newline at end of file diff --git a/testsuite/escript/bug/bug001.src b/testsuite/escript/bug/bug001.src index aef46f075..f56f3cad2 100644 --- a/testsuite/escript/bug/bug001.src +++ b/testsuite/escript/bug/bug001.src @@ -1,9 +1,8 @@ var foo := "abc"; -print(foo[1]); -print(foo[2]); +print( foo[1] ); +print( foo[2] ); -print(foo[1]+foo[2]); - -print(foo[1,2]-"b"); +print( foo[1] + foo[2] ); +print( foo[1, 2] - "b" ); diff --git a/testsuite/escript/bug/bug002.src b/testsuite/escript/bug/bug002.src index dc1c9ca22..119eb777a 100644 --- a/testsuite/escript/bug/bug002.src +++ b/testsuite/escript/bug/bug002.src @@ -5,8 +5,8 @@ ret.+Amt; ret.Ret := 1; ret.Amt := 2; -print("got = " + ret); +print( "got = " + ret ); -//Result is: +// Result is: -//got == {, 2} +// got == {, 2} diff --git a/testsuite/escript/bug/bug003.src b/testsuite/escript/bug/bug003.src index 13cb135de..8d9f5b5d0 100644 --- a/testsuite/escript/bug/bug003.src +++ b/testsuite/escript/bug/bug003.src @@ -1,4 +1,4 @@ -var foo := {88,88}; +var foo := { 88, 88 }; foo[4] := 90; -foo := CChrZ(foo); -print(foo); +foo := CChrZ( foo ); +print( foo ); diff --git a/testsuite/escript/bug/bug004.err b/testsuite/escript/bug/bug004.err index 6d8a00491..f462f01e2 100644 --- a/testsuite/escript/bug/bug004.err +++ b/testsuite/escript/bug/bug004.err @@ -1 +1 @@ -bug004.src:2:6: error: missing ';' at '(' \ No newline at end of file +:2:6: error: missing ';' at '(' \ No newline at end of file diff --git a/testsuite/escript/bug/bug005.src b/testsuite/escript/bug/bug005.src index 4370351c2..c88f369ac 100644 --- a/testsuite/escript/bug/bug005.src +++ b/testsuite/escript/bug/bug005.src @@ -1,17 +1,17 @@ const EXPR_ZERO := 0; -function A(key) -var wtype; -var sev; +function A( key ) + var wtype; + var sev; - if (!EXPR_ZERO) - B(); - else - foreach v in { 4,5,6 } - C(); - endforeach - endif - sev := 7; + if ( !EXPR_ZERO ) + B(); + else + foreach v in { 4, 5, 6 } + C(); + endforeach + endif + sev := 7; endfunction @@ -22,6 +22,6 @@ function C() endfunction program foo() - A(4); - print("ok"); + A( 4 ); + print( "ok" ); endprogram diff --git a/testsuite/escript/bug/bug006.err b/testsuite/escript/bug/bug006.err index 84f2856f0..fe1ed1dc9 100644 --- a/testsuite/escript/bug/bug006.err +++ b/testsuite/escript/bug/bug006.err @@ -1 +1 @@ -bug006.src:11:15: error: missing ';' at '(' \ No newline at end of file +:11:15: error: missing ';' at '(' \ No newline at end of file diff --git a/testsuite/escript/bug/bug007.err b/testsuite/escript/bug/bug007.err index 3eb962c5e..31e601839 100644 --- a/testsuite/escript/bug/bug007.err +++ b/testsuite/escript/bug/bug007.err @@ -1 +1 @@ -bug007.src:2:8: error: missing ';' at '{' \ No newline at end of file +:2:8: error: missing ';' at '{' \ No newline at end of file diff --git a/testsuite/escript/bug/bug008.err b/testsuite/escript/bug/bug008.err index bcaa49fde..88adc40e3 100644 --- a/testsuite/escript/bug/bug008.err +++ b/testsuite/escript/bug/bug008.err @@ -1 +1 @@ -bug008.src:4:8: error: extraneous input 'c' expecting ';' \ No newline at end of file +:4:8: error: extraneous input 'c' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/bug/bug010-if-statement-optimization-offset-corruption.src b/testsuite/escript/bug/bug010-if-statement-optimization-offset-corruption.src index 4b626c2d5..5a9a3ae30 100644 --- a/testsuite/escript/bug/bug010-if-statement-optimization-offset-corruption.src +++ b/testsuite/escript/bug/bug010-if-statement-optimization-offset-corruption.src @@ -8,9 +8,9 @@ var b := "correct: first path"; -if (1) - b := b + "!"; - print(b); -elseif (b) - print("incorrect: second path"); +if ( 1 ) + b := b + "!"; + print( b ); +elseif ( b ) + print( "incorrect: second path" ); endif diff --git a/testsuite/escript/bug/bug011-module-function-param-name-clash.src b/testsuite/escript/bug/bug011-module-function-param-name-clash.src index fa3923fe4..e5e370111 100644 --- a/testsuite/escript/bug/bug011-module-function-param-name-clash.src +++ b/testsuite/escript/bug/bug011-module-function-param-name-clash.src @@ -9,12 +9,11 @@ use storage; program display_area() - var h := 10; - var w := 20; - print("Area is " +CStr(area(h, w))); + var h := 10; + var w := 20; + print( "Area is " + CStr( area( h, w ) ) ); endprogram -function area(ht, wd) - return ht * wd; +function area( ht, wd ) + return ht * wd; endfunction - diff --git a/testsuite/escript/bug/bug012-function-as-named-parameter.src b/testsuite/escript/bug/bug012-function-as-named-parameter.src index a11317a19..20de79d27 100644 --- a/testsuite/escript/bug/bug012-function-as-named-parameter.src +++ b/testsuite/escript/bug/bug012-function-as-named-parameter.src @@ -8,10 +8,10 @@ // and still pass the argument by name. // function anything( s ) - return "the argument value is " + s; + return "the argument value is " + s; endfunction program print_anything() - var s := anything("as expected"); - print( anything := s ); + var s := anything( "as expected" ); + print( anything := s ); endprogram diff --git a/testsuite/escript/bug/bug013-local-variable-index.src b/testsuite/escript/bug/bug013-local-variable-index.src index 88ce05dd5..e5274c277 100644 --- a/testsuite/escript/bug/bug013-local-variable-index.src +++ b/testsuite/escript/bug/bug013-local-variable-index.src @@ -4,14 +4,13 @@ // The executor doesn't use the variable index, which is why this didn't cause problems. program foo() - var a; // should be 0 - if ( a ) - var b; // should be 1 actually emitted 0 - var c; // should be 2 actually emitted 1 - if ( b ) - var d; // should be 3 actually emitted 0 - print(d); - endif - endif + var a; // should be 0 + if ( a ) + var b; // should be 1 actually emitted 0 + var c; // should be 2 actually emitted 1 + if ( b ) + var d; // should be 3 actually emitted 0 + print( d ); + endif + endif endprogram - diff --git a/testsuite/escript/bug/crash001.err b/testsuite/escript/bug/crash001.err index f9bdd7699..18bdfc672 100644 --- a/testsuite/escript/bug/crash001.err +++ b/testsuite/escript/bug/crash001.err @@ -1 +1 @@ -crash001.inc:3:24: error: missing ';' at '{' +:3:24: error: missing ';' at '{' \ No newline at end of file diff --git a/testsuite/escript/bug/crash001.src b/testsuite/escript/bug/crash001.src index 0f96f8a2b..2ebaf5ddc 100644 --- a/testsuite/escript/bug/crash001.src +++ b/testsuite/escript/bug/crash001.src @@ -1,5 +1,5 @@ include "crash001"; program test() - ecompile_crash_func(); + ecompile_crash_func(); endprogram diff --git a/testsuite/escript/cfg/appendcfgelem.src b/testsuite/escript/cfg/appendcfgelem.src index 6d0d6cb9d..132a4b454 100644 --- a/testsuite/escript/cfg/appendcfgelem.src +++ b/testsuite/escript/cfg/appendcfgelem.src @@ -1,22 +1,18 @@ use cfgfile; use file; -OpenBinaryFile(":cfgtests:appendtest.cfg", OPENMODE_OUT|OPENMODE_TRUNC); // clear content -var props:={ - {"key1","val1"}, - struct{name:="key2", value:=1} -}; +OpenBinaryFile( ":cfgtests:appendtest.cfg", OPENMODE_OUT | OPENMODE_TRUNC ); // clear content +var props := { { "key1", "val1" }, struct{ name := "key2", value := 1 } }; -print(AppendConfigFileElem(":cfgtests:appendtest", "elem", 1, props)); +print( AppendConfigFileElem( ":cfgtests:appendtest", "elem", 1, props ) ); -var c:=ReadConfigFile(":cfgtests:appendtest"); -print(c); -var e:=c["1"]; -print(e.key1); -print(e.key2); +var c := ReadConfigFile( ":cfgtests:appendtest" ); +print( c ); +var e := c["1"]; +print( e.key1 ); +print( e.key2 ); -//invalid file -print(AppendConfigFileElem(":cfgtests:appendtest/", "elem", 1, props)); +// invalid file +print( AppendConfigFileElem( ":cfgtests:appendtest/", "elem", 1, props ) ); - -OpenBinaryFile(":cfgtests:appendtest.cfg", OPENMODE_OUT|OPENMODE_TRUNC);// clear content +OpenBinaryFile( ":cfgtests:appendtest.cfg", OPENMODE_OUT | OPENMODE_TRUNC ); // clear content diff --git a/testsuite/escript/cfg/cfg.src b/testsuite/escript/cfg/cfg.src index b40e28f7e..348a4d41e 100644 --- a/testsuite/escript/cfg/cfg.src +++ b/testsuite/escript/cfg/cfg.src @@ -1,15 +1,16 @@ use cfgfile; -function get(cfg) - print(cfg); - foreach key in GetConfigStringKeys(cfg) - var e:= FindConfigElem(cfg,key); - print(key); - foreach entry in ListConfigElemProps(e) - print(entry+" "+GetConfigString(e,entry)+" "+GetConfigString(e, entry).find("ü")); - endforeach +function get( cfg ) + print( cfg ); + foreach key in GetConfigStringKeys( cfg ) + var e := FindConfigElem( cfg, key ); + print( key ); + foreach entry in ListConfigElemProps( e ) + print( entry + " " + GetConfigString( e, entry ) + + " " + GetConfigString( e, entry ).find( "ü" ) ); + endforeach endforeach endfunction -get(ReadConfigFile(":cfgtests:cfg")); -get(ReadConfigFile(":cfgtests:cfgbom")); -get(ReadConfigFile(":cfgtests:cfgiso")); +get( ReadConfigFile( ":cfgtests:cfg" ) ); +get( ReadConfigFile( ":cfgtests:cfgbom" ) ); +get( ReadConfigFile( ":cfgtests:cfgiso" ) ); diff --git a/testsuite/escript/compiler2/compiler2-001-hello-world.src b/testsuite/escript/compiler2/compiler2-001-hello-world.src index b2c7db7a2..a9db16303 100644 --- a/testsuite/escript/compiler2/compiler2-001-hello-world.src +++ b/testsuite/escript/compiler2/compiler2-001-hello-world.src @@ -1,2 +1 @@ -print("hello, world"); - +print( "hello, world" ); diff --git a/testsuite/escript/compiler2/compiler2-002-hello-world-program.src b/testsuite/escript/compiler2/compiler2-002-hello-world-program.src index 94656dfba..57dd75f62 100644 --- a/testsuite/escript/compiler2/compiler2-002-hello-world-program.src +++ b/testsuite/escript/compiler2/compiler2-002-hello-world-program.src @@ -1,4 +1,3 @@ program hi() - print("hello, world"); + print( "hello, world" ); endprogram - diff --git a/testsuite/escript/compiler2/compiler2-003-print-global-var.src b/testsuite/escript/compiler2/compiler2-003-print-global-var.src index af9be6cb2..af2835fb6 100644 --- a/testsuite/escript/compiler2/compiler2-003-print-global-var.src +++ b/testsuite/escript/compiler2/compiler2-003-print-global-var.src @@ -1,2 +1,2 @@ var a := "hello, world"; -print(a); +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-004-if-is-true.src b/testsuite/escript/compiler2/compiler2-004-if-is-true.src index 3b37ef807..1f39e5fbf 100644 --- a/testsuite/escript/compiler2/compiler2-004-if-is-true.src +++ b/testsuite/escript/compiler2/compiler2-004-if-is-true.src @@ -1,6 +1,5 @@ var a := 5; -if (a) - print("correct - path taken"); +if ( a ) + print( "correct - path taken" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-005-if-is-false.src b/testsuite/escript/compiler2/compiler2-005-if-is-false.src index fafec6970..0fa4dd999 100644 --- a/testsuite/escript/compiler2/compiler2-005-if-is-false.src +++ b/testsuite/escript/compiler2/compiler2-005-if-is-false.src @@ -1,7 +1,6 @@ var a := 0; -if (a) - print("incorrect - path taken"); +if ( a ) + print( "incorrect - path taken" ); endif -print("correct if no other output"); - +print( "correct if no other output" ); diff --git a/testsuite/escript/compiler2/compiler2-006-if-else-first.src b/testsuite/escript/compiler2/compiler2-006-if-else-first.src index ce2fa8519..a8fb37f35 100644 --- a/testsuite/escript/compiler2/compiler2-006-if-else-first.src +++ b/testsuite/escript/compiler2/compiler2-006-if-else-first.src @@ -1,8 +1,7 @@ var a := 5; -if (a) - print("correct - path taken"); +if ( a ) + print( "correct - path taken" ); else - print("incorrect - should not take else"); + print( "incorrect - should not take else" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-007-if-else-second.src b/testsuite/escript/compiler2/compiler2-007-if-else-second.src index 0ae4b18fa..0aa0fd5be 100644 --- a/testsuite/escript/compiler2/compiler2-007-if-else-second.src +++ b/testsuite/escript/compiler2/compiler2-007-if-else-second.src @@ -1,8 +1,7 @@ var a := 0; -if (a) - print("incorrect - first path taken"); +if ( a ) + print( "incorrect - first path taken" ); else - print("correct - else path taken"); + print( "correct - else path taken" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-008-if-elseif-first.src b/testsuite/escript/compiler2/compiler2-008-if-elseif-first.src index 979e285be..9b5635a24 100644 --- a/testsuite/escript/compiler2/compiler2-008-if-elseif-first.src +++ b/testsuite/escript/compiler2/compiler2-008-if-elseif-first.src @@ -1,9 +1,8 @@ var a := 5; var b := 7; -if (a) - print("correct - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "correct - first path" ); +elseif ( b ) + print( "incorrect - second path" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-009-if-elseif-second.src b/testsuite/escript/compiler2/compiler2-009-if-elseif-second.src index 128b3c4a1..9ed384e54 100644 --- a/testsuite/escript/compiler2/compiler2-009-if-elseif-second.src +++ b/testsuite/escript/compiler2/compiler2-009-if-elseif-second.src @@ -1,9 +1,8 @@ var a := 0; var b := 7; -if (a) - print("incorrect - first path"); -elseif (b) - print("correct - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "correct - second path" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-010-if-elseif-neither.src b/testsuite/escript/compiler2/compiler2-010-if-elseif-neither.src index 137fa0b82..44ded5fea 100644 --- a/testsuite/escript/compiler2/compiler2-010-if-elseif-neither.src +++ b/testsuite/escript/compiler2/compiler2-010-if-elseif-neither.src @@ -1,10 +1,10 @@ var a := 0; var b := 0; -if (a) - print("incorrect - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "incorrect - second path" ); endif -print("correct - neither"); \ No newline at end of file +print( "correct - neither" ); diff --git a/testsuite/escript/compiler2/compiler2-011-if-elseif-else-first.src b/testsuite/escript/compiler2/compiler2-011-if-elseif-else-first.src index 8fa2aa97a..ca8d3761f 100644 --- a/testsuite/escript/compiler2/compiler2-011-if-elseif-else-first.src +++ b/testsuite/escript/compiler2/compiler2-011-if-elseif-else-first.src @@ -1,10 +1,10 @@ var a := "xyz"; var b := 7; -if (a) - print("correct - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "correct - first path" ); +elseif ( b ) + print( "incorrect - second path" ); else - print("incorrect - third path"); + print( "incorrect - third path" ); endif diff --git a/testsuite/escript/compiler2/compiler2-012-if-elseif-else-second.src b/testsuite/escript/compiler2/compiler2-012-if-elseif-else-second.src index d34acb488..d20d3890c 100644 --- a/testsuite/escript/compiler2/compiler2-012-if-elseif-else-second.src +++ b/testsuite/escript/compiler2/compiler2-012-if-elseif-else-second.src @@ -1,10 +1,10 @@ var a := 0; var b := 7; -if (a) - print("incorrect - first path"); -elseif (b) - print("correct - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "correct - second path" ); else - print("incorrect - third path"); + print( "incorrect - third path" ); endif diff --git a/testsuite/escript/compiler2/compiler2-013-if-elseif-else-third.src b/testsuite/escript/compiler2/compiler2-013-if-elseif-else-third.src index 4beb4c522..69cd2d1b6 100644 --- a/testsuite/escript/compiler2/compiler2-013-if-elseif-else-third.src +++ b/testsuite/escript/compiler2/compiler2-013-if-elseif-else-third.src @@ -1,10 +1,10 @@ var a := 0; var b := 0; -if (a) - print("incorrect - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "incorrect - second path" ); else - print("correct - third path"); + print( "correct - third path" ); endif diff --git a/testsuite/escript/compiler2/compiler2-014-print-local-var.src b/testsuite/escript/compiler2/compiler2-014-print-local-var.src index 4068e32d1..b3e45f098 100644 --- a/testsuite/escript/compiler2/compiler2-014-print-local-var.src +++ b/testsuite/escript/compiler2/compiler2-014-print-local-var.src @@ -1,5 +1,5 @@ var a := 1; -if (a) - var b := "hi"; - print(b); +if ( a ) + var b := "hi"; + print( b ); endif diff --git a/testsuite/escript/compiler2/compiler2-015-local-vars-scoped.src b/testsuite/escript/compiler2/compiler2-015-local-vars-scoped.src index f6af8c8aa..33f8a1ae4 100644 --- a/testsuite/escript/compiler2/compiler2-015-local-vars-scoped.src +++ b/testsuite/escript/compiler2/compiler2-015-local-vars-scoped.src @@ -1,9 +1,9 @@ var a := 0; -if (a) - var b := "hi"; - print(b); +if ( a ) + var b := "hi"; + print( b ); else - var c := "wrong"; - var b := "correct"; - print(b); + var c := "wrong"; + var b := "correct"; + print( b ); endif diff --git a/testsuite/escript/compiler2/compiler2-016-function-call-no-params.src b/testsuite/escript/compiler2/compiler2-016-function-call-no-params.src index 7ed27d17c..9f0b2b2f8 100644 --- a/testsuite/escript/compiler2/compiler2-016-function-call-no-params.src +++ b/testsuite/escript/compiler2/compiler2-016-function-call-no-params.src @@ -1,5 +1,5 @@ function hello() - print("hello world"); + print( "hello world" ); endfunction hello(); diff --git a/testsuite/escript/compiler2/compiler2-017-function-call-single-parameter.src b/testsuite/escript/compiler2/compiler2-017-function-call-single-parameter.src index 4ae3f9654..7992c526c 100644 --- a/testsuite/escript/compiler2/compiler2-017-function-call-single-parameter.src +++ b/testsuite/escript/compiler2/compiler2-017-function-call-single-parameter.src @@ -1,5 +1,5 @@ -function display(s) - print(s); +function display( s ) + print( s ); endfunction -display("hi there"); +display( "hi there" ); diff --git a/testsuite/escript/compiler2/compiler2-018-function-call-multi-parameter.src b/testsuite/escript/compiler2/compiler2-018-function-call-multi-parameter.src index 87856d49d..be0daee72 100644 --- a/testsuite/escript/compiler2/compiler2-018-function-call-multi-parameter.src +++ b/testsuite/escript/compiler2/compiler2-018-function-call-multi-parameter.src @@ -1,6 +1,6 @@ -function display(a, b) - print(a); - print(b); +function display( a, b ) + print( a ); + print( b ); endfunction -display("hello", "world"); +display( "hello", "world" ); diff --git a/testsuite/escript/compiler2/compiler2-019-function-call-single-default-param.src b/testsuite/escript/compiler2/compiler2-019-function-call-single-default-param.src index 9ef997dc2..987ed56fc 100644 --- a/testsuite/escript/compiler2/compiler2-019-function-call-single-default-param.src +++ b/testsuite/escript/compiler2/compiler2-019-function-call-single-default-param.src @@ -1,6 +1,6 @@ -function display(s := "this is the default") - print(s); +function display( s := "this is the default" ) + print( s ); endfunction display(); -display("not the default"); +display( "not the default" ); diff --git a/testsuite/escript/compiler2/compiler2-020-function-return-value.src b/testsuite/escript/compiler2/compiler2-020-function-return-value.src index b816f9a1d..b2a2d4da3 100644 --- a/testsuite/escript/compiler2/compiler2-020-function-return-value.src +++ b/testsuite/escript/compiler2/compiler2-020-function-return-value.src @@ -1,5 +1,5 @@ function foo() - return "hello"; + return "hello"; endfunction foo(); diff --git a/testsuite/escript/compiler2/compiler2-021-const-simple.src b/testsuite/escript/compiler2/compiler2-021-const-simple.src index e8adb249a..761bf3b00 100644 --- a/testsuite/escript/compiler2/compiler2-021-const-simple.src +++ b/testsuite/escript/compiler2/compiler2-021-const-simple.src @@ -1,4 +1,3 @@ const VALUE := 4; -print(VALUE); - +print( VALUE ); diff --git a/testsuite/escript/compiler2/compiler2-022-integer-addition.src b/testsuite/escript/compiler2/compiler2-022-integer-addition.src index aa15a084c..94625871b 100644 --- a/testsuite/escript/compiler2/compiler2-022-integer-addition.src +++ b/testsuite/escript/compiler2/compiler2-022-integer-addition.src @@ -1,4 +1,4 @@ var a := 6; var b := 7; -print(a+b); +print( a + b ); diff --git a/testsuite/escript/compiler2/compiler2-023-const-optimized.src b/testsuite/escript/compiler2/compiler2-023-const-optimized.src index 5b6297c37..32189c2ba 100644 --- a/testsuite/escript/compiler2/compiler2-023-const-optimized.src +++ b/testsuite/escript/compiler2/compiler2-023-const-optimized.src @@ -1,4 +1,3 @@ const VALUE := 4 + 7; -print(VALUE); - +print( VALUE ); diff --git a/testsuite/escript/compiler2/compiler2-024-const-of-const-optimized.src b/testsuite/escript/compiler2/compiler2-024-const-of-const-optimized.src index 12de3c844..473ba85f2 100644 --- a/testsuite/escript/compiler2/compiler2-024-const-of-const-optimized.src +++ b/testsuite/escript/compiler2/compiler2-024-const-of-const-optimized.src @@ -2,5 +2,4 @@ const FIRST_PART := 4; const SECOND_PART := 7; const VALUE := FIRST_PART + SECOND_PART; -print(VALUE); - +print( VALUE ); diff --git a/testsuite/escript/compiler2/compiler2-025-if-is-true-optimized.src b/testsuite/escript/compiler2/compiler2-025-if-is-true-optimized.src index 200c238f1..b3d1fddd9 100644 --- a/testsuite/escript/compiler2/compiler2-025-if-is-true-optimized.src +++ b/testsuite/escript/compiler2/compiler2-025-if-is-true-optimized.src @@ -1,4 +1,3 @@ -if (5) - print("correct - path taken"); +if ( 5 ) + print( "correct - path taken" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-026-if-is-false-optimized.src b/testsuite/escript/compiler2/compiler2-026-if-is-false-optimized.src index 3f4994de5..ca964f35a 100644 --- a/testsuite/escript/compiler2/compiler2-026-if-is-false-optimized.src +++ b/testsuite/escript/compiler2/compiler2-026-if-is-false-optimized.src @@ -1,3 +1,3 @@ -if (0) - print("incorrect - path taken"); +if ( 0 ) + print( "incorrect - path taken" ); endif diff --git a/testsuite/escript/compiler2/compiler2-027-if-else-first-optimized.src b/testsuite/escript/compiler2/compiler2-027-if-else-first-optimized.src index 53caf488c..6a8d78e2c 100644 --- a/testsuite/escript/compiler2/compiler2-027-if-else-first-optimized.src +++ b/testsuite/escript/compiler2/compiler2-027-if-else-first-optimized.src @@ -1,6 +1,5 @@ -if (7) - print("correct - path taken"); +if ( 7 ) + print( "correct - path taken" ); else - print("incorrect - should not take else"); + print( "incorrect - should not take else" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-028-if-else-second-optimized.src b/testsuite/escript/compiler2/compiler2-028-if-else-second-optimized.src index f62d535de..0f3fc6497 100644 --- a/testsuite/escript/compiler2/compiler2-028-if-else-second-optimized.src +++ b/testsuite/escript/compiler2/compiler2-028-if-else-second-optimized.src @@ -1,6 +1,5 @@ -if (0) - print("incorrect - first path taken"); +if ( 0 ) + print( "incorrect - first path taken" ); else - print("correct - else path taken"); + print( "correct - else path taken" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-029-if-elseif-first-optimized.src b/testsuite/escript/compiler2/compiler2-029-if-elseif-first-optimized.src index d9091cf52..59f16e889 100644 --- a/testsuite/escript/compiler2/compiler2-029-if-elseif-first-optimized.src +++ b/testsuite/escript/compiler2/compiler2-029-if-elseif-first-optimized.src @@ -1,9 +1,8 @@ const a := 5; var b := 7; -if (a) - print("correct - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "correct - first path" ); +elseif ( b ) + print( "incorrect - second path" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-030-if-elseif-second-optimized.src b/testsuite/escript/compiler2/compiler2-030-if-elseif-second-optimized.src index 3f23c49e0..7f0c3a7df 100644 --- a/testsuite/escript/compiler2/compiler2-030-if-elseif-second-optimized.src +++ b/testsuite/escript/compiler2/compiler2-030-if-elseif-second-optimized.src @@ -1,9 +1,8 @@ const a := 0; const b := 7; -if (a) - print("incorrect - first path"); -elseif (b) - print("correct - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "correct - second path" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-031-if-elseif-neither-optimized.src b/testsuite/escript/compiler2/compiler2-031-if-elseif-neither-optimized.src index 798494dc0..f4505bf1e 100644 --- a/testsuite/escript/compiler2/compiler2-031-if-elseif-neither-optimized.src +++ b/testsuite/escript/compiler2/compiler2-031-if-elseif-neither-optimized.src @@ -1,10 +1,10 @@ const a := 0; const b := 0; -if (a) - print("incorrect - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "incorrect - second path" ); endif -print("correct - neither"); +print( "correct - neither" ); diff --git a/testsuite/escript/compiler2/compiler2-032-if-elseif-else-first-optimized.src b/testsuite/escript/compiler2/compiler2-032-if-elseif-else-first-optimized.src index d533027f5..4d15853a2 100644 --- a/testsuite/escript/compiler2/compiler2-032-if-elseif-else-first-optimized.src +++ b/testsuite/escript/compiler2/compiler2-032-if-elseif-else-first-optimized.src @@ -1,10 +1,10 @@ const a := 8; var b := 7; -if (a) - print("correct - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "correct - first path" ); +elseif ( b ) + print( "incorrect - second path" ); else - print("incorrect - third path"); + print( "incorrect - third path" ); endif diff --git a/testsuite/escript/compiler2/compiler2-033-if-elseif-else-second-optimized.src b/testsuite/escript/compiler2/compiler2-033-if-elseif-else-second-optimized.src index 7cde8e460..6f89b7ef4 100644 --- a/testsuite/escript/compiler2/compiler2-033-if-elseif-else-second-optimized.src +++ b/testsuite/escript/compiler2/compiler2-033-if-elseif-else-second-optimized.src @@ -1,10 +1,10 @@ const a := 0; const b := 7; -if (a) - print("incorrect - first path"); -elseif (b) - print("correct - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "correct - second path" ); else - print("incorrect - third path"); + print( "incorrect - third path" ); endif diff --git a/testsuite/escript/compiler2/compiler2-034-if-elseif-else-third-optimized.src b/testsuite/escript/compiler2/compiler2-034-if-elseif-else-third-optimized.src index 441776f02..ea00b85a5 100644 --- a/testsuite/escript/compiler2/compiler2-034-if-elseif-else-third-optimized.src +++ b/testsuite/escript/compiler2/compiler2-034-if-elseif-else-third-optimized.src @@ -1,10 +1,10 @@ const a := 0; const b := 0; -if (a) - print("incorrect - first path"); -elseif (b) - print("incorrect - second path"); +if ( a ) + print( "incorrect - first path" ); +elseif ( b ) + print( "incorrect - second path" ); else - print("correct - third path"); + print( "correct - third path" ); endif diff --git a/testsuite/escript/compiler2/compiler2-035-while-is-false.src b/testsuite/escript/compiler2/compiler2-035-while-is-false.src index 9baf04b87..a97d648db 100644 --- a/testsuite/escript/compiler2/compiler2-035-while-is-false.src +++ b/testsuite/escript/compiler2/compiler2-035-while-is-false.src @@ -1,6 +1,6 @@ var a := 0; -while (a) - print("incorrect - should not be taken"); +while ( a ) + print( "incorrect - should not be taken" ); endwhile -print("correct - exits loop"); \ No newline at end of file +print( "correct - exits loop" ); diff --git a/testsuite/escript/compiler2/compiler2-036-assign-to-global-var.src b/testsuite/escript/compiler2/compiler2-036-assign-to-global-var.src index 8ba2d74f1..5fea40adc 100644 --- a/testsuite/escript/compiler2/compiler2-036-assign-to-global-var.src +++ b/testsuite/escript/compiler2/compiler2-036-assign-to-global-var.src @@ -1,7 +1,7 @@ var a := 5; -print(a); +print( a ); a := 7; -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-037-while-single-pass.src b/testsuite/escript/compiler2/compiler2-037-while-single-pass.src index 1d65394eb..9e2a2227b 100644 --- a/testsuite/escript/compiler2/compiler2-037-while-single-pass.src +++ b/testsuite/escript/compiler2/compiler2-037-while-single-pass.src @@ -1,7 +1,7 @@ var a := 1; -while (a) - print("correct - should be taken (once)"); - a := 0; +while ( a ) + print( "correct - should be taken (once)" ); + a := 0; endwhile -print("correct - loop should exit"); +print( "correct - loop should exit" ); diff --git a/testsuite/escript/compiler2/compiler2-038-while-loop-and-exit.src b/testsuite/escript/compiler2/compiler2-038-while-loop-and-exit.src index 7e69884c3..e218ecb83 100644 --- a/testsuite/escript/compiler2/compiler2-038-while-loop-and-exit.src +++ b/testsuite/escript/compiler2/compiler2-038-while-loop-and-exit.src @@ -1,6 +1,6 @@ var i := 4; -while (i) - print( "i: " + i ); - i := i - 1; +while ( i ) + print( "i: " + i ); + i := i - 1; endwhile diff --git a/testsuite/escript/compiler2/compiler2-039-test-equality.src b/testsuite/escript/compiler2/compiler2-039-test-equality.src index 5845faad4..ea004002c 100644 --- a/testsuite/escript/compiler2/compiler2-039-test-equality.src +++ b/testsuite/escript/compiler2/compiler2-039-test-equality.src @@ -1,7 +1,6 @@ var a := 6; -if (a == 6) - print("correct"); +if ( a == 6 ) + print( "correct" ); else - print("incorrect"); + print( "incorrect" ); endif - diff --git a/testsuite/escript/compiler2/compiler2-040-early-exit-break.src b/testsuite/escript/compiler2/compiler2-040-early-exit-break.src index 3dc42faa1..c552db739 100644 --- a/testsuite/escript/compiler2/compiler2-040-early-exit-break.src +++ b/testsuite/escript/compiler2/compiler2-040-early-exit-break.src @@ -1,10 +1,10 @@ var i := 4; -while (i) - print( "i: " + i ); - i := i - 1; - if ( i == 2 ) - print("early exit"); - break; - endif +while ( i ) + print( "i: " + i ); + i := i - 1; + if ( i == 2 ) + print( "early exit" ); + break; + endif endwhile diff --git a/testsuite/escript/compiler2/compiler2-041-break-clean-up-locals.src b/testsuite/escript/compiler2/compiler2-041-break-clean-up-locals.src index aed409353..f8c06375c 100644 --- a/testsuite/escript/compiler2/compiler2-041-break-clean-up-locals.src +++ b/testsuite/escript/compiler2/compiler2-041-break-clean-up-locals.src @@ -1,4 +1,4 @@ -while (1) - var a := 4; - break; +while ( 1 ) + var a := 4; + break; endwhile diff --git a/testsuite/escript/compiler2/compiler2-042-while-continue-simple.src b/testsuite/escript/compiler2/compiler2-042-while-continue-simple.src index 6351ef41e..9ca2fe30d 100644 --- a/testsuite/escript/compiler2/compiler2-042-while-continue-simple.src +++ b/testsuite/escript/compiler2/compiler2-042-while-continue-simple.src @@ -1,9 +1,9 @@ var i := 4; -while (i) - i := i - 1; - if ( i == 2 ) - continue; - endif - print( "i: " + i ); +while ( i ) + i := i - 1; + if ( i == 2 ) + continue; + endif + print( "i: " + i ); endwhile diff --git a/testsuite/escript/compiler2/compiler2-043-while-break-labeled.src b/testsuite/escript/compiler2/compiler2-043-while-break-labeled.src index 867e3e9b4..42cfb678e 100644 --- a/testsuite/escript/compiler2/compiler2-043-while-break-labeled.src +++ b/testsuite/escript/compiler2/compiler2-043-while-break-labeled.src @@ -1,13 +1,12 @@ var a := 6; var b := 2; -outer: -while (a) - print("a"); - while(b) - print("b"); - break outer; - print("c"); - endwhile - print("d"); +outer: while ( a ) + print( "a" ); + while ( b ) + print( "b" ); + break outer; + print( "c" ); + endwhile + print( "d" ); endwhile diff --git a/testsuite/escript/compiler2/compiler2-044-integer-less-than-equal-to.src b/testsuite/escript/compiler2/compiler2-044-integer-less-than-equal-to.src index 24304f2a5..bf8ec948c 100644 --- a/testsuite/escript/compiler2/compiler2-044-integer-less-than-equal-to.src +++ b/testsuite/escript/compiler2/compiler2-044-integer-less-than-equal-to.src @@ -1,11 +1,11 @@ var a := 6; if ( a <= 5 ) - print("incorrect"); + print( "incorrect" ); endif if ( a <= 6 ) - print("correct"); + print( "correct" ); endif if ( a <= 7 ) - print("correct"); + print( "correct" ); endif diff --git a/testsuite/escript/compiler2/compiler2-045-integer-less-than.src b/testsuite/escript/compiler2/compiler2-045-integer-less-than.src index 941fc057c..a11404993 100644 --- a/testsuite/escript/compiler2/compiler2-045-integer-less-than.src +++ b/testsuite/escript/compiler2/compiler2-045-integer-less-than.src @@ -1,11 +1,11 @@ var a := 6; if ( a < 5 ) - print("incorrect"); + print( "incorrect" ); endif if ( a < 6 ) - print("incorrect"); + print( "incorrect" ); endif if ( a < 7 ) - print("correct"); + print( "correct" ); endif diff --git a/testsuite/escript/compiler2/compiler2-046-integer-greater-than-equal-to.src b/testsuite/escript/compiler2/compiler2-046-integer-greater-than-equal-to.src index d8cbc3fe6..7a5f21a81 100644 --- a/testsuite/escript/compiler2/compiler2-046-integer-greater-than-equal-to.src +++ b/testsuite/escript/compiler2/compiler2-046-integer-greater-than-equal-to.src @@ -1,11 +1,11 @@ var a := 6; if ( a >= 5 ) - print("correct"); + print( "correct" ); endif if ( a >= 6 ) - print("correct"); + print( "correct" ); endif if ( a >= 7 ) - print("incorrect"); + print( "incorrect" ); endif diff --git a/testsuite/escript/compiler2/compiler2-047-integer-greater-than.src b/testsuite/escript/compiler2/compiler2-047-integer-greater-than.src index 728fe1565..0a5f16a99 100644 --- a/testsuite/escript/compiler2/compiler2-047-integer-greater-than.src +++ b/testsuite/escript/compiler2/compiler2-047-integer-greater-than.src @@ -1,11 +1,11 @@ var a := 6; if ( a > 5 ) - print("correct"); + print( "correct" ); endif if ( a > 6 ) - print("incorrect"); + print( "incorrect" ); endif if ( a > 7 ) - print("incorrect"); + print( "incorrect" ); endif diff --git a/testsuite/escript/compiler2/compiler2-048-case-integer-simple.src b/testsuite/escript/compiler2/compiler2-048-case-integer-simple.src index 9959492df..9b111b8d2 100644 --- a/testsuite/escript/compiler2/compiler2-048-case-integer-simple.src +++ b/testsuite/escript/compiler2/compiler2-048-case-integer-simple.src @@ -1,8 +1,6 @@ var a := 5; -case (a) - 4: - print( "four" ); - 5: - print( "five" ); +case ( a ) + 4: print( "four" ); + 5: print( "five" ); endcase -print("done"); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/compiler2/compiler2-049-global-var-declaration-multiple.src b/testsuite/escript/compiler2/compiler2-049-global-var-declaration-multiple.src index 7c6eaa71e..ba2874f23 100644 --- a/testsuite/escript/compiler2/compiler2-049-global-var-declaration-multiple.src +++ b/testsuite/escript/compiler2/compiler2-049-global-var-declaration-multiple.src @@ -1,3 +1,3 @@ var a := 2, b; -print(a); -print(b); +print( a ); +print( b ); diff --git a/testsuite/escript/compiler2/compiler2-050-case-with-labeled-while.src b/testsuite/escript/compiler2/compiler2-050-case-with-labeled-while.src index 29d80532e..df7b4414f 100644 --- a/testsuite/escript/compiler2/compiler2-050-case-with-labeled-while.src +++ b/testsuite/escript/compiler2/compiler2-050-case-with-labeled-while.src @@ -4,17 +4,14 @@ // and change it to be the label of the outer while-loop. var a := 5; -case (a) - 4: - outer: - while (1) - inner: - while(1) - break outer; - endwhile - endwhile - - 5: - print( "five" ); +case ( a ) + 4: + outer: + while ( 1 ) + inner: while ( 1 ) + break outer; + endwhile + endwhile + 5: print( "five" ); endcase -print("done"); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/compiler2/compiler2-051-case-with-labeled-while-after-statement.src b/testsuite/escript/compiler2/compiler2-051-case-with-labeled-while-after-statement.src index 40f486133..16a5d4bbd 100644 --- a/testsuite/escript/compiler2/compiler2-051-case-with-labeled-while-after-statement.src +++ b/testsuite/escript/compiler2/compiler2-051-case-with-labeled-while-after-statement.src @@ -1,18 +1,14 @@ // The parser chose the meaning that matches the semantic meaning. var a := 5; -case (a) - 4: - print("4"); - outer: - while (1) - inner: - while(1) - break outer; - endwhile - endwhile - - 5: - print( "five" ); +case ( a ) + 4: + print( "4" ); + outer: while ( 1 ) + inner: while ( 1 ) + break outer; + endwhile + endwhile + 5: print( "five" ); endcase -print("done"); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/compiler2/compiler2-052-case-with-selector-attached-to-loop.src b/testsuite/escript/compiler2/compiler2-052-case-with-selector-attached-to-loop.src index f7eeae4d4..ed3464a46 100644 --- a/testsuite/escript/compiler2/compiler2-052-case-with-selector-attached-to-loop.src +++ b/testsuite/escript/compiler2/compiler2-052-case-with-selector-attached-to-loop.src @@ -4,19 +4,16 @@ // split the group into two. const FIVE := 5; var a := 5; -case (a) - 4: - print("4"); - FIVE: - while (1) - while(1) - print( "five" ); - break; - endwhile - break; - endwhile - - 6: - print( "six" ); +case ( a ) + 4: + print( "4" ); + FIVE: while ( 1 ) + while ( 1 ) + print( "five" ); + break; + endwhile + break; + endwhile + 6: print( "six" ); endcase -print("done"); +print( "done" ); diff --git a/testsuite/escript/compiler2/compiler2-053-array-initialization-braces.src b/testsuite/escript/compiler2/compiler2-053-array-initialization-braces.src index 43e15ad92..57cd3fad6 100644 --- a/testsuite/escript/compiler2/compiler2-053-array-initialization-braces.src +++ b/testsuite/escript/compiler2/compiler2-053-array-initialization-braces.src @@ -1,2 +1,2 @@ var a := { 82, 54, 22, "x" }; -print(a); +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-054-foreach-basic.src b/testsuite/escript/compiler2/compiler2-054-foreach-basic.src index 939648175..c0883a775 100644 --- a/testsuite/escript/compiler2/compiler2-054-foreach-basic.src +++ b/testsuite/escript/compiler2/compiler2-054-foreach-basic.src @@ -1,5 +1,4 @@ var a := { 82, 54, 22, "x" }; foreach i in a - print(i); + print( i ); endforeach - diff --git a/testsuite/escript/compiler2/compiler2-055-do-while-basic.src b/testsuite/escript/compiler2/compiler2-055-do-while-basic.src index 5cf042278..dfbfff58a 100644 --- a/testsuite/escript/compiler2/compiler2-055-do-while-basic.src +++ b/testsuite/escript/compiler2/compiler2-055-do-while-basic.src @@ -1,8 +1,8 @@ var i := 0; do - print(i); - i := i + 1; -dowhile (i < 10); + print( i ); + i := i + 1; +dowhile ( i < 10 ); -print("done"); +print( "done" ); diff --git a/testsuite/escript/compiler2/compiler2-056-dictionary-empty.src b/testsuite/escript/compiler2/compiler2-056-dictionary-empty.src index 7aed610c9..d6ccd247f 100644 --- a/testsuite/escript/compiler2/compiler2-056-dictionary-empty.src +++ b/testsuite/escript/compiler2/compiler2-056-dictionary-empty.src @@ -1,2 +1,2 @@ var d := dictionary{}; -print(d); +print( d ); diff --git a/testsuite/escript/compiler2/compiler2-057-dictionary-add-integer-key.src b/testsuite/escript/compiler2/compiler2-057-dictionary-add-integer-key.src index 6b3040c4f..e8061cb17 100644 --- a/testsuite/escript/compiler2/compiler2-057-dictionary-add-integer-key.src +++ b/testsuite/escript/compiler2/compiler2-057-dictionary-add-integer-key.src @@ -1,3 +1,3 @@ var d := dictionary{}; d[11] := "an element"; -print(d); +print( d ); diff --git a/testsuite/escript/compiler2/compiler2-058-assign-float.src b/testsuite/escript/compiler2/compiler2-058-assign-float.src index 0cf6788f1..d5c03a5bd 100644 --- a/testsuite/escript/compiler2/compiler2-058-assign-float.src +++ b/testsuite/escript/compiler2/compiler2-058-assign-float.src @@ -1,3 +1,2 @@ var d := 1.4; -print(d); - +print( d ); diff --git a/testsuite/escript/compiler2/compiler2-059-dictionary-initializer-integers.src b/testsuite/escript/compiler2/compiler2-059-dictionary-initializer-integers.src index e1c809d7e..c296cd71e 100644 --- a/testsuite/escript/compiler2/compiler2-059-dictionary-initializer-integers.src +++ b/testsuite/escript/compiler2/compiler2-059-dictionary-initializer-integers.src @@ -1,2 +1,2 @@ -var d := dictionary { 5 -> "hey", 7 -> "you" }; -print(d); +var d := dictionary{ 5 -> "hey", 7 -> "you" }; +print( d ); diff --git a/testsuite/escript/compiler2/compiler2-060-struct-empty.src b/testsuite/escript/compiler2/compiler2-060-struct-empty.src index aee3e398b..02b6d1540 100644 --- a/testsuite/escript/compiler2/compiler2-060-struct-empty.src +++ b/testsuite/escript/compiler2/compiler2-060-struct-empty.src @@ -1,2 +1,2 @@ var d := struct{}; -print(d); +print( d ); diff --git a/testsuite/escript/compiler2/compiler2-061-struct-with-uninit-member.src b/testsuite/escript/compiler2/compiler2-061-struct-with-uninit-member.src index 5908c2a86..4af779a19 100644 --- a/testsuite/escript/compiler2/compiler2-061-struct-with-uninit-member.src +++ b/testsuite/escript/compiler2/compiler2-061-struct-with-uninit-member.src @@ -1,2 +1,2 @@ -var a:=struct{ abc }; -print(a); +var a := struct{ abc }; +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-062-assign-to-struct-member.src b/testsuite/escript/compiler2/compiler2-062-assign-to-struct-member.src index d7bcb9479..3cdf2af79 100644 --- a/testsuite/escript/compiler2/compiler2-062-assign-to-struct-member.src +++ b/testsuite/escript/compiler2/compiler2-062-assign-to-struct-member.src @@ -1,3 +1,3 @@ -var a:=struct{ b }; +var a := struct{ b }; a.b := 4; -print(a); +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-063-struct-with-initialized-member.src b/testsuite/escript/compiler2/compiler2-063-struct-with-initialized-member.src index f7f1c66ec..1d6365eca 100644 --- a/testsuite/escript/compiler2/compiler2-063-struct-with-initialized-member.src +++ b/testsuite/escript/compiler2/compiler2-063-struct-with-initialized-member.src @@ -1,2 +1,2 @@ -var a:=struct{ aaabb := 62 }; -print(a); +var a := struct{ aaabb := 62 }; +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-064-get-struct-member.src b/testsuite/escript/compiler2/compiler2-064-get-struct-member.src index fb3cb567d..bcbef0052 100644 --- a/testsuite/escript/compiler2/compiler2-064-get-struct-member.src +++ b/testsuite/escript/compiler2/compiler2-064-get-struct-member.src @@ -1,2 +1,2 @@ -var a:=struct{ aaabb := 77 }; -print(a.aaabb); +var a := struct{ aaabb := 77 }; +print( a.aaabb ); diff --git a/testsuite/escript/compiler2/compiler2-065-get-struct-known-member.src b/testsuite/escript/compiler2/compiler2-065-get-struct-known-member.src index 28da7f1d1..91066b9d0 100644 --- a/testsuite/escript/compiler2/compiler2-065-get-struct-known-member.src +++ b/testsuite/escript/compiler2/compiler2-065-get-struct-known-member.src @@ -1,2 +1,2 @@ -var a:=struct{ quality := 99 }; -print(a.quality); +var a := struct{ quality := 99 }; +print( a.quality ); diff --git a/testsuite/escript/compiler2/compiler2-066-error-empty.src b/testsuite/escript/compiler2/compiler2-066-error-empty.src index b9ebecb64..eea82e1e3 100644 --- a/testsuite/escript/compiler2/compiler2-066-error-empty.src +++ b/testsuite/escript/compiler2/compiler2-066-error-empty.src @@ -1,2 +1,2 @@ var a := error; -print(a); +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-067-error-with-initialized-member.src b/testsuite/escript/compiler2/compiler2-067-error-with-initialized-member.src index 6c907cde0..b49711147 100644 --- a/testsuite/escript/compiler2/compiler2-067-error-with-initialized-member.src +++ b/testsuite/escript/compiler2/compiler2-067-error-with-initialized-member.src @@ -1,2 +1,2 @@ -var a := error { abc := 62 }; -print(a); +var a := error{ abc := 62 }; +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-068-repeat-until-simple.src b/testsuite/escript/compiler2/compiler2-068-repeat-until-simple.src index bc1957ea7..38efa88a4 100644 --- a/testsuite/escript/compiler2/compiler2-068-repeat-until-simple.src +++ b/testsuite/escript/compiler2/compiler2-068-repeat-until-simple.src @@ -1,5 +1,5 @@ var i := 6; repeat - print(i); - i := i + 1; -until (i == 11); + print( i ); + i := i + 1; +until ( i == 11 ); diff --git a/testsuite/escript/compiler2/compiler2-070-substring.src b/testsuite/escript/compiler2/compiler2-070-substring.src index 1e1da8280..a10ab846f 100644 --- a/testsuite/escript/compiler2/compiler2-070-substring.src +++ b/testsuite/escript/compiler2/compiler2-070-substring.src @@ -1,3 +1,3 @@ var s := "abcdefg"; -print( s[2,3] ); +print( s[2, 3] ); diff --git a/testsuite/escript/compiler2/compiler2-071-exported-function.src b/testsuite/escript/compiler2/compiler2-071-exported-function.src index 590951ba6..ca0650a08 100644 --- a/testsuite/escript/compiler2/compiler2-071-exported-function.src +++ b/testsuite/escript/compiler2/compiler2-071-exported-function.src @@ -1,6 +1,6 @@ -exported function foo(a,b) - print( a + b ); - return a+b; +exported function foo( a, b ) + print( a + b ); + return a + b; endfunction -foo(3,2); +foo( 3, 2 ); diff --git a/testsuite/escript/compiler2/compiler2-072-negative-hex.src b/testsuite/escript/compiler2/compiler2-072-negative-hex.src index 76e7c1586..88c3f8221 100644 --- a/testsuite/escript/compiler2/compiler2-072-negative-hex.src +++ b/testsuite/escript/compiler2/compiler2-072-negative-hex.src @@ -1,2 +1,2 @@ var t := -0Xff; -print(t); +print( t ); diff --git a/testsuite/escript/compiler2/compiler2-073-integer-plusequals.src b/testsuite/escript/compiler2/compiler2-073-integer-plusequals.src index 7abe94806..29b6c4d35 100644 --- a/testsuite/escript/compiler2/compiler2-073-integer-plusequals.src +++ b/testsuite/escript/compiler2/compiler2-073-integer-plusequals.src @@ -1,4 +1,4 @@ var a := 4; -print(a); +print( a ); a += 2; -print(a); +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-074-negative-float.src b/testsuite/escript/compiler2/compiler2-074-negative-float.src index fa9375e0d..510d06720 100644 --- a/testsuite/escript/compiler2/compiler2-074-negative-float.src +++ b/testsuite/escript/compiler2/compiler2-074-negative-float.src @@ -1,2 +1,2 @@ var t := -2147483648.123456; -print(t); +print( t ); diff --git a/testsuite/escript/compiler2/compiler2-075-modulus.src b/testsuite/escript/compiler2/compiler2-075-modulus.src index 41f8eadd5..b22aa82f3 100644 --- a/testsuite/escript/compiler2/compiler2-075-modulus.src +++ b/testsuite/escript/compiler2/compiler2-075-modulus.src @@ -1,2 +1,2 @@ var t := 8 % 3; -print(t); +print( t ); diff --git a/testsuite/escript/compiler2/compiler2-076-struct-addmember.src b/testsuite/escript/compiler2/compiler2-076-struct-addmember.src index 58acf6e42..b9352f460 100644 --- a/testsuite/escript/compiler2/compiler2-076-struct-addmember.src +++ b/testsuite/escript/compiler2/compiler2-076-struct-addmember.src @@ -1,3 +1,3 @@ var a := struct; a.+b := "added"; -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-077-struct-addmember-by-expression.src b/testsuite/escript/compiler2/compiler2-077-struct-addmember-by-expression.src index 76e345757..fb7fe68b1 100644 --- a/testsuite/escript/compiler2/compiler2-077-struct-addmember-by-expression.src +++ b/testsuite/escript/compiler2/compiler2-077-struct-addmember-by-expression.src @@ -1,5 +1,5 @@ var a := struct; var b := "x"; var c := "y"; -a .+ (b+c) := "added"; -print(a); +a.+( b + c ) := "added"; +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-078-program-after-globals.src b/testsuite/escript/compiler2/compiler2-078-program-after-globals.src index ac3077158..cb2eee59c 100644 --- a/testsuite/escript/compiler2/compiler2-078-program-after-globals.src +++ b/testsuite/escript/compiler2/compiler2-078-program-after-globals.src @@ -2,6 +2,6 @@ // at the end of the program block. var a, b, c, d; -program foo(e) +program foo( e ) var f, g; endprogram diff --git a/testsuite/escript/compiler2/compiler2-079-double-optimization-addition.src b/testsuite/escript/compiler2/compiler2-079-double-optimization-addition.src index 33397a3e0..4abed73cb 100644 --- a/testsuite/escript/compiler2/compiler2-079-double-optimization-addition.src +++ b/testsuite/escript/compiler2/compiler2-079-double-optimization-addition.src @@ -1 +1 @@ -print(6.4 + 7.8); +print( 6.4 + 7.8 ); diff --git a/testsuite/escript/compiler2/compiler2-080-string-optimization-concatenation.src b/testsuite/escript/compiler2/compiler2-080-string-optimization-concatenation.src index f629a5480..532533c3a 100644 --- a/testsuite/escript/compiler2/compiler2-080-string-optimization-concatenation.src +++ b/testsuite/escript/compiler2/compiler2-080-string-optimization-concatenation.src @@ -1 +1 @@ -print("a" + "b"); +print( "a" + "b" ); diff --git a/testsuite/escript/compiler2/compiler2-081-call-known-method.src b/testsuite/escript/compiler2/compiler2-081-call-known-method.src index e3d8bea04..ea1fa53a2 100644 --- a/testsuite/escript/compiler2/compiler2-081-call-known-method.src +++ b/testsuite/escript/compiler2/compiler2-081-call-known-method.src @@ -1,2 +1,2 @@ var s := "abcdef"; -print(s.find("cd")); +print( s.find( "cd" ) ); diff --git a/testsuite/escript/compiler2/compiler2-082-ambiguity-addition.src b/testsuite/escript/compiler2/compiler2-082-ambiguity-addition.src index 8b866ebcc..770c8035e 100644 --- a/testsuite/escript/compiler2/compiler2-082-ambiguity-addition.src +++ b/testsuite/escript/compiler2/compiler2-082-ambiguity-addition.src @@ -1,14 +1,14 @@ var a := 2, b := 3, c := 5, d := 7, e := 11, f := 13; var x := a + b + c + d + e + f; -print(x); +print( x ); var y := a + b * c + d * e + f; -print(y); +print( y ); -//var y := a + c.b + d.e + +// var y := a + c.b + d.e + -//a.d -//a.+d -//a.-f -//a.?f -//++a.b +// a.d +// a.+d +// a.-f +// a.?f +// ++a.b diff --git a/testsuite/escript/compiler2/compiler2-083-declare-array-short.src b/testsuite/escript/compiler2/compiler2-083-declare-array-short.src index ad38a0e39..698e93fa3 100644 --- a/testsuite/escript/compiler2/compiler2-083-declare-array-short.src +++ b/testsuite/escript/compiler2/compiler2-083-declare-array-short.src @@ -1,2 +1,2 @@ var a array; -print(a); +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-084-replace-substring.src b/testsuite/escript/compiler2/compiler2-084-replace-substring.src index 3453bcdf1..a71a969c6 100644 --- a/testsuite/escript/compiler2/compiler2-084-replace-substring.src +++ b/testsuite/escript/compiler2/compiler2-084-replace-substring.src @@ -1,3 +1,3 @@ var a := "abcdef"; -a[2,3] := "zyx"; -print(a); +a[2, 3] := "zyx"; +print( a ); diff --git a/testsuite/escript/compiler2/compiler2-085-unicode-characters.src b/testsuite/escript/compiler2/compiler2-085-unicode-characters.src index 97731b324..5bc49f420 100644 --- a/testsuite/escript/compiler2/compiler2-085-unicode-characters.src +++ b/testsuite/escript/compiler2/compiler2-085-unicode-characters.src @@ -1,4 +1,4 @@ // This file contains invalid UTF8 characters and should fail to compile// but its valid ISO8859 -> fallback should work -//var i:=" àòùç"; -var i:=" àòùç"; +// var i:=" àòùç"; +var i := " àòùç"; diff --git a/testsuite/escript/compiler2/compiler2-086-tilde-integer.src b/testsuite/escript/compiler2/compiler2-086-tilde-integer.src index d903160c8..ad20767e9 100644 --- a/testsuite/escript/compiler2/compiler2-086-tilde-integer.src +++ b/testsuite/escript/compiler2/compiler2-086-tilde-integer.src @@ -1,3 +1,2 @@ var t := 0x88; -print( ~ t ); - +print( ~t ); diff --git a/testsuite/escript/compiler2/compiler2-087-pass-array-elem-byref.src b/testsuite/escript/compiler2/compiler2-087-pass-array-elem-byref.src index 957c139ee..8490d4c89 100644 --- a/testsuite/escript/compiler2/compiler2-087-pass-array-elem-byref.src +++ b/testsuite/escript/compiler2/compiler2-087-pass-array-elem-byref.src @@ -1,10 +1,10 @@ function foo( byref elem ) - elem := 12; + elem := 12; endfunction program array12() - var a := { 82, 43, 56, 23, 51 }; - print(a); - foo( a[2] ); - print(a); -endprogram \ No newline at end of file + var a := { 82, 43, 56, 23, 51 }; + print( a ); + foo( a[2] ); + print( a ); +endprogram diff --git a/testsuite/escript/compiler2/compiler2-088-local-variable-shadowing.src b/testsuite/escript/compiler2/compiler2-088-local-variable-shadowing.src index c2e4ac368..b4ff6d763 100644 --- a/testsuite/escript/compiler2/compiler2-088-local-variable-shadowing.src +++ b/testsuite/escript/compiler2/compiler2-088-local-variable-shadowing.src @@ -1,11 +1,11 @@ // Make sure locals in sub-blocks can override other locals program foo() - var a := 5; - print( "1. A=" + a ); - if (2) - var a; - a := 7; - print( "2. A=" + a ); - endif - print( "3. A=" + a ); + var a := 5; + print( "1. A=" + a ); + if ( 2 ) + var a; + a := 7; + print( "2. A=" + a ); + endif + print( "3. A=" + a ); endprogram diff --git a/testsuite/escript/compiler2/compiler2-089-optimizer-removes-unreferenced-functions.src b/testsuite/escript/compiler2/compiler2-089-optimizer-removes-unreferenced-functions.src index 49d495c2c..41579885b 100644 --- a/testsuite/escript/compiler2/compiler2-089-optimizer-removes-unreferenced-functions.src +++ b/testsuite/escript/compiler2/compiler2-089-optimizer-removes-unreferenced-functions.src @@ -4,22 +4,22 @@ const ZERO := 0; -function caller(x) - if (!ZERO) - included(); - else - optimized_out(); - endif +function caller( x ) + if ( !ZERO ) + included(); + else + optimized_out(); + endif endfunction function included() - return "included"; + return "included"; endfunction function optimized_out() - return "optimized out"; + return "optimized out"; endfunction program foo() - print(caller(2)); + print( caller( 2 ) ); endprogram diff --git a/testsuite/escript/compiler2/compiler2-090-basic-for-simple.src b/testsuite/escript/compiler2/compiler2-090-basic-for-simple.src index 04945bad3..3702d859a 100644 --- a/testsuite/escript/compiler2/compiler2-090-basic-for-simple.src +++ b/testsuite/escript/compiler2/compiler2-090-basic-for-simple.src @@ -1,3 +1,3 @@ for i := 1 to 4 - print(i); + print( i ); endfor diff --git a/testsuite/escript/compiler2/compiler2-091-optimize-increment-member-by-id.src b/testsuite/escript/compiler2/compiler2-091-optimize-increment-member-by-id.src index faea21ecb..917b53003 100644 --- a/testsuite/escript/compiler2/compiler2-091-optimize-increment-member-by-id.src +++ b/testsuite/escript/compiler2/compiler2-091-optimize-increment-member-by-id.src @@ -1,3 +1,3 @@ -var s:=struct{resist_fire_mod}; +var s := struct{ resist_fire_mod }; s.resist_fire_mod += 1; -print(s); +print( s ); diff --git a/testsuite/escript/compiler2/compiler2-092-member-pre-decrement.src b/testsuite/escript/compiler2/compiler2-092-member-pre-decrement.src index ab1735347..906a42878 100644 --- a/testsuite/escript/compiler2/compiler2-092-member-pre-decrement.src +++ b/testsuite/escript/compiler2/compiler2-092-member-pre-decrement.src @@ -1,4 +1,4 @@ -var s:=struct{resist_fire_mod:=6}; // reserved name, converts to get_member_id -var i:=--s.resist_fire_mod; -print(i); -print(s); +var s := struct{ resist_fire_mod := 6 }; // reserved name, converts to get_member_id +var i := --s.resist_fire_mod; +print( i ); +print( s ); diff --git a/testsuite/escript/compiler2/compiler2-093-predecrement.src b/testsuite/escript/compiler2/compiler2-093-predecrement.src index 8e3905ca1..e8355db8d 100644 --- a/testsuite/escript/compiler2/compiler2-093-predecrement.src +++ b/testsuite/escript/compiler2/compiler2-093-predecrement.src @@ -4,6 +4,6 @@ var ii; // The OG optimizer had a bug where would exit early // after not optimizing (ii-), and so it would // not optimize the global assignment + consume. -ii := 1 - (--i); -print(i); -print(ii); +ii := 1 - ( --i ); +print( i ); +print( ii ); diff --git a/testsuite/escript/compiler2/compiler2-094-funcref-assign-call.src b/testsuite/escript/compiler2/compiler2-094-funcref-assign-call.src index fe57a6888..49b9f8746 100644 --- a/testsuite/escript/compiler2/compiler2-094-funcref-assign-call.src +++ b/testsuite/escript/compiler2/compiler2-094-funcref-assign-call.src @@ -1,6 +1,6 @@ function foo() - print("correct"); + print( "correct" ); endfunction -var f:=@foo; +var f := @foo; f.call(); diff --git a/testsuite/escript/compiler2/compiler2-095-funcref-with-params.src b/testsuite/escript/compiler2/compiler2-095-funcref-with-params.src index 86b108cab..b7e7168fd 100644 --- a/testsuite/escript/compiler2/compiler2-095-funcref-with-params.src +++ b/testsuite/escript/compiler2/compiler2-095-funcref-with-params.src @@ -1,7 +1,7 @@ -function foo(a, b) - print(a); - print(b); +function foo( a, b ) + print( a ); + print( b ); endfunction -var f:=@foo; -f.call("X", "yy"); +var f := @foo; +f.call( "X", "yy" ); diff --git a/testsuite/escript/compiler2/compiler2-097-modulefunc-register-order.src b/testsuite/escript/compiler2/compiler2-097-modulefunc-register-order.src index 1e7386ba3..25c0f08c2 100644 --- a/testsuite/escript/compiler2/compiler2-097-modulefunc-register-order.src +++ b/testsuite/escript/compiler2/compiler2-097-modulefunc-register-order.src @@ -1,4 +1,3 @@ // OG compiler emits lower as function 0 // there's no way to tell from the runtime output though. -print(lower(upper("abc"))); - +print( lower( upper( "abc" ) ) ); diff --git a/testsuite/escript/compiler2/compiler2-098-embedded-quote.src b/testsuite/escript/compiler2/compiler2-098-embedded-quote.src index cb1878c80..e82cbfdbb 100644 --- a/testsuite/escript/compiler2/compiler2-098-embedded-quote.src +++ b/testsuite/escript/compiler2/compiler2-098-embedded-quote.src @@ -1,3 +1,3 @@ -var s := "il1[]]]]]]]]]\""+ // 5 - "bcejotâ€(){}==="; // 6 -print(s); +var s := "il1[]]]]]]]]]\"" + // 5 + "bcejotâ€(){}==="; // 6 +print( s ); diff --git a/testsuite/escript/compiler2/compiler2-099-chained-method-call.src b/testsuite/escript/compiler2/compiler2-099-chained-method-call.src index 61e4c14c8..3ee4dcd02 100644 --- a/testsuite/escript/compiler2/compiler2-099-chained-method-call.src +++ b/testsuite/escript/compiler2/compiler2-099-chained-method-call.src @@ -1,4 +1,4 @@ var a := { "a", "b", "c", "d", "e", "f" }; var s; -s := "-".join(a).find("c-d"); -print(s); // expect 5 \ No newline at end of file +s := "-".join( a ).find( "c-d" ); +print( s ); // expect 5 diff --git a/testsuite/escript/compiler2/compiler2-100-syntax-error.src b/testsuite/escript/compiler2/compiler2-100-syntax-error.src index 571a5a33c..f986a01c9 100644 --- a/testsuite/escript/compiler2/compiler2-100-syntax-error.src +++ b/testsuite/escript/compiler2/compiler2-100-syntax-error.src @@ -1,12 +1,11 @@ - function foo() -var a; -// This used to report a syntax error here: -//var x := TargetCoordinates(a); -var x := a["d"]."range"; -print(x); + var a; + // This used to report a syntax error here: + // var x := TargetCoordinates(a); + var x := a["d"]."range"; + print( x ); endfunction -foo(); \ No newline at end of file +foo(); diff --git a/testsuite/escript/compiler2/compiler2-101-case-group-with-empty-block.src b/testsuite/escript/compiler2/compiler2-101-case-group-with-empty-block.src index c0aefe92c..01496a2d2 100644 --- a/testsuite/escript/compiler2/compiler2-101-case-group-with-empty-block.src +++ b/testsuite/escript/compiler2/compiler2-101-case-group-with-empty-block.src @@ -2,8 +2,8 @@ const X := 1; const Y := 2; var a := 1; -case (a) - X: print("x!"); - Y: +case ( a ) + X: print( "x!" ); + Y: endcase -print("complete"); \ No newline at end of file +print( "complete" ); diff --git a/testsuite/escript/compiler2/compiler2-103-navigation-by-string-literal.src b/testsuite/escript/compiler2/compiler2-103-navigation-by-string-literal.src index 899e2aed7..8be242ea5 100644 --- a/testsuite/escript/compiler2/compiler2-103-navigation-by-string-literal.src +++ b/testsuite/escript/compiler2/compiler2-103-navigation-by-string-literal.src @@ -1,3 +1,2 @@ -var a := struct { b := "xyz" }; +var a := struct{ b := "xyz" }; print( a."b" ); - diff --git a/testsuite/escript/compiler2/compiler2-104-exit.src b/testsuite/escript/compiler2/compiler2-104-exit.src index 198ffe70e..b3e1af440 100644 --- a/testsuite/escript/compiler2/compiler2-104-exit.src +++ b/testsuite/escript/compiler2/compiler2-104-exit.src @@ -1,4 +1,3 @@ -print("hello"); +print( "hello" ); exit; -print("incorrect"); - +print( "incorrect" ); diff --git a/testsuite/escript/compiler2/compiler2-105-module-function-og-parity.src b/testsuite/escript/compiler2/compiler2-105-module-function-og-parity.src index 4223deff6..896cac2dc 100644 --- a/testsuite/escript/compiler2/compiler2-105-module-function-og-parity.src +++ b/testsuite/escript/compiler2/compiler2-105-module-function-og-parity.src @@ -1,5 +1,5 @@ var ev; var following; following := ev.upper; // OG compiler assigns (used to assign) basic.Upper() to function index #0 here -print(Lower("A")); -print(Upper("b")); +print( Lower( "A" ) ); +print( Upper( "b" ) ); diff --git a/testsuite/escript/compiler2/compiler2-106-exported-function.src b/testsuite/escript/compiler2/compiler2-106-exported-function.src index b163e9bee..31590dda9 100644 --- a/testsuite/escript/compiler2/compiler2-106-exported-function.src +++ b/testsuite/escript/compiler2/compiler2-106-exported-function.src @@ -1,8 +1,7 @@ program Install() - return 1; + return 1; endprogram exported function foo() - print("hello"); + print( "hello" ); endfunction - diff --git a/testsuite/escript/compiler2/compiler2-107-lower-case-method-names.src b/testsuite/escript/compiler2/compiler2-107-lower-case-method-names.src index e682309f2..b099d2748 100644 --- a/testsuite/escript/compiler2/compiler2-107-lower-case-method-names.src +++ b/testsuite/escript/compiler2/compiler2-107-lower-case-method-names.src @@ -1,4 +1,3 @@ var a; -a.SetForArea("a", "b"); - +a.SetForArea( "a", "b" ); diff --git a/testsuite/escript/compiler2/compiler2-108-enum-after-constant-silently-ignored.src b/testsuite/escript/compiler2/compiler2-108-enum-after-constant-silently-ignored.src index c4e95301f..6cceb3b80 100644 --- a/testsuite/escript/compiler2/compiler2-108-enum-after-constant-silently-ignored.src +++ b/testsuite/escript/compiler2/compiler2-108-enum-after-constant-silently-ignored.src @@ -1,7 +1,7 @@ const A := 52; enum B - A := 37 // really, expect a compiler error but.. + A := 37 // really, expect a compiler error but.. endenum -print(A); // expect 52 +print( A ); // expect 52 diff --git a/testsuite/escript/compiler2/compiler2-109-double-enum-second-ignored.src b/testsuite/escript/compiler2/compiler2-109-double-enum-second-ignored.src index ff7a65178..2ee801f70 100644 --- a/testsuite/escript/compiler2/compiler2-109-double-enum-second-ignored.src +++ b/testsuite/escript/compiler2/compiler2-109-double-enum-second-ignored.src @@ -1,7 +1,7 @@ enum X - A := 6, - B := 7, - A := 8 // a compiler error here would be nice + A := 6, + B := 7, + A := 8 // a compiler error here would be nice endenum -print(A); // current behavior is 6 +print( A ); // current behavior is 6 diff --git a/testsuite/escript/compiler2/compiler2-110-return-assignment.src b/testsuite/escript/compiler2/compiler2-110-return-assignment.src index 3fadeb7e1..3d2b67f04 100644 --- a/testsuite/escript/compiler2/compiler2-110-return-assignment.src +++ b/testsuite/escript/compiler2/compiler2-110-return-assignment.src @@ -1,10 +1,9 @@ -var a := struct { x := 2, y := 3 }; +var a := struct{ x := 2, y := 3 }; function foo() - // There was a bug where the := was generated already consuming itself, - // but return consumes it here. - return a.x := a.y; + // There was a bug where the := was generated already consuming itself, + // but return consumes it here. + return a.x := a.y; endfunction -print(foo()); - +print( foo() ); diff --git a/testsuite/escript/compiler2/compiler2-111-program-no-func-conversions.src b/testsuite/escript/compiler2/compiler2-111-program-no-func-conversions.src index 5a58c9372..ec7375478 100644 --- a/testsuite/escript/compiler2/compiler2-111-program-no-func-conversions.src +++ b/testsuite/escript/compiler2/compiler2-111-program-no-func-conversions.src @@ -1,9 +1,6 @@ program foo() - - print("abcd".Find("b")); + print( "abcd".Find( "b" ) ); endprogram - - diff --git a/testsuite/escript/compiler2/compiler2-112-foreach-expression-scope.src b/testsuite/escript/compiler2/compiler2-112-foreach-expression-scope.src index 267eb4209..e734df5e0 100644 --- a/testsuite/escript/compiler2/compiler2-112-foreach-expression-scope.src +++ b/testsuite/escript/compiler2/compiler2-112-foreach-expression-scope.src @@ -5,6 +5,5 @@ var thing := { "a", "b", "c", "d" }; foreach thing in { thing[1], thing[2], thing[3], thing[4] } - print(thing); + print( thing ); endforeach - diff --git a/testsuite/escript/compiler2/compiler2-113-basic-for-expression-scope.src b/testsuite/escript/compiler2/compiler2-113-basic-for-expression-scope.src index 531b03f73..9e2706eee 100644 --- a/testsuite/escript/compiler2/compiler2-113-basic-for-expression-scope.src +++ b/testsuite/escript/compiler2/compiler2-113-basic-for-expression-scope.src @@ -7,5 +7,5 @@ var a := 1; var b := 8; for a := a to b - print(a); + print( a ); endfor diff --git a/testsuite/escript/compiler2/compiler2-114-case-extra-jump.src b/testsuite/escript/compiler2/compiler2-114-case-extra-jump.src index 96ec49696..467f99f90 100644 --- a/testsuite/escript/compiler2/compiler2-114-case-extra-jump.src +++ b/testsuite/escript/compiler2/compiler2-114-case-extra-jump.src @@ -1,25 +1,23 @@ use util; -const SKILLID_BLACKSMITHY := 7; -const SKILLID_TAILORING := 34; +const SKILLID_BLACKSMITHY := 7; +const SKILLID_TAILORING := 34; -print(GetItemTypeByJobType(SKILLID_TAILORING, 9)); +print( GetItemTypeByJobType( SKILLID_TAILORING, 9 ) ); -function GetItemTypeByJobType (jobtype, y) +function GetItemTypeByJobType( jobtype, y ) - case (jobtype) - SKILLID_TAILORING: - print(0x153B); // Half Apron + case ( jobtype ) + SKILLID_TAILORING: + print( 0x153B ); // Half Apron - // If not properly handled, this is treated - // as a break label for the inner case statement, - // rather than a selector for the outer case statement. - SKILLID_BLACKSMITHY: - case( y ) - 8: return 0x1b73; //Buckler - 9: print(0x1b72); //Bronze Shield - endcase - endcase + // If not properly handled, this is treated + // as a break label for the inner case statement, + // rather than a selector for the outer case statement. + SKILLID_BLACKSMITHY: case ( y ) + 8: return 0x1b73; // Buckler + 9: print( 0x1b72 ); // Bronze Shield + endcase + endcase endfunction - diff --git a/testsuite/escript/condexpr/condexpr01.src b/testsuite/escript/condexpr/condexpr01.src index 82fe0cddd..78e5ca409 100644 --- a/testsuite/escript/condexpr/condexpr01.src +++ b/testsuite/escript/condexpr/condexpr01.src @@ -1,29 +1,29 @@ -function Call(byref val) - return ++val; +function Call( byref val ) + return ++val; endfunction function DoNotCall() - print("TEST FAILURE"); - return error{ errortext := "Called!" }; + print( "TEST FAILURE" ); + return error{ errortext := "Called!" }; endfunction var foo, i := 0; -foo := 1 ? Call(i) : DoNotCall(); -print(foo); +foo := 1 ? Call( i ) : DoNotCall(); +print( foo ); -foo := 0 ? DoNotCall() : Call(i); -print(foo); +foo := 0 ? DoNotCall() : Call( i ); +print( foo ); -foo := -1 > 0 ? DoNotCall() : Call(i); -print(foo); +foo := -1 > 0 ? DoNotCall() : Call( i ); +print( foo ); -foo := -1 > 0 ? DoNotCall() : 0 > 1 ? DoNotCall() : Call(i); -print(foo); +foo := -1 > 0 ? DoNotCall() : 0 > 1 ? DoNotCall() : Call( i ); +print( foo ); -foo := 0 ?: "" ? DoNotCall() : uninit ?: 0 ? DoNotCall() : Call(i); -print(foo); +foo := 0 ?: "" ? DoNotCall() : uninit ?: 0 ? DoNotCall() : Call( i ); +print( foo ); var bar := struct{}; -foo := bar.+baz := "" ?: "truthty" ? 1 : 0 ? Call(i) : DoNotCall(); -print(foo); +foo := bar.+baz := "" ?: "truthty" ? 1 : 0 ? Call( i ) : DoNotCall(); +print( foo ); diff --git a/testsuite/escript/condexpr/condexpr02.src b/testsuite/escript/condexpr/condexpr02.src index 113c0ca6e..27d8ce5b2 100644 --- a/testsuite/escript/condexpr/condexpr02.src +++ b/testsuite/escript/condexpr/condexpr02.src @@ -2,15 +2,15 @@ var a := 1e0, b := 1e1, c := 1e2, d := 1e3, e := 1e4, f := 1e5, g := 1e6, h := 1 var foo, bar, baz; function testPrint() - print($"{foo} {bar} {baz} {foo == bar && bar == baz}"); + print( $"{foo} {bar} {baz} {foo == bar && bar == baz}" ); endfunction -foo := a+b ? c+g ? d : e+h : f; // go crazy -bar := (a+b) ? ( (c+g) ? d : (e+h) ) : f; // group the craziness +foo := a + b ? c + g ? d : e + h : f; // go crazy +bar := ( a + b ) ? ( ( c + g ) ? d : ( e + h ) ) : f; // group the craziness baz := 1000; testPrint(); -foo := a ? b : c+d ? e+f : g; -bar := a ? b : (c+d) ? (e+f) : g; +foo := a ? b : c + d ? e + f : g; +bar := a ? b : ( c + d ) ? ( e + f ) : g; baz := 110000; testPrint(); diff --git a/testsuite/escript/condexpr/condexpr03.src b/testsuite/escript/condexpr/condexpr03.src index cd01038da..baec4e3a3 100644 --- a/testsuite/escript/condexpr/condexpr03.src +++ b/testsuite/escript/condexpr/condexpr03.src @@ -1 +1 @@ -print(1 ? TRUE : 0); +print( 1 ? TRUE : 0 ); diff --git a/testsuite/escript/condexpr/condexpr04.err b/testsuite/escript/condexpr/condexpr04.err index df62bffab..3e5f9d274 100644 --- a/testsuite/escript/condexpr/condexpr04.err +++ b/testsuite/escript/condexpr/condexpr04.err @@ -1 +1 @@ -condexpr04.src:1:6: error: missing ';' at '(' +:1:6: error: missing ';' at '(' \ No newline at end of file diff --git a/testsuite/escript/const/const001-integer.src b/testsuite/escript/const/const001-integer.src index ec67d095b..68accadbb 100644 --- a/testsuite/escript/const/const001-integer.src +++ b/testsuite/escript/const/const001-integer.src @@ -1,4 +1,3 @@ const FOO := 6; print( FOO ); - diff --git a/testsuite/escript/const/const002-integer-optimized.src b/testsuite/escript/const/const002-integer-optimized.src index ffb300c90..b7622794b 100644 --- a/testsuite/escript/const/const002-integer-optimized.src +++ b/testsuite/escript/const/const002-integer-optimized.src @@ -1,4 +1,3 @@ const FOO := 6 / 2; print( FOO ); - diff --git a/testsuite/escript/const/const003-expression-of-const-optimized.src b/testsuite/escript/const/const003-expression-of-const-optimized.src index 883c49be8..9520c2842 100644 --- a/testsuite/escript/const/const003-expression-of-const-optimized.src +++ b/testsuite/escript/const/const003-expression-of-const-optimized.src @@ -3,4 +3,3 @@ const BAR := FOO * 3; print( FOO ); print( BAR ); - diff --git a/testsuite/escript/const/const004-cannot-shadow-const-with-global.err b/testsuite/escript/const/const004-cannot-shadow-const-with-global.err index 481c9e645..a2e16062f 100644 --- a/testsuite/escript/const/const004-cannot-shadow-const-with-global.err +++ b/testsuite/escript/const/const004-cannot-shadow-const-with-global.err @@ -1 +1 @@ -error: Cannot define a variable with the same name as constant 'FOO'. \ No newline at end of file +:4:5: error: Cannot define a variable with the same name as constant 'FOO'. \ No newline at end of file diff --git a/testsuite/escript/const/const004-cannot-shadow-const-with-global.src b/testsuite/escript/const/const004-cannot-shadow-const-with-global.src index c615cfc17..fe2fecfa6 100644 --- a/testsuite/escript/const/const004-cannot-shadow-const-with-global.src +++ b/testsuite/escript/const/const004-cannot-shadow-const-with-global.src @@ -4,4 +4,3 @@ const BAR := FOO * 3; var FOO := 3; print( FOO ); print( BAR ); - diff --git a/testsuite/escript/const/const005-string.src b/testsuite/escript/const/const005-string.src index 87b86f93b..e5d08a75a 100644 --- a/testsuite/escript/const/const005-string.src +++ b/testsuite/escript/const/const005-string.src @@ -1,4 +1,3 @@ const FOO := "xyz"; print( FOO ); - diff --git a/testsuite/escript/const/const006-float.src b/testsuite/escript/const/const006-float.src index d5c62ed11..cbcd97afb 100644 --- a/testsuite/escript/const/const006-float.src +++ b/testsuite/escript/const/const006-float.src @@ -1,4 +1,3 @@ const FOO := 1.4; print( FOO ); - diff --git a/testsuite/escript/const/const007-call-module-func.src b/testsuite/escript/const/const007-call-module-func.src index 6ca0048fe..d52768d2a 100644 --- a/testsuite/escript/const/const007-call-module-func.src +++ b/testsuite/escript/const/const007-call-module-func.src @@ -14,4 +14,3 @@ use math; const PI := ConstPI(); print( PI ); - diff --git a/testsuite/escript/const/const008-cannot-call-user-func.err b/testsuite/escript/const/const008-cannot-call-user-func.err index 637c7cf27..3302d966b 100644 --- a/testsuite/escript/const/const008-cannot-call-user-func.err +++ b/testsuite/escript/const/const008-cannot-call-user-func.err @@ -1 +1 @@ -const008-cannot-call-user-func.src:8:1: error: Const expression must be optimizable. \ No newline at end of file +:8:1: error: Const expression must be optimizable. \ No newline at end of file diff --git a/testsuite/escript/const/const008-cannot-call-user-func.src b/testsuite/escript/const/const008-cannot-call-user-func.src index e7aaa6f90..2c9363b6f 100644 --- a/testsuite/escript/const/const008-cannot-call-user-func.src +++ b/testsuite/escript/const/const008-cannot-call-user-func.src @@ -1,12 +1,11 @@ use math; function foo() - return "hi"; + return "hi"; endfunction // this is not allowed: const A := foo(); -print(foo()); -print(A); - +print( foo() ); +print( A ); diff --git a/testsuite/escript/const/const009-string-alias.src b/testsuite/escript/const/const009-string-alias.src index 15bd2d9ad..7f56293da 100644 --- a/testsuite/escript/const/const009-string-alias.src +++ b/testsuite/escript/const/const009-string-alias.src @@ -2,4 +2,3 @@ const FOO := "xyz"; const BAR := FOO; print( BAR ); - diff --git a/testsuite/escript/const/const010-empty-array.src b/testsuite/escript/const/const010-empty-array.src index a6fa5545e..3697c83e8 100644 --- a/testsuite/escript/const/const010-empty-array.src +++ b/testsuite/escript/const/const010-empty-array.src @@ -1,2 +1,2 @@ const X := {}; -print(X); +print( X ); diff --git a/testsuite/escript/const/const011-populated-array.err b/testsuite/escript/const/const011-populated-array.err index 76af56e7a..2fa9e326f 100644 --- a/testsuite/escript/const/const011-populated-array.err +++ b/testsuite/escript/const/const011-populated-array.err @@ -1 +1 @@ -A const array must be empty. +:1:12: error: A const array must be empty. \ No newline at end of file diff --git a/testsuite/escript/const/const011-populated-array.src b/testsuite/escript/const/const011-populated-array.src index 49a61e3ae..bc98acfb0 100644 --- a/testsuite/escript/const/const011-populated-array.src +++ b/testsuite/escript/const/const011-populated-array.src @@ -1,2 +1,2 @@ const X := { 6 }; -print(X); +print( X ); diff --git a/testsuite/escript/const/const012-empty-dictionary.src b/testsuite/escript/const/const012-empty-dictionary.src index 7cc8ad5aa..2814da17c 100644 --- a/testsuite/escript/const/const012-empty-dictionary.src +++ b/testsuite/escript/const/const012-empty-dictionary.src @@ -1,2 +1,2 @@ -const X := dictionary {}; -print(X); +const X := dictionary{}; +print( X ); diff --git a/testsuite/escript/const/const013-populated-dictionary.err b/testsuite/escript/const/const013-populated-dictionary.err index 4801cb0b2..a48ad6ed8 100644 --- a/testsuite/escript/const/const013-populated-dictionary.err +++ b/testsuite/escript/const/const013-populated-dictionary.err @@ -1 +1 @@ -A const dictionary must be empty. +:1:12: error: A const dictionary must be empty. \ No newline at end of file diff --git a/testsuite/escript/const/const013-populated-dictionary.src b/testsuite/escript/const/const013-populated-dictionary.src index 832a62787..e200a3deb 100644 --- a/testsuite/escript/const/const013-populated-dictionary.src +++ b/testsuite/escript/const/const013-populated-dictionary.src @@ -1,2 +1,2 @@ -const X := dictionary { "a" -> "b" }; -print(X); +const X := dictionary{ "a" -> "b" }; +print( X ); diff --git a/testsuite/escript/const/const014-empty-error.src b/testsuite/escript/const/const014-empty-error.src index fb016ea93..54d9d299e 100644 --- a/testsuite/escript/const/const014-empty-error.src +++ b/testsuite/escript/const/const014-empty-error.src @@ -1,2 +1,2 @@ -const X := error {}; -print(X); +const X := error{}; +print( X ); diff --git a/testsuite/escript/const/const015-populated-error.err b/testsuite/escript/const/const015-populated-error.err index 7a7db4555..25257e6a0 100644 --- a/testsuite/escript/const/const015-populated-error.err +++ b/testsuite/escript/const/const015-populated-error.err @@ -1 +1 @@ -A const error must be empty. +:1:12: error: A const error must be empty. \ No newline at end of file diff --git a/testsuite/escript/const/const015-populated-error.src b/testsuite/escript/const/const015-populated-error.src index 77271a147..74184b4d0 100644 --- a/testsuite/escript/const/const015-populated-error.src +++ b/testsuite/escript/const/const015-populated-error.src @@ -1,2 +1,2 @@ -const X := error { errortext := "abc" }; -print(X); +const X := error{ errortext := "abc" }; +print( X ); diff --git a/testsuite/escript/const/const016-empty-struct.src b/testsuite/escript/const/const016-empty-struct.src index 6a3a41ccc..aea4428e7 100644 --- a/testsuite/escript/const/const016-empty-struct.src +++ b/testsuite/escript/const/const016-empty-struct.src @@ -1,2 +1,2 @@ -const X := struct {}; -print(X); +const X := struct{}; +print( X ); diff --git a/testsuite/escript/const/const017-populated-struct.err b/testsuite/escript/const/const017-populated-struct.err index de6941092..5fedce432 100644 --- a/testsuite/escript/const/const017-populated-struct.err +++ b/testsuite/escript/const/const017-populated-struct.err @@ -1 +1 @@ -A const struct must be empty. +:1:12: error: A const struct must be empty. \ No newline at end of file diff --git a/testsuite/escript/const/const017-populated-struct.src b/testsuite/escript/const/const017-populated-struct.src index 86215f328..0852be309 100644 --- a/testsuite/escript/const/const017-populated-struct.src +++ b/testsuite/escript/const/const017-populated-struct.src @@ -1,2 +1,2 @@ -const X := struct { a := 5 }; -print(X); +const X := struct{ a := 5 }; +print( X ); diff --git a/testsuite/escript/dict/dict003.src b/testsuite/escript/dict/dict003.src index 5c406826d..5a9701048 100644 --- a/testsuite/escript/dict/dict003.src +++ b/testsuite/escript/dict/dict003.src @@ -8,4 +8,4 @@ print( dict[7] ); print( "dict.size=" + dict.size() ); print( dict[12] ); print( "dict.size=" + dict.size() ); -print( "dict.keys=" + dict.keys() ); \ No newline at end of file +print( "dict.keys=" + dict.keys() ); diff --git a/testsuite/escript/dict/dict004.src b/testsuite/escript/dict/dict004.src index e490d9cce..7457fac75 100644 --- a/testsuite/escript/dict/dict004.src +++ b/testsuite/escript/dict/dict004.src @@ -9,7 +9,7 @@ dict.insert( a[3], 3 ); print( dict ); var b := pack( dict ); -print(b); +print( b ); -var c := unpack(b); -print(c); +var c := unpack( b ); +print( c ); diff --git a/testsuite/escript/dict/dict005.src b/testsuite/escript/dict/dict005.src index ed827e06c..00fa75eea 100644 --- a/testsuite/escript/dict/dict005.src +++ b/testsuite/escript/dict/dict005.src @@ -1,13 +1,12 @@ -var str :="abcd"; +var str := "abcd"; var dict := dictionary; -for i:=1 to 4 - dict.insert(str[i],i); +for i := 1 to 4 + dict.insert( str[i], i ); endfor -print("dict: "+dict); +print( "dict: " + dict ); // everything works fine untill now -for i:=1 to 4 - print("i: "+i+"result: "+dict[str[i]]); +for i := 1 to 4 + print( "i: " + i + "result: " + dict[str[i]] ); endfor - diff --git a/testsuite/escript/dict/dict006.src b/testsuite/escript/dict/dict006.src index 6a20afe17..5e50ad473 100644 --- a/testsuite/escript/dict/dict006.src +++ b/testsuite/escript/dict/dict006.src @@ -1,13 +1,12 @@ -var str :="abcd"; +var str := "abcd"; var dict := dictionary; -for i:=1 to 4 - dict.insert(str[i],i); +for i := 1 to 4 + dict.insert( str[i], i ); endfor -print("dict: "+dict); +print( "dict: " + dict ); // everything works fine untill now foreach v in dict - print("v: "+v); + print( "v: " + v ); endforeach - diff --git a/testsuite/escript/dict/dict007.src b/testsuite/escript/dict/dict007.src index 21d344964..e8d3db51f 100644 --- a/testsuite/escript/dict/dict007.src +++ b/testsuite/escript/dict/dict007.src @@ -1,13 +1,12 @@ -var str :="abcd"; +var str := "abcd"; var dict := dictionary; -for i:=1 to 4 - dict.insert(str[i],i); +for i := 1 to 4 + dict.insert( str[i], i ); endfor -print("dict: "+dict); +print( "dict: " + dict ); // everything works fine untill now foreach v in dict - print( _v_iter + " -> " + v); + print( _v_iter + " -> " + v ); endforeach - diff --git a/testsuite/escript/dict/dict008.src b/testsuite/escript/dict/dict008.src index 3173e97ec..3b486edb9 100644 --- a/testsuite/escript/dict/dict008.src +++ b/testsuite/escript/dict/dict008.src @@ -1,19 +1,18 @@ program tc_etest( who ) var searchin := dictionary; - searchin["woot"] := dictionary; - searchin["roar"] := dictionary; - + searchin["woot"] := dictionary; + searchin["roar"] := dictionary; + var key := dictionary; - key["cheese"] := 400; - + key["cheese"] := 400; + print( "Approaching check..." ); - - if( !searchin[key] ) + + if ( !searchin[key] ) print( "No match." ); else print( "Match" ); endif - + print( "Finished check." ); endprogram - diff --git a/testsuite/escript/dict/dict009.src b/testsuite/escript/dict/dict009.src index 5e397e1a9..e8856167d 100644 --- a/testsuite/escript/dict/dict009.src +++ b/testsuite/escript/dict/dict009.src @@ -1,4 +1,4 @@ -var d := dictionary { 5 -> "hey", 7 -> "you" }; -print(d); +var d := dictionary{ 5 -> "hey", 7 -> "you" }; +print( d ); print( d[5] ); print( d[7] ); diff --git a/testsuite/escript/dict/dict010.src b/testsuite/escript/dict/dict010.src index b26cbc90d..05f2c2115 100644 --- a/testsuite/escript/dict/dict010.src +++ b/testsuite/escript/dict/dict010.src @@ -1,4 +1,4 @@ -var d := dictionary { "x" -> "hey", "y" -> "you" }; -print(d); +var d := dictionary{ "x" -> "hey", "y" -> "you" }; +print( d ); print( d["x"] ); print( d["y"] ); diff --git a/testsuite/escript/dict/dict011.src b/testsuite/escript/dict/dict011.src index 53d48c410..25fc3a6dd 100644 --- a/testsuite/escript/dict/dict011.src +++ b/testsuite/escript/dict/dict011.src @@ -2,12 +2,12 @@ var a_key := 3; var a_val := 72; -var d := dictionary { a_key -> a_val }; -print("dict start: " + d); +var d := dictionary{ a_key -> a_val }; +print( "dict start: " + d ); a_key := 5; a_val := 71; -print("dict after reassign a_key, a_val:" + d); -d[ 3 ] := 74; -print("dict after modification: " + d); -print("a_key is " + a_key); -print("a_val is " + a_val); +print( "dict after reassign a_key, a_val:" + d ); +d[3] := 74; +print( "dict after modification: " + d ); +print( "a_key is " + a_key ); +print( "a_val is " + a_val ); diff --git a/testsuite/escript/dict/dict012.src b/testsuite/escript/dict/dict012.src index 12fd1cfd5..09298ca8a 100644 --- a/testsuite/escript/dict/dict012.src +++ b/testsuite/escript/dict/dict012.src @@ -1,2 +1,2 @@ -var d := dictionary { "abc", "def" -> "ghi" }; -print(d); +var d := dictionary{ "abc", "def" -> "ghi" }; +print( d ); diff --git a/testsuite/escript/dict/dict013.src b/testsuite/escript/dict/dict013.src index af1246e58..8d999fb58 100644 --- a/testsuite/escript/dict/dict013.src +++ b/testsuite/escript/dict/dict013.src @@ -1,4 +1,4 @@ var a := "X"; -var d := dictionary { a+"abc", a+"def" -> "ghi" }; -print(d); +var d := dictionary{ a + "abc", a + "def" -> "ghi" }; +print( d ); diff --git a/testsuite/escript/dict/dict014.src b/testsuite/escript/dict/dict014.src index 473c17d29..517c24987 100644 --- a/testsuite/escript/dict/dict014.src +++ b/testsuite/escript/dict/dict014.src @@ -1,5 +1,5 @@ var a := "X"; var b := "Y"; -var d := dictionary { a+"abc", a+"def" -> "ghi"+b }; -print(d); +var d := dictionary{ a + "abc", a + "def" -> "ghi" + b }; +print( d ); diff --git a/testsuite/escript/dict/dict015.src b/testsuite/escript/dict/dict015.src index d6fbf1d23..afc7b4d46 100644 --- a/testsuite/escript/dict/dict015.src +++ b/testsuite/escript/dict/dict015.src @@ -1,14 +1,14 @@ program foo() - var i:=1; - var d1 := dictionary{i->i}; - var d2 := dictionary{}; - var d3 := dictionary{}; - d2.insert("i",i); - d2.insert(i,i); - d3["i"]:=i; - i+=1; - print(i); - print(d1); // dicts should not change - print(d2); - print(d3); + var i := 1; + var d1 := dictionary{ i -> i }; + var d2 := dictionary{}; + var d3 := dictionary{}; + d2.insert( "i", i ); + d2.insert( i, i ); + d3["i"] := i; + i += 1; + print( i ); + print( d1 ); // dicts should not change + print( d2 ); + print( d3 ); endprogram diff --git a/testsuite/escript/enum/enum01.src b/testsuite/escript/enum/enum01.src index 33cd9fdda..96e53fb7b 100644 --- a/testsuite/escript/enum/enum01.src +++ b/testsuite/escript/enum/enum01.src @@ -1,7 +1,7 @@ enum FOO - FOO_A, // should start counter at 0 - FOO_B, - FOO_C + FOO_A, // should start counter at 0 + FOO_B, + FOO_C endenum print( FOO_A ); diff --git a/testsuite/escript/enum/enum02.src b/testsuite/escript/enum/enum02.src index fc36c6300..d48c6eb73 100644 --- a/testsuite/escript/enum/enum02.src +++ b/testsuite/escript/enum/enum02.src @@ -1,7 +1,7 @@ enum FOO - FOO_A := 2, - FOO_B, - FOO_C + FOO_A := 2, + FOO_B, + FOO_C endenum print( FOO_A ); diff --git a/testsuite/escript/enum/enum03.src b/testsuite/escript/enum/enum03.src index b70710572..31aa5edf5 100644 --- a/testsuite/escript/enum/enum03.src +++ b/testsuite/escript/enum/enum03.src @@ -1,8 +1,8 @@ enum FOO - FOO_A, - FOO_B, - FOO_C := 8, - FOO_D + FOO_A, + FOO_B, + FOO_C := 8, + FOO_D endenum print( FOO_A ); diff --git a/testsuite/escript/enum/enum04.src b/testsuite/escript/enum/enum04.src index b601e4615..714447928 100644 --- a/testsuite/escript/enum/enum04.src +++ b/testsuite/escript/enum/enum04.src @@ -1,8 +1,8 @@ enum FOO - FOO_A, - FOO_B, - FOO_C := FOO_B + 8, - FOO_D + FOO_A, + FOO_B, + FOO_C := FOO_B + 8, + FOO_D endenum print( FOO_A ); diff --git a/testsuite/escript/enum/enum05.src b/testsuite/escript/enum/enum05.src index 6940bc78d..51ee982ed 100644 --- a/testsuite/escript/enum/enum05.src +++ b/testsuite/escript/enum/enum05.src @@ -1,8 +1,8 @@ enum FOO - FOO_A := 1, - FOO_B, - FOO_C, - FOO_COUNT := FOO_C + FOO_A := 1, + FOO_B, + FOO_C, + FOO_COUNT := FOO_C endenum print( FOO_A ); diff --git a/testsuite/escript/enum/enum06.src b/testsuite/escript/enum/enum06.src index ffa3278e6..e44958470 100644 --- a/testsuite/escript/enum/enum06.src +++ b/testsuite/escript/enum/enum06.src @@ -1,17 +1,17 @@ enum FOO - FOO_A, - FOO_B, - FOO_C + FOO_A, + FOO_B, + FOO_C endenum function bar( a := FOO_B ) - print( "a=" + a ); + print( "a=" + a ); endfunction -bar(1); -bar(2); +bar( 1 ); +bar( 2 ); bar(); -bar(FOO_C); +bar( FOO_C ); /**** Expected Output Begins: ***** 1 2 diff --git a/testsuite/escript/error/error001.src b/testsuite/escript/error/error001.src index 836cb12f4..c037170cf 100644 --- a/testsuite/escript/error/error001.src +++ b/testsuite/escript/error/error001.src @@ -1 +1 @@ -print(error{ "errortext" }); +print( error{ "errortext" } ); diff --git a/testsuite/escript/errors/errors001-two-functions-same-name.err b/testsuite/escript/errors/errors001-two-functions-same-name.err index cd307ec7d..afb7bba2a 100644 --- a/testsuite/escript/errors/errors001-two-functions-same-name.err +++ b/testsuite/escript/errors/errors001-two-functions-same-name.err @@ -1 +1 @@ -errors001-two-functions-same-name.src:6:1: error: Function 'foo' defined more than once. +:6:1: error: Function 'foo' defined more than once. \ No newline at end of file diff --git a/testsuite/escript/errors/errors001-two-functions-same-name.src b/testsuite/escript/errors/errors001-two-functions-same-name.src index fc3b0f351..6515a2f10 100644 --- a/testsuite/escript/errors/errors001-two-functions-same-name.src +++ b/testsuite/escript/errors/errors001-two-functions-same-name.src @@ -1,10 +1,10 @@ // reported in https://forums.polserver.com/viewtopic.php?f=54&t=6140 -function foo(x) - print(x); +function foo( x ) + print( x ); endfunction -function foo(y) - print(y); +function foo( y ) + print( y ); endfunction -foo("a"); +foo( "a" ); diff --git a/testsuite/escript/errors/errors002-var-same-name-as-function.err b/testsuite/escript/errors/errors002-var-same-name-as-function.err index 003a74d76..9c0db41f2 100644 --- a/testsuite/escript/errors/errors002-var-same-name-as-function.err +++ b/testsuite/escript/errors/errors002-var-same-name-as-function.err @@ -1 +1 @@ -errors002-var-same-name-as-function.src:4:9: error: Cannot define a variable with the same name as function 'print' \ No newline at end of file +:4:7: error: Cannot define a variable with the same name as function 'print'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors002-var-same-name-as-function.src b/testsuite/escript/errors/errors002-var-same-name-as-function.src index 5064d9feb..2a4a38289 100644 --- a/testsuite/escript/errors/errors002-var-same-name-as-function.src +++ b/testsuite/escript/errors/errors002-var-same-name-as-function.src @@ -1,6 +1,6 @@ // reported in https://forums.polserver.com/viewtopic.php?f=54&t=6140 // variable with the same name as a system function: -if (1) - var print := 3; - print( print ); +if ( 1 ) + var print := 3; + print( print ); endif diff --git a/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.err b/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.err index e70c1b84e..46e907320 100644 --- a/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.err +++ b/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.err @@ -1 +1 @@ -errors003-function-parameter-same-name-as-function.src:2:14: error: Cannot define a function parameter with the same name as function 'print'. +:2:15: error: Cannot define a function parameter with the same name as function 'print'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.src b/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.src index 9ddf769a5..06e091495 100644 --- a/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.src +++ b/testsuite/escript/errors/errors003-function-parameter-same-name-as-function.src @@ -1,6 +1,6 @@ // reported in https://forums.polserver.com/viewtopic.php?f=54&t=6140 -function foo(print) - not_defined; +function foo( print ) + not_defined; endfunction -foo(4); \ No newline at end of file +foo( 4 ); diff --git a/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.err b/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.err index 89ce5e4aa..e82f44a6a 100644 --- a/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.err +++ b/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.err @@ -1 +1 @@ -errors004-program-parameter-same-name-as-function.src:2:13: error: Cannot define a program parameter with the same name as function 'print'. +:2:14: error: Cannot define a program parameter with the same name as function 'print'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.src b/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.src index 7e0ff0dc0..404f4f4b1 100644 --- a/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.src +++ b/testsuite/escript/errors/errors004-program-parameter-same-name-as-function.src @@ -1,4 +1,4 @@ // reported in https://forums.polserver.com/viewtopic.php?f=54&t=6140 -program foo(print) +program foo( print ) endprogram diff --git a/testsuite/escript/errors/errors004-reserved-word-as-argument-name.err b/testsuite/escript/errors/errors004-reserved-word-as-argument-name.err index 0d9ce7d6a..53926d5fc 100644 --- a/testsuite/escript/errors/errors004-reserved-word-as-argument-name.err +++ b/testsuite/escript/errors/errors004-reserved-word-as-argument-name.err @@ -1 +1 @@ -errors004-reserved-word-as-argument-name.src:3:13: error: Did not expect reserved word 'downto' in this context. \ No newline at end of file +:3:13: error: Did not expect reserved word 'downto' in this context. \ No newline at end of file diff --git a/testsuite/escript/errors/errors005-const-same-name-as-function.err b/testsuite/escript/errors/errors005-const-same-name-as-function.err index 6bfc72f32..f1cda0802 100644 --- a/testsuite/escript/errors/errors005-const-same-name-as-function.err +++ b/testsuite/escript/errors/errors005-const-same-name-as-function.err @@ -1 +1 @@ -errors005-const-same-name-as-function.src:1:1: error: Cannot define a constant with the same name as function 'print'. +:1:1: error: Cannot define a constant with the same name as function 'print'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors005-const-same-name-as-function.src b/testsuite/escript/errors/errors005-const-same-name-as-function.src index 043760e0f..cb521de97 100644 --- a/testsuite/escript/errors/errors005-const-same-name-as-function.src +++ b/testsuite/escript/errors/errors005-const-same-name-as-function.src @@ -1,2 +1,2 @@ const print := 5; -print(print); +print( print ); diff --git a/testsuite/escript/errors/errors005-missing-open-paren.err b/testsuite/escript/errors/errors005-missing-open-paren.err index 7406dd2da..be98f83df 100644 --- a/testsuite/escript/errors/errors005-missing-open-paren.err +++ b/testsuite/escript/errors/errors005-missing-open-paren.err @@ -1 +1 @@ -errors005-missing-open-paren.src:6:40: error: extraneous input ')' expecting ';' \ No newline at end of file +:6:40: error: extraneous input ')' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.err b/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.err index 2473f344f..4f6b9712d 100644 --- a/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.err +++ b/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.err @@ -1 +1 @@ -errors006-for-loop-iterator-same-name-as-function.src:1:5: error: Cannot define a for loop iterator with the same name as function 'len'. +:1:5: error: Cannot define a for loop iterator with the same name as function 'len'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.src b/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.src index dcda5a0a0..37a0ea56e 100644 --- a/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.src +++ b/testsuite/escript/errors/errors006-for-loop-iterator-same-name-as-function.src @@ -1,3 +1,3 @@ for len := 1 to 5 - print(len); + print( len ); endfor diff --git a/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.err b/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.err index 7b2cb8150..3034bb5fa 100644 --- a/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.err +++ b/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.err @@ -1 +1 @@ -errors007-foreach-iterator-same-name-as-function.src:1:1: error: Cannot define a foreach iterator with the same name as function 'len'. +:1:1: error: Cannot define a foreach iterator with the same name as function 'len'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.src b/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.src index e35c05ed0..5ae618dee 100644 --- a/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.src +++ b/testsuite/escript/errors/errors007-foreach-iterator-same-name-as-function.src @@ -1,3 +1,3 @@ foreach len in { 1, 3, 5, 7 } - print(len); + print( len ); endforeach diff --git a/testsuite/escript/errors/errors008-var-same-name-as-user-function.err b/testsuite/escript/errors/errors008-var-same-name-as-user-function.err index 7e37e26e7..e9c4fb5c8 100644 --- a/testsuite/escript/errors/errors008-var-same-name-as-user-function.err +++ b/testsuite/escript/errors/errors008-var-same-name-as-user-function.err @@ -1 +1 @@ -errors008-var-same-name-as-user-function.src:6:9: error: Cannot define a variable with the same name as function 'xyz'. \ No newline at end of file +:6:7: error: Cannot define a variable with the same name as function 'xyz'. \ No newline at end of file diff --git a/testsuite/escript/errors/errors008-var-same-name-as-user-function.src b/testsuite/escript/errors/errors008-var-same-name-as-user-function.src index e16df085a..94ed79f5c 100644 --- a/testsuite/escript/errors/errors008-var-same-name-as-user-function.src +++ b/testsuite/escript/errors/errors008-var-same-name-as-user-function.src @@ -2,7 +2,7 @@ function xyz() endfunction -if (1) - var xyz := 3; - print( xyz ); +if ( 1 ) + var xyz := 3; + print( xyz ); endif diff --git a/testsuite/escript/errors/errors009-int-out-of-range.err b/testsuite/escript/errors/errors009-int-out-of-range.err index 2327c8d47..4a4ec8708 100644 --- a/testsuite/escript/errors/errors009-int-out-of-range.err +++ b/testsuite/escript/errors/errors009-int-out-of-range.err @@ -1 +1 @@ -errors009-int-out-of-range.src:1:10: error: integer value '123456789123456789' out of range. \ No newline at end of file +:1:10: error: integer value '123456789123456789' out of range. \ No newline at end of file diff --git a/testsuite/escript/errors/errors009-int-out-of-range.src b/testsuite/escript/errors/errors009-int-out-of-range.src index 18376a983..3f3b0b504 100644 --- a/testsuite/escript/errors/errors009-int-out-of-range.src +++ b/testsuite/escript/errors/errors009-int-out-of-range.src @@ -1,5 +1,5 @@ var x := 123456789123456789; -print(x); +print( x ); // OG compiler does not notice this error. force_compile_error(); diff --git a/testsuite/escript/errors/errors010-reserved-word-syntax-error.err b/testsuite/escript/errors/errors010-reserved-word-syntax-error.err index 545831c97..c979e21b2 100644 --- a/testsuite/escript/errors/errors010-reserved-word-syntax-error.err +++ b/testsuite/escript/errors/errors010-reserved-word-syntax-error.err @@ -1 +1 @@ -errors010-reserved-word-syntax-error.src:1:5: error: Did not expect reserved word 'is' in this context. \ No newline at end of file +:1:5: error: Did not expect reserved word 'is' in this context. \ No newline at end of file diff --git a/testsuite/escript/errors/errors011-const-no-init.err b/testsuite/escript/errors/errors011-const-no-init.err index 4f421a3cf..f66432ad1 100644 --- a/testsuite/escript/errors/errors011-const-no-init.err +++ b/testsuite/escript/errors/errors011-const-no-init.err @@ -1 +1 @@ -errors011-const-no-init.src:1:10: error: mismatched input ';' expecting {'array', '=', ':='} +:1:10: error: mismatched input ';' expecting {'array', '=', ':='} \ No newline at end of file diff --git a/testsuite/escript/export/export01-too-long.err b/testsuite/escript/export/export01-too-long.err index cfc89ea6c..d9ef2099c 100644 --- a/testsuite/escript/export/export01-too-long.err +++ b/testsuite/escript/export/export01-too-long.err @@ -1 +1 @@ -export01-too-long.src:1:1: error: Exported function name 'foo456789012345678901234567890123' is too long at 33 characters. Max length: 32 +:1:1: error: Exported function name 'foo456789012345678901234567890123' is too long at 33 characters. Max length: 32 \ No newline at end of file diff --git a/testsuite/escript/export/export01-too-long.src b/testsuite/escript/export/export01-too-long.src index 37fa5cbdc..be916f9d3 100644 --- a/testsuite/escript/export/export01-too-long.src +++ b/testsuite/escript/export/export01-too-long.src @@ -1,7 +1,6 @@ exported function foo456789012345678901234567890123() - print("this is exported"); + print( "this is exported" ); - // OG compiler does not flag the function name length as an error - b; + // OG compiler does not flag the function name length as an error + b; endfunction - diff --git a/testsuite/escript/filemod/file.src b/testsuite/escript/filemod/file.src index c77264fd5..bf5acbf4b 100644 --- a/testsuite/escript/filemod/file.src +++ b/testsuite/escript/filemod/file.src @@ -1,7 +1,7 @@ use file; -print(ReadFile(":filetest:normal.file")); -print(ReadFile(":filetest:bom.file")); -var c:=ReadFile(":filetest:iso.file"); -print(c); -print(c[1].find("ü")); +print( ReadFile( ":filetest:normal.file" ) ); +print( ReadFile( ":filetest:bom.file" ) ); +var c := ReadFile( ":filetest:iso.file" ); +print( c ); +print( c[1].find( "ü" ) ); diff --git a/testsuite/escript/filemod/xml.src b/testsuite/escript/filemod/xml.src index c3d02e307..2dc130862 100644 --- a/testsuite/escript/filemod/xml.src +++ b/testsuite/escript/filemod/xml.src @@ -1,68 +1,67 @@ use file; program XMLTest() - print("itertest..."); - itertest(); - print("membertest..."); - membertest(); - print("scopetest..."); - scopetest(); - print("not existing file..."); - notexistingtest(); - print("invalid file..."); - invalidtest(); + print( "itertest..." ); + itertest(); + print( "membertest..." ); + membertest(); + print( "scopetest..." ); + scopetest(); + print( "not existing file..." ); + notexistingtest(); + print( "invalid file..." ); + invalidtest(); endprogram function itertest() - var xml:=OpenXMLFile("filemod/xmltest.xml"); - print(xml); - parsenode(xml,""); + var xml := OpenXMLFile( "filemod/xmltest.xml" ); + print( xml ); + parsenode( xml, "" ); endfunction -function parsenode(node,i) - foreach blubb in node - print(i+cstr(blubb)+" ["+blubb.type+"] ("+cstr(_blubb_iter)+")"); - parseattrib(blubb,i+"-"); - parsenode(blubb,i+" "); - endforeach +function parsenode( node, i ) + foreach blubb in node + print( i + cstr( blubb ) + " [" + blubb.type + "] (" + cstr( _blubb_iter ) + ")" ); + parseattrib( blubb, i + "-" ); + parsenode( blubb, i + " " ); + endforeach endfunction -function parseattrib(node,i) - foreach ele in (node.attributes) - print(i+cstr(ele)+" ("+_ele_iter+")"); - endforeach +function parseattrib( node, i ) + foreach ele in ( node.attributes ) + print( i + cstr( ele ) + " (" + _ele_iter + ")" ); + endforeach endfunction function membertest() - var xml:=OpenXMLFile("filemod/xmltest.xml"); - var root:=xml[2]; - print("root= "+root); - print("firstchild= "+root.firstxmlchild()); - print("firstchildstring= "+root.firstxmlchild("nodetwo")); - print("firstsibling= "+root.firstxmlchild().nextxmlsibling()); - var node:=root.firstxmlchild("nodetwo"); - print("attributes= "+node.attributes.propnames()); - print("attributes= "+node.attributes["j"]); + var xml := OpenXMLFile( "filemod/xmltest.xml" ); + var root := xml[2]; + print( "root= " + root ); + print( "firstchild= " + root.firstxmlchild() ); + print( "firstchildstring= " + root.firstxmlchild( "nodetwo" ) ); + print( "firstsibling= " + root.firstxmlchild().nextxmlsibling() ); + var node := root.firstxmlchild( "nodetwo" ); + print( "attributes= " + node.attributes.propnames() ); + print( "attributes= " + node.attributes["j"] ); endfunction function scopetest() - var elem:=scopeloose(); - print("root= "+elem); - print("firstchild= "+elem.firstxmlchild()); + var elem := scopeloose(); + print( "root= " + elem ); + print( "firstchild= " + elem.firstxmlchild() ); endfunction function scopeloose() - var xml:=OpenXMLFile("filemod/xmltest.xml"); - return xml[2].clonenode(); + var xml := OpenXMLFile( "filemod/xmltest.xml" ); + return xml[2].clonenode(); endfunction - function notexistingtest() - var xml:=OpenXMLFile("filemod/xmltestnotexisting.xml"); - print(typeof(xml)); + var xml := OpenXMLFile( "filemod/xmltestnotexisting.xml" ); + print( typeof( xml ) ); endfunction function invalidtest() - var xml:=OpenXMLFile("filemod/xmlinvalid.xml"); - print(typeof(xml)); + var xml := OpenXMLFile( "filemod/xmlinvalid.xml" ); + print( typeof( xml ) ); endfunction diff --git a/testsuite/escript/for/for001.src b/testsuite/escript/for/for001.src index 9e71bb508..6b14ab046 100644 --- a/testsuite/escript/for/for001.src +++ b/testsuite/escript/for/for001.src @@ -1,5 +1,5 @@ var i; -for( i := 0; i < 5; i := i+1 ) - print( "Loop: " + i ); -endfor \ No newline at end of file +for ( i := 0; i < 5; i := i + 1 ) + print( "Loop: " + i ); +endfor diff --git a/testsuite/escript/for/for001b.src b/testsuite/escript/for/for001b.src index 9e71bb508..6b14ab046 100644 --- a/testsuite/escript/for/for001b.src +++ b/testsuite/escript/for/for001b.src @@ -1,5 +1,5 @@ var i; -for( i := 0; i < 5; i := i+1 ) - print( "Loop: " + i ); -endfor \ No newline at end of file +for ( i := 0; i < 5; i := i + 1 ) + print( "Loop: " + i ); +endfor diff --git a/testsuite/escript/for/for002.src b/testsuite/escript/for/for002.src index e060457d4..a146fc124 100644 --- a/testsuite/escript/for/for002.src +++ b/testsuite/escript/for/for002.src @@ -1,7 +1,11 @@ var i; -for( i := 0; i < 10; i := i+1 ) - if (i == 3) continue; endif - print( "Loop: " + i); - if (i == 8) break; endif -endfor \ No newline at end of file +for ( i := 0; i < 10; i := i + 1 ) + if ( i == 3 ) + continue; + endif + print( "Loop: " + i ); + if ( i == 8 ) + break; + endif +endfor diff --git a/testsuite/escript/for/for002b.src b/testsuite/escript/for/for002b.src index e07911606..a146fc124 100644 --- a/testsuite/escript/for/for002b.src +++ b/testsuite/escript/for/for002b.src @@ -1,11 +1,11 @@ var i; -for( i := 0; i < 10; i := i+1 ) - if (i == 3) - continue; - endif - print( "Loop: " + i); - if (i == 8) - break; - endif -endfor \ No newline at end of file +for ( i := 0; i < 10; i := i + 1 ) + if ( i == 3 ) + continue; + endif + print( "Loop: " + i ); + if ( i == 8 ) + break; + endif +endfor diff --git a/testsuite/escript/for/for003.src b/testsuite/escript/for/for003.src index 4a7564f7f..3e366acae 100644 --- a/testsuite/escript/for/for003.src +++ b/testsuite/escript/for/for003.src @@ -1,7 +1,11 @@ var i; -for( i := 0; i < 10; i := (i+1) ) - if (i == 3) continue; endif - print( "Loop: " + i); - if (i == 8) break; endif -endfor \ No newline at end of file +for ( i := 0; i < 10; i := ( i + 1 ) ) + if ( i == 3 ) + continue; + endif + print( "Loop: " + i ); + if ( i == 8 ) + break; + endif +endfor diff --git a/testsuite/escript/for/for003b.src b/testsuite/escript/for/for003b.src index de82f12eb..3e366acae 100644 --- a/testsuite/escript/for/for003b.src +++ b/testsuite/escript/for/for003b.src @@ -1,11 +1,11 @@ var i; -for( i := 0; i < 10; i := (i+1) ) - if (i == 3) - continue; - endif - print( "Loop: " + i); - if (i == 8) - break; - endif -endfor \ No newline at end of file +for ( i := 0; i < 10; i := ( i + 1 ) ) + if ( i == 3 ) + continue; + endif + print( "Loop: " + i ); + if ( i == 8 ) + break; + endif +endfor diff --git a/testsuite/escript/for/for004.src b/testsuite/escript/for/for004.src index ecd82359d..f9698199c 100644 --- a/testsuite/escript/for/for004.src +++ b/testsuite/escript/for/for004.src @@ -1,17 +1,16 @@ function foo() - var accum := 0; - var i; + var accum := 0; + var i; - for( i := 0; i < 10; i := i + 1 ) - accum := accum + i; - print( "Accum=" + accum ); - endfor - - print( "Final Accum=" + accum ); - return accum; + for ( i := 0; i < 10; i := i + 1 ) + accum := accum + i; + print( "Accum=" + accum ); + endfor + + print( "Final Accum=" + accum ); + return accum; endfunction - print( 5 + foo() + 7 ); print( 5 + 45 + 7 ); diff --git a/testsuite/escript/for/for004b.src b/testsuite/escript/for/for004b.src index ecd82359d..f9698199c 100644 --- a/testsuite/escript/for/for004b.src +++ b/testsuite/escript/for/for004b.src @@ -1,17 +1,16 @@ function foo() - var accum := 0; - var i; + var accum := 0; + var i; - for( i := 0; i < 10; i := i + 1 ) - accum := accum + i; - print( "Accum=" + accum ); - endfor - - print( "Final Accum=" + accum ); - return accum; + for ( i := 0; i < 10; i := i + 1 ) + accum := accum + i; + print( "Accum=" + accum ); + endfor + + print( "Final Accum=" + accum ); + return accum; endfunction - print( 5 + foo() + 7 ); print( 5 + 45 + 7 ); diff --git a/testsuite/escript/for/for005.src b/testsuite/escript/for/for005.src index ba3e0edca..b8f28e0b0 100644 --- a/testsuite/escript/for/for005.src +++ b/testsuite/escript/for/for005.src @@ -1,6 +1,6 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - var a := i + 4; - print( "I=" + i + ", A=" + a ); +for ( i := 0; i < 10; i := i + 1 ) + var a := i + 4; + print( "I=" + i + ", A=" + a ); endfor diff --git a/testsuite/escript/for/for006.src b/testsuite/escript/for/for006.src index a7a65cdea..b41e2377d 100644 --- a/testsuite/escript/for/for006.src +++ b/testsuite/escript/for/for006.src @@ -1,7 +1,7 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - var a := i + 4; - print( "I=" + i + ", A=" + a ); - break; +for ( i := 0; i < 10; i := i + 1 ) + var a := i + 4; + print( "I=" + i + ", A=" + a ); + break; endfor diff --git a/testsuite/escript/for/for007.src b/testsuite/escript/for/for007.src index f4253dbdf..0bc9f80cb 100644 --- a/testsuite/escript/for/for007.src +++ b/testsuite/escript/for/for007.src @@ -1,7 +1,7 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - var a := i + 4; - print( "I=" + i + ", A=" + a ); - continue; +for ( i := 0; i < 10; i := i + 1 ) + var a := i + 4; + print( "I=" + i + ", A=" + a ); + continue; endfor diff --git a/testsuite/escript/for/for008.src b/testsuite/escript/for/for008.src index 1f2a9e31b..7da74b0d1 100644 --- a/testsuite/escript/for/for008.src +++ b/testsuite/escript/for/for008.src @@ -1,11 +1,11 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - if (i > 4) - break; - endif - var a := i + 4; - print( "I=" + i + ", A=" + a ); - continue; +for ( i := 0; i < 10; i := i + 1 ) + if ( i > 4 ) + break; + endif + var a := i + 4; + print( "I=" + i + ", A=" + a ); + continue; endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/for/for009.src b/testsuite/escript/for/for009.src index 95e10fbf6..7b82db2f2 100644 --- a/testsuite/escript/for/for009.src +++ b/testsuite/escript/for/for009.src @@ -1,10 +1,10 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - var a := i + 4; - if (i > 4) - break; - endif - print( "I=" + i + ", A=" + a ); +for ( i := 0; i < 10; i := i + 1 ) + var a := i + 4; + if ( i > 4 ) + break; + endif + print( "I=" + i + ", A=" + a ); endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/for/for010.src b/testsuite/escript/for/for010.src index 34e9a5444..b1fcd1e60 100644 --- a/testsuite/escript/for/for010.src +++ b/testsuite/escript/for/for010.src @@ -1,10 +1,10 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - var a := i + 4; - if (i > 4) - continue; - endif - print( "I=" + i + ", A=" + a ); +for ( i := 0; i < 10; i := i + 1 ) + var a := i + 4; + if ( i > 4 ) + continue; + endif + print( "I=" + i + ", A=" + a ); endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/for/for011.src b/testsuite/escript/for/for011.src index f77098bf7..7e34d6ce6 100644 --- a/testsuite/escript/for/for011.src +++ b/testsuite/escript/for/for011.src @@ -1,11 +1,11 @@ var i; -for( i := 0; i < 10; i := i + 1 ) - var a := i + 4; - if (i > 4) - continue; - endif - var b; - print( "I=" + i + ", A=" + a ); +for ( i := 0; i < 10; i := i + 1 ) + var a := i + 4; + if ( i > 4 ) + continue; + endif + var b; + print( "I=" + i + ", A=" + a ); endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/for/for012.src b/testsuite/escript/for/for012.src index f23ff97c1..b5cb845e4 100644 --- a/testsuite/escript/for/for012.src +++ b/testsuite/escript/for/for012.src @@ -1,7 +1,7 @@ var i; -for( i := 0; i < 1000; i := i + 1 ) - var a := i + 4; - var b := a + 6; +for ( i := 0; i < 1000; i := i + 1 ) + var a := i + 4; + var b := a + 6; endfor -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/for/for019.src b/testsuite/escript/for/for019.src index c7e035df9..743d26aee 100644 --- a/testsuite/escript/for/for019.src +++ b/testsuite/escript/for/for019.src @@ -1,5 +1,5 @@ var i; -for( i := 0; i <= 3; i := i+1 ) - print( "Loop: " + i ); -endfor \ No newline at end of file +for ( i := 0; i <= 3; i := i + 1 ) + print( "Loop: " + i ); +endfor diff --git a/testsuite/escript/for/foreach01.src b/testsuite/escript/for/foreach01.src index 302ec2fc1..3acf193ec 100644 --- a/testsuite/escript/for/foreach01.src +++ b/testsuite/escript/for/foreach01.src @@ -1,10 +1,10 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; -foreach i in (a) - print("I="+i); +foreach i in ( a ) + print( "I=" + i ); endforeach diff --git a/testsuite/escript/for/foreach02.src b/testsuite/escript/for/foreach02.src index 1677d3722..8f493de38 100644 --- a/testsuite/escript/for/foreach02.src +++ b/testsuite/escript/for/foreach02.src @@ -1,16 +1,16 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; -foreach i in (a) - print("I="+i); - i := i + 1; +foreach i in ( a ) + print( "I=" + i ); + i := i + 1; endforeach print( "second pass" ); -foreach i in (a) - print("I="+i); +foreach i in ( a ) + print( "I=" + i ); endforeach diff --git a/testsuite/escript/for/foreach03.src b/testsuite/escript/for/foreach03.src index 977689f0d..fe66778f4 100644 --- a/testsuite/escript/for/foreach03.src +++ b/testsuite/escript/for/foreach03.src @@ -1,24 +1,24 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - var i := 45; + var i := 45; - foreach i in (a) - print("I="+i); - i := i + 1; - endforeach + foreach i in ( a ) + print( "I=" + i ); + i := i + 1; + endforeach - print( "i=" + i ); + print( "i=" + i ); - print( "second pass" ); - foreach i in (a) - print("I="+i); - endforeach + print( "second pass" ); + foreach i in ( a ) + print( "I=" + i ); + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach04.src b/testsuite/escript/for/foreach04.src index b60935e88..90567f31c 100644 --- a/testsuite/escript/for/foreach04.src +++ b/testsuite/escript/for/foreach04.src @@ -1,15 +1,15 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - foreach i in (a) - print( "I=" + i ); - break; - endforeach + foreach i in ( a ) + print( "I=" + i ); + break; + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach05.src b/testsuite/escript/for/foreach05.src index ee2303cd5..9380effdc 100644 --- a/testsuite/escript/for/foreach05.src +++ b/testsuite/escript/for/foreach05.src @@ -1,16 +1,16 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - foreach i in (a) - print( "1. I=" + i ); - continue; - print( "2. I=" + i ); - endforeach + foreach i in ( a ) + print( "1. I=" + i ); + continue; + print( "2. I=" + i ); + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach06.src b/testsuite/escript/for/foreach06.src index 8bd45c520..cca3754a5 100644 --- a/testsuite/escript/for/foreach06.src +++ b/testsuite/escript/for/foreach06.src @@ -1,25 +1,23 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - outer: - foreach i in (a) - print( "1. I=" + i ); - var j := 0; - inner: - while (j <= 10) - print( "J=" + j ); - if (j == i) - continue outer; - endif - j := j + 1; - endwhile - print( "2. I=" + i ); - endforeach + outer: foreach i in ( a ) + print( "1. I=" + i ); + var j := 0; + inner: while ( j <= 10 ) + print( "J=" + j ); + if ( j == i ) + continue outer; + endif + j := j + 1; + endwhile + print( "2. I=" + i ); + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach07.src b/testsuite/escript/for/foreach07.src index bddfc1247..280324070 100644 --- a/testsuite/escript/for/foreach07.src +++ b/testsuite/escript/for/foreach07.src @@ -1,21 +1,20 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - outer: - foreach i in (a) - print( "1. I=" + i ); + outer: foreach i in ( a ) + print( "1. I=" + i ); - while (1) - continue outer; - endwhile + while ( 1 ) + continue outer; + endwhile - print( "2. I=" + i ); - endforeach + print( "2. I=" + i ); + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach08.src b/testsuite/escript/for/foreach08.src index bddfc1247..280324070 100644 --- a/testsuite/escript/for/foreach08.src +++ b/testsuite/escript/for/foreach08.src @@ -1,21 +1,20 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - outer: - foreach i in (a) - print( "1. I=" + i ); + outer: foreach i in ( a ) + print( "1. I=" + i ); - while (1) - continue outer; - endwhile + while ( 1 ) + continue outer; + endwhile - print( "2. I=" + i ); - endforeach + print( "2. I=" + i ); + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach09.src b/testsuite/escript/for/foreach09.src index 748f93e56..f5dbb2a74 100644 --- a/testsuite/escript/for/foreach09.src +++ b/testsuite/escript/for/foreach09.src @@ -1,21 +1,20 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// var a array; a[1] := 4; a[2] := 5; a[3] := 9; function foo( a ) - outer: - foreach i in (a) - print( "1. I=" + i ); - - var j := 0; - - continue; + outer: foreach i in ( a ) + print( "1. I=" + i ); - print( "2. I=" + i ); - endforeach + var j := 0; + + continue; + + print( "2. I=" + i ); + endforeach endfunction -foo(a); +foo( a ); diff --git a/testsuite/escript/for/foreach10.src b/testsuite/escript/for/foreach10.src index d4a36d3ab..e62011f01 100644 --- a/testsuite/escript/for/foreach10.src +++ b/testsuite/escript/for/foreach10.src @@ -1,17 +1,17 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// function bar() - var a array; - a[1] := 4; - a[2] := 5; - a[3] := 9; - return a; + var a array; + a[1] := 4; + a[2] := 5; + a[3] := 9; + return a; endfunction function foo() - foreach i in bar() - print( "1. I=" + i ); - endforeach + foreach i in bar() + print( "1. I=" + i ); + endforeach endfunction foo(); diff --git a/testsuite/escript/for/foreach11.src b/testsuite/escript/for/foreach11.src index 474221ef1..015078e67 100644 --- a/testsuite/escript/for/foreach11.src +++ b/testsuite/escript/for/foreach11.src @@ -1,18 +1,18 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// function bar() - var a array; - a[1] := 4; - a[2] := 5; - a[3] := 9; - a[10] := 27; - return a; + var a array; + a[1] := 4; + a[2] := 5; + a[3] := 9; + a[10] := 27; + return a; endfunction function foo() - foreach i in bar() - print( "1. I=" + i ); - endforeach + foreach i in bar() + print( "1. I=" + i ); + endforeach endfunction foo(); diff --git a/testsuite/escript/for/foreach12-bare-array.src b/testsuite/escript/for/foreach12-bare-array.src index c0aa0b0a6..b03c58cb7 100644 --- a/testsuite/escript/for/foreach12-bare-array.src +++ b/testsuite/escript/for/foreach12-bare-array.src @@ -1,3 +1,3 @@ foreach a in { 6, 4, 8 } - print(a); + print( a ); endforeach diff --git a/testsuite/escript/for/foreach13-explicit-array.src b/testsuite/escript/for/foreach13-explicit-array.src index a886794e2..3ab7e9849 100644 --- a/testsuite/escript/for/foreach13-explicit-array.src +++ b/testsuite/escript/for/foreach13-explicit-array.src @@ -1,3 +1,3 @@ -foreach a in array { 9, 12, 6 } - print(a); +foreach a in array{ 9, 12, 6 } + print( a ); endforeach diff --git a/testsuite/escript/for/foreach14-over-user-function.src b/testsuite/escript/for/foreach14-over-user-function.src index 70b63dcf7..896fb0e9e 100644 --- a/testsuite/escript/for/foreach14-over-user-function.src +++ b/testsuite/escript/for/foreach14-over-user-function.src @@ -1,7 +1,7 @@ -function foo(unused x) - return { 5, 4, 3 }; +function foo( unused x ) + return { 5, 4, 3 }; endfunction -foreach a in foo(5) - print(a); +foreach a in foo( 5 ) + print( a ); endforeach diff --git a/testsuite/escript/for/foreach15-over-user-function-extra-semi.src b/testsuite/escript/for/foreach15-over-user-function-extra-semi.src index 0059b7b8f..0baa30538 100644 --- a/testsuite/escript/for/foreach15-over-user-function-extra-semi.src +++ b/testsuite/escript/for/foreach15-over-user-function-extra-semi.src @@ -1,7 +1,7 @@ -function foo(x) - return { 7, x, 8, 4 }; +function foo( x ) + return { 7, x, 8, 4 }; endfunction -foreach a in foo(5); - print(a); +foreach a in foo( 5 ) + print( a ); endforeach diff --git a/testsuite/escript/for/foreach16-over-module-function.src b/testsuite/escript/for/foreach16-over-module-function.src index d9358d6e0..c9da0f8d1 100644 --- a/testsuite/escript/for/foreach16-over-module-function.src +++ b/testsuite/escript/for/foreach16-over-module-function.src @@ -1,3 +1,3 @@ -foreach a in SplitWords("a b c d") - print(a); +foreach a in SplitWords( "a b c d" ) + print( a ); endforeach diff --git a/testsuite/escript/for/foreach17-over-module-function-extra-semi.src b/testsuite/escript/for/foreach17-over-module-function-extra-semi.src index a4a9cb471..0120cdabb 100644 --- a/testsuite/escript/for/foreach17-over-module-function-extra-semi.src +++ b/testsuite/escript/for/foreach17-over-module-function-extra-semi.src @@ -3,6 +3,6 @@ // ("w x y z"); // print(a) // endforeach -foreach a in SplitWords("w x y z"); - print(a); +foreach a in SplitWords( "w x y z" ) + print( a ); endforeach diff --git a/testsuite/escript/for/foreach18-over-scoped-module-function.src b/testsuite/escript/for/foreach18-over-scoped-module-function.src index 86d1f58de..f924452b2 100644 --- a/testsuite/escript/for/foreach18-over-scoped-module-function.src +++ b/testsuite/escript/for/foreach18-over-scoped-module-function.src @@ -1,3 +1,3 @@ -foreach a in basic::SplitWords("fg hi jk") - print(a); +foreach a in basic::SplitWords( "fg hi jk" ) + print( a ); endforeach diff --git a/testsuite/escript/for/foreach19-over-method-call-result-disallowed.err b/testsuite/escript/for/foreach19-over-method-call-result-disallowed.err index 2182d99b5..0338d1126 100644 --- a/testsuite/escript/for/foreach19-over-method-call-result-disallowed.err +++ b/testsuite/escript/for/foreach19-over-method-call-result-disallowed.err @@ -1 +1 @@ -foreach19-over-method-call-result-disallowed.src:5:15: error: mismatched input '.' expecting 'endforeach' \ No newline at end of file +:5:15: error: mismatched input '.' expecting 'endforeach' \ No newline at end of file diff --git a/testsuite/escript/for/foreach20-over-function-reference-disallowed.err b/testsuite/escript/for/foreach20-over-function-reference-disallowed.err index cbca0f4a2..f11a9968b 100644 --- a/testsuite/escript/for/foreach20-over-function-reference-disallowed.err +++ b/testsuite/escript/for/foreach20-over-function-reference-disallowed.err @@ -1 +1 @@ -foreach20-over-function-reference-disallowed.src:6:15: error: mismatched input '.' expecting 'endforeach' \ No newline at end of file +:6:15: error: mismatched input '.' expecting 'endforeach' \ No newline at end of file diff --git a/testsuite/escript/for/foreach21-over-parenthesized-expression.src b/testsuite/escript/for/foreach21-over-parenthesized-expression.src index a15617c0d..f3e71799b 100644 --- a/testsuite/escript/for/foreach21-over-parenthesized-expression.src +++ b/testsuite/escript/for/foreach21-over-parenthesized-expression.src @@ -1,8 +1,8 @@ function foo() - return { 11, 18, 14 }; + return { 11, 18, 14 }; endfunction var f := @foo; -foreach a in (f.call()) - print(a); +foreach a in ( f.call() ) + print( a ); endforeach diff --git a/testsuite/escript/func/func0.src b/testsuite/escript/func/func0.src index eb5202dc8..4368e9864 100644 --- a/testsuite/escript/func/func0.src +++ b/testsuite/escript/func/func0.src @@ -1,8 +1,7 @@ -function foo( a, b,c,d ) - return a*b+c*d; +function foo( a, b, c, d ) + return a * b + c * d; endfunction - var a; a := foo( 2, 3.5, 6.7, 9 ); diff --git a/testsuite/escript/func/func001-oneline.src b/testsuite/escript/func/func001-oneline.src index 29a97be69..a89bb976e 100644 --- a/testsuite/escript/func/func001-oneline.src +++ b/testsuite/escript/func/func001-oneline.src @@ -1,5 +1,5 @@ print( foo() ); function foo() - return 5; + return 5; endfunction diff --git a/testsuite/escript/func/func002-multiline.src b/testsuite/escript/func/func002-multiline.src index 6f8c4772c..d7ba2ba94 100644 --- a/testsuite/escript/func/func002-multiline.src +++ b/testsuite/escript/func/func002-multiline.src @@ -1,6 +1,6 @@ print( foo() ); function foo() - var a := 6; - return a; + var a := 6; + return a; endfunction diff --git a/testsuite/escript/func/func010-non-optimizable-default-parameter.err b/testsuite/escript/func/func010-non-optimizable-default-parameter.err index 597129056..6a4e0b4d8 100644 --- a/testsuite/escript/func/func010-non-optimizable-default-parameter.err +++ b/testsuite/escript/func/func010-non-optimizable-default-parameter.err @@ -1 +1 @@ -func010-non-optimizable-default-parameter.src:5:14: error: Parameter 'x' has a disallowed default. Only simple operands are allowed as default arguments. \ No newline at end of file +:5:15: error: Parameter 'x' has a disallowed default. Only simple operands are allowed as default arguments. \ No newline at end of file diff --git a/testsuite/escript/func/func010-non-optimizable-default-parameter.src b/testsuite/escript/func/func010-non-optimizable-default-parameter.src index 58c9f09c1..25708ff93 100644 --- a/testsuite/escript/func/func010-non-optimizable-default-parameter.src +++ b/testsuite/escript/func/func010-non-optimizable-default-parameter.src @@ -1,9 +1,9 @@ -function bar(y) - print(y); +function bar( y ) + print( y ); endfunction -function foo(x := bar(3)) - print(x); +function foo( x := bar( 3 ) ) + print( x ); endfunction -foo(6); +foo( 6 ); diff --git a/testsuite/escript/func/func011-default-parameter-bare-function-call.err b/testsuite/escript/func/func011-default-parameter-bare-function-call.err index 8c3950515..6a4e0b4d8 100644 --- a/testsuite/escript/func/func011-default-parameter-bare-function-call.err +++ b/testsuite/escript/func/func011-default-parameter-bare-function-call.err @@ -1 +1 @@ -func011-default-parameter-bare-function-call.src:5:14: error: Parameter 'x' has a disallowed default. Only simple operands are allowed as default arguments. \ No newline at end of file +:5:15: error: Parameter 'x' has a disallowed default. Only simple operands are allowed as default arguments. \ No newline at end of file diff --git a/testsuite/escript/func/func011-default-parameter-bare-function-call.src b/testsuite/escript/func/func011-default-parameter-bare-function-call.src index 9ebbbc0b0..abdb597e1 100644 --- a/testsuite/escript/func/func011-default-parameter-bare-function-call.src +++ b/testsuite/escript/func/func011-default-parameter-bare-function-call.src @@ -2,8 +2,8 @@ use math; // "Only simple operands..." -function foo(x := ConstPi()) - print(x); +function foo( x := ConstPi() ) + print( x ); endfunction foo(); diff --git a/testsuite/escript/func/func012-byref-unused.src b/testsuite/escript/func/func012-byref-unused.src index a8c3480a1..154018542 100644 --- a/testsuite/escript/func/func012-byref-unused.src +++ b/testsuite/escript/func/func012-byref-unused.src @@ -1,5 +1,5 @@ -function foo(byref unused x) - print("not using"); +function foo( byref unused x ) + print( "not using" ); endfunction -foo(4); +foo( 4 ); diff --git a/testsuite/escript/func/func013-double-semicolon.src b/testsuite/escript/func/func013-double-semicolon.src index 367691f85..c67a03b5d 100644 --- a/testsuite/escript/func/func013-double-semicolon.src +++ b/testsuite/escript/func/func013-double-semicolon.src @@ -5,8 +5,7 @@ // function foo() - return "bar";; + return "bar"; endfunction -print(foo()); - +print( foo() ); diff --git a/testsuite/escript/func/func014-module-function-conflict.err b/testsuite/escript/func/func014-module-function-conflict.err index eb87dd12f..fa439a1c7 100644 --- a/testsuite/escript/func/func014-module-function-conflict.err +++ b/testsuite/escript/func/func014-module-function-conflict.err @@ -1 +1 @@ -func014-module-function-conflict.src:2:1: error: User Function 'Broadcast' conflicts with Module Function of the same name. \ No newline at end of file +:2:1: error: User Function 'Broadcast' conflicts with Module Function of the same name. \ No newline at end of file diff --git a/testsuite/escript/func/func014-module-function-conflict.src b/testsuite/escript/func/func014-module-function-conflict.src index 92d972386..ac2a6bcde 100644 --- a/testsuite/escript/func/func014-module-function-conflict.src +++ b/testsuite/escript/func/func014-module-function-conflict.src @@ -1,2 +1,3 @@ use uo; -function Broadcast() endfunction +function Broadcast() +endfunction diff --git a/testsuite/escript/func/func015-module-function-conflict.err b/testsuite/escript/func/func015-module-function-conflict.err index bb5ea6538..c095af918 100644 --- a/testsuite/escript/func/func015-module-function-conflict.err +++ b/testsuite/escript/func/func015-module-function-conflict.err @@ -1 +1 @@ -func015-module-function-conflict.src:1:1: error: User Function 'Broadcast' conflicts with Module Function of the same name. \ No newline at end of file +:1:1: error: User Function 'Broadcast' conflicts with Module Function of the same name. \ No newline at end of file diff --git a/testsuite/escript/func/func015-module-function-conflict.src b/testsuite/escript/func/func015-module-function-conflict.src index a56ab4427..feb8a4d66 100644 --- a/testsuite/escript/func/func015-module-function-conflict.src +++ b/testsuite/escript/func/func015-module-function-conflict.src @@ -1,2 +1,3 @@ -function Broadcast() endfunction +function Broadcast() +endfunction use uo; diff --git a/testsuite/escript/func/func04.src b/testsuite/escript/func/func04.src index 90912f6e8..fca4d71c1 100644 --- a/testsuite/escript/func/func04.src +++ b/testsuite/escript/func/func04.src @@ -1,4 +1,4 @@ function foo( a := 6 / 3, b := "blah" ) - print( a + " " + b ); + print( a + " " + b ); endfunction foo(); diff --git a/testsuite/escript/func/func05.src b/testsuite/escript/func/func05.src index 200b7a503..0bb48d9a2 100644 --- a/testsuite/escript/func/func05.src +++ b/testsuite/escript/func/func05.src @@ -1,6 +1,6 @@ const BAR := 6; function foo( a := BAR / 3, b := "blah" ) - print( a + " " + b ); + print( a + " " + b ); endfunction foo(); diff --git a/testsuite/escript/func/func06.err b/testsuite/escript/func/func06.err index 720e8fc57..97dac8d12 100644 --- a/testsuite/escript/func/func06.err +++ b/testsuite/escript/func/func06.err @@ -1 +1 @@ -func06.src:5:15: error: Parameter 'a' has a disallowed default. Only simple operands are allowed as default arguments. \ No newline at end of file +:5:15: error: Parameter 'a' has a disallowed default. Only simple operands are allowed as default arguments. \ No newline at end of file diff --git a/testsuite/escript/func/func06.src b/testsuite/escript/func/func06.src index 151194917..c39391cd4 100644 --- a/testsuite/escript/func/func06.src +++ b/testsuite/escript/func/func06.src @@ -1,9 +1,9 @@ function bar() - print( "bar" ); + print( "bar" ); endfunction function foo( a := bar(), b := "blah" ) - print( a + " " + b ); + print( a + " " + b ); endfunction foo(); diff --git a/testsuite/escript/func/func07.src b/testsuite/escript/func/func07.src index bf3d19910..65987a2c3 100644 --- a/testsuite/escript/func/func07.src +++ b/testsuite/escript/func/func07.src @@ -1,22 +1,19 @@ - foo(); - - function bar01() - print( "bar01" ); + print( "bar01" ); endfunction function bar02() - print( "bar02" ); + print( "bar02" ); endfunction function bar() - bar01(); - bar02(); + bar01(); + bar02(); endfunction function foo( a := "foo", b := "blah" ) - print( a + " " + b ); + print( a + " " + b ); endfunction diff --git a/testsuite/escript/func/func08.src b/testsuite/escript/func/func08.src index 1aff6c6e2..b4c347dbc 100644 --- a/testsuite/escript/func/func08.src +++ b/testsuite/escript/func/func08.src @@ -1,18 +1,18 @@ program f() - foo( 1, 2 ); + foo( 1, 2 ); endprogram function foo( a, b ) - if (a) - print( "a true" ); - if (b) - print( "b true" ); - else - print( "b false" ); - endif + if ( a ) + print( "a true" ); + if ( b ) + print( "b true" ); else - print( "a false" ); - return; + print( "b false" ); endif + else + print( "a false" ); + return; + endif endfunction diff --git a/testsuite/escript/func/func09.err b/testsuite/escript/func/func09.err index f5d823b4a..47f51cde2 100644 --- a/testsuite/escript/func/func09.err +++ b/testsuite/escript/func/func09.err @@ -1 +1 @@ -func09.src:3:33: error: missing ')' at ';' \ No newline at end of file +:3:33: error: missing ')' at ';' \ No newline at end of file diff --git a/testsuite/escript/func/func0a.src b/testsuite/escript/func/func0a.src index 4593e0a7d..a253ea261 100644 --- a/testsuite/escript/func/func0a.src +++ b/testsuite/escript/func/func0a.src @@ -1,13 +1,13 @@ function foo2( a, b, e ) - return a+b+e; + return a + b + e; endfunction -function foo( a, b,c,d ) - return a*b+c*d-foo2( 12,c,2 ); +function foo( a, b, c, d ) + return a * b + c * d - foo2( 12, c, 2 ); endfunction var a; a := foo( 2, 3.5, 6.7, 9 ); -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/func/func0ab.src b/testsuite/escript/func/func0ab.src index 4593e0a7d..a253ea261 100644 --- a/testsuite/escript/func/func0ab.src +++ b/testsuite/escript/func/func0ab.src @@ -1,13 +1,13 @@ function foo2( a, b, e ) - return a+b+e; + return a + b + e; endfunction -function foo( a, b,c,d ) - return a*b+c*d-foo2( 12,c,2 ); +function foo( a, b, c, d ) + return a * b + c * d - foo2( 12, c, 2 ); endfunction var a; a := foo( 2, 3.5, 6.7, 9 ); -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/func/func0b.src b/testsuite/escript/func/func0b.src index eb5202dc8..4368e9864 100644 --- a/testsuite/escript/func/func0b.src +++ b/testsuite/escript/func/func0b.src @@ -1,8 +1,7 @@ -function foo( a, b,c,d ) - return a*b+c*d; +function foo( a, b, c, d ) + return a * b + c * d; endfunction - var a; a := foo( 2, 3.5, 6.7, 9 ); diff --git a/testsuite/escript/func/func1.src b/testsuite/escript/func/func1.src index 42c4bf5c9..f75f530d1 100644 --- a/testsuite/escript/func/func1.src +++ b/testsuite/escript/func/func1.src @@ -1,61 +1,60 @@ -//declare function foo2(); -//declare function foo3(a, b, c); -//declare function foo5(a , g); +// declare function foo2(); +// declare function foo3(a, b, c); +// declare function foo5(a , g); var a := "ll"; // MID( "hello world", 3, 2 ); function foo1() - print( "foo1" ); + print( "foo1" ); endfunction function foo2( a ) - print( "foo2: a=" + a ); + print( "foo2: a=" + a ); endfunction function foo3( a := 5 ) - print( "foo3: a=" + a ); + print( "foo3: a=" + a ); endfunction -function foo4( a, b:="hello" ) - print( "foo4: a=" + a ); - print( "foo4: b=" + b ); +function foo4( a, b := "hello" ) + print( "foo4: a=" + a ); + print( "foo4: b=" + b ); endfunction -function foo5( a:=1, b:=2 ) - print( "foo5: a=" + a ); - print( "foo5: b=" + b); +function foo5( a := 1, b := 2 ) + print( "foo5: a=" + a ); + print( "foo5: b=" + b ); endfunction function foo6( a := 2, b ) - print( "foo6: a=" + a ); - print( "foo6: b=" + b ); + print( "foo6: a=" + a ); + print( "foo6: b=" + b ); endfunction function foo7( a := 2, b, c := 7 ) - print( "foo7: a=" + a ); - print( "foo7: b=" + b ); - print( "foo7: c=" + c ); + print( "foo7: a=" + a ); + print( "foo7: b=" + b ); + print( "foo7: c=" + c ); endfunction - // Program Start var b, c; print( "Program Starting - Function Test (Func1.src)" ); a := 5; -b := 7+8; +b := 7 + 8; foo5( 6, 2 ); c := foo5( 7, 1 ); foo1(); -foo2("hello"); +foo2( "hello" ); foo3(); -foo3("hello foo3"); -foo3(5.4); +foo3( "hello foo3" ); +foo3( 5.4 ); foo3( a := 6 ); foo3( a := "hey" ); -foo4( a:= 3, b := 6); +foo4( a := 3, b := 6 ); foo5( 17, 32 ); foo5( 12 ); foo5(); @@ -65,8 +64,7 @@ foo5( b := 3 ); foo5( b := 9, a := 3 ); // Any of these lines should break the compile. -//foo1( 3 ); -//foo1( "hello" ); -//foo1( a := 4 ); -//foo7( b := "blah blah" , 3, 2); - +// foo1( 3 ); +// foo1( "hello" ); +// foo1( a := 4 ); +// foo7( b := "blah blah" , 3, 2); diff --git a/testsuite/escript/func/func1b.src b/testsuite/escript/func/func1b.src index 42c4bf5c9..f75f530d1 100644 --- a/testsuite/escript/func/func1b.src +++ b/testsuite/escript/func/func1b.src @@ -1,61 +1,60 @@ -//declare function foo2(); -//declare function foo3(a, b, c); -//declare function foo5(a , g); +// declare function foo2(); +// declare function foo3(a, b, c); +// declare function foo5(a , g); var a := "ll"; // MID( "hello world", 3, 2 ); function foo1() - print( "foo1" ); + print( "foo1" ); endfunction function foo2( a ) - print( "foo2: a=" + a ); + print( "foo2: a=" + a ); endfunction function foo3( a := 5 ) - print( "foo3: a=" + a ); + print( "foo3: a=" + a ); endfunction -function foo4( a, b:="hello" ) - print( "foo4: a=" + a ); - print( "foo4: b=" + b ); +function foo4( a, b := "hello" ) + print( "foo4: a=" + a ); + print( "foo4: b=" + b ); endfunction -function foo5( a:=1, b:=2 ) - print( "foo5: a=" + a ); - print( "foo5: b=" + b); +function foo5( a := 1, b := 2 ) + print( "foo5: a=" + a ); + print( "foo5: b=" + b ); endfunction function foo6( a := 2, b ) - print( "foo6: a=" + a ); - print( "foo6: b=" + b ); + print( "foo6: a=" + a ); + print( "foo6: b=" + b ); endfunction function foo7( a := 2, b, c := 7 ) - print( "foo7: a=" + a ); - print( "foo7: b=" + b ); - print( "foo7: c=" + c ); + print( "foo7: a=" + a ); + print( "foo7: b=" + b ); + print( "foo7: c=" + c ); endfunction - // Program Start var b, c; print( "Program Starting - Function Test (Func1.src)" ); a := 5; -b := 7+8; +b := 7 + 8; foo5( 6, 2 ); c := foo5( 7, 1 ); foo1(); -foo2("hello"); +foo2( "hello" ); foo3(); -foo3("hello foo3"); -foo3(5.4); +foo3( "hello foo3" ); +foo3( 5.4 ); foo3( a := 6 ); foo3( a := "hey" ); -foo4( a:= 3, b := 6); +foo4( a := 3, b := 6 ); foo5( 17, 32 ); foo5( 12 ); foo5(); @@ -65,8 +64,7 @@ foo5( b := 3 ); foo5( b := 9, a := 3 ); // Any of these lines should break the compile. -//foo1( 3 ); -//foo1( "hello" ); -//foo1( a := 4 ); -//foo7( b := "blah blah" , 3, 2); - +// foo1( 3 ); +// foo1( "hello" ); +// foo1( a := 4 ); +// foo7( b := "blah blah" , 3, 2); diff --git a/testsuite/escript/func/func2.err b/testsuite/escript/func/func2.err index 7a0a40f60..8520ad84c 100644 --- a/testsuite/escript/func/func2.err +++ b/testsuite/escript/func/func2.err @@ -1 +1 @@ -func2.src:6:2: error: missing 'endfunction' at 'print' \ No newline at end of file +:6:2: error: missing 'endfunction' at 'print' \ No newline at end of file diff --git a/testsuite/escript/func/func2b.err b/testsuite/escript/func/func2b.err index c402d7547..c57e57e87 100644 --- a/testsuite/escript/func/func2b.err +++ b/testsuite/escript/func/func2b.err @@ -1 +1 @@ -func2b.src:7:2: error: missing 'endfunction' at 'print' \ No newline at end of file +:7:2: error: missing 'endfunction' at 'print' \ No newline at end of file diff --git a/testsuite/escript/func/funceof.err b/testsuite/escript/func/funceof.err index 1f5f39a7f..994e1dda6 100644 --- a/testsuite/escript/func/funceof.err +++ b/testsuite/escript/func/funceof.err @@ -1 +1 @@ -funceof.src:9:24: error: missing 'endfunction' at '' \ No newline at end of file +:9:24: error: missing 'endfunction' at '' \ No newline at end of file diff --git a/testsuite/escript/func/funcref01.src b/testsuite/escript/func/funcref01.src index 51483e8e3..6b2e4c932 100644 --- a/testsuite/escript/func/funcref01.src +++ b/testsuite/escript/func/funcref01.src @@ -1,26 +1,26 @@ -function test(c) - return("works"+c); +function test( c ) + return ( "works" + c ); endfunction -function copy(c) - print(c.call("copy")); +function copy( c ) + print( c.call( "copy" ) ); endfunction program t() -var f:=@test; -var res:=f.call("direct"); -copy(f); -print("res "+res); -print(@test); -copy(@test); + var f := @test; + var res := f.call( "direct" ); + copy( f ); + print( "res " + res ); + print( @test ); + copy( @test ); -if (f) - print("error"); -else - print("funcref is always false"); -endif + if ( f ) + print( "error" ); + else + print( "funcref is always false" ); + endif -// should be packet to uninit -print(pack(f)); -print(unpack(pack(f))); + // should be packet to uninit + print( pack( f ) ); + print( unpack( pack( f ) ) ); endprogram diff --git a/testsuite/escript/func/funcref02.src b/testsuite/escript/func/funcref02.src index 7e6a40687..cb1316b82 100644 --- a/testsuite/escript/func/funcref02.src +++ b/testsuite/escript/func/funcref02.src @@ -1,38 +1,38 @@ -function init_animal(byref self) - self.+yell:=@animal_yell; +function init_animal( byref self ) + self.+yell := @animal_yell; endfunction -function animal_yell(byref self) - print(self.text.call(self)); +function animal_yell( byref self ) + print( self.text.call( self ) ); endfunction function init_cat() - var cat:=struct; - init_animal(cat); - cat.+text:=@cat_text; + var cat := struct; + init_animal( cat ); + cat.+text := @cat_text; return cat; endfunction -function cat_text(byref self) +function cat_text( byref self ) return "miau"; endfunction function init_dog() - var dog:=struct; - init_animal(dog); - dog.+text:=@dog_text; - dog.+angry:=0; + var dog := struct; + init_animal( dog ); + dog.+text := @dog_text; + dog.+angry := 0; return dog; endfunction -function dog_text(byref self) - if (self.angry) +function dog_text( byref self ) + if ( self.angry ) return "ggggrrr"; endif return "wuff"; endfunction -var dog:=init_dog(); -dog.yell.call(dog); -dog.angry:=1; -dog.yell.call(dog); +var dog := init_dog(); +dog.yell.call( dog ); +dog.angry := 1; +dog.yell.call( dog ); -var cat:=init_cat(); -cat.yell.call(cat); +var cat := init_cat(); +cat.yell.call( cat ); diff --git a/testsuite/escript/func/funcref04.err b/testsuite/escript/func/funcref04.err index 3a32b115e..c17db6a50 100644 --- a/testsuite/escript/func/funcref04.err +++ b/testsuite/escript/func/funcref04.err @@ -1 +1 @@ -funcref04.src:7:10: error: Unknown identifier 'sum'. \ No newline at end of file +:7:10: error: Unknown identifier 'sum'. \ No newline at end of file diff --git a/testsuite/escript/func/funcref05.err b/testsuite/escript/func/funcref05.err index e31894771..8628a96f6 100644 --- a/testsuite/escript/func/funcref05.err +++ b/testsuite/escript/func/funcref05.err @@ -1 +1 @@ -funcref05.src:1:8: error: In function call: Cannot use named arguments here. \ No newline at end of file +:1:8: error: In function call: Cannot use named arguments here. \ No newline at end of file diff --git a/testsuite/escript/func/funcref08.src b/testsuite/escript/func/funcref08.src index 5ddeb89c2..401eb7eb5 100644 --- a/testsuite/escript/func/funcref08.src +++ b/testsuite/escript/func/funcref08.src @@ -1,4 +1,4 @@ // This is technically valid, but the callee does not implement MTH_CALL so // results in a BError. -print( 4("hello") ); +print( 4( "hello" ) ); diff --git a/testsuite/escript/func/funcref09.src b/testsuite/escript/func/funcref09.src index 342195328..879a9c4a0 100644 --- a/testsuite/escript/func/funcref09.src +++ b/testsuite/escript/func/funcref09.src @@ -6,11 +6,11 @@ print( @args2() ); print( @args2plus() ); print( @args3() ); print( "-" ); -print( @args0(1) ); -print( @args1(1) ); -print( @args2(1) ); -print( @args2plus(1) ); -print( @args3(1) ); +print( @args0( 1 ) ); +print( @args1( 1 ) ); +print( @args2( 1 ) ); +print( @args2plus( 1 ) ); +print( @args3( 1 ) ); function args0() endfunction @@ -21,7 +21,7 @@ endfunction function args2( a, b ) endfunction -function args2plus( a, b, c... ) +function args2plus( a, b, c ... ) endfunction function args3( a, b, c ) diff --git a/testsuite/escript/func/var-args-captures.src b/testsuite/escript/func/var-args-captures.src index aad3f72bd..e91bef998 100644 --- a/testsuite/escript/func/var-args-captures.src +++ b/testsuite/escript/func/var-args-captures.src @@ -2,7 +2,7 @@ // Tests via function expression call `(@(){})(...)` with captures // ----- -if ("1") // make local block +if ( "1" ) // make local block var cap0 := -1; var sum_functor := @( args ... ) { @@ -12,12 +12,12 @@ if ("1") // make local block var sumWithArg_functor := @( arg0, args ... ) { var loc0 := 123; // capture cap0, arg0, loc0; and args - return (@(){ - if (loc0 != 123) + return ( @() { + if ( loc0 != 123 ) return error{}; endif return $"sum of {cap0} + {arg0} + {args}"; - })(); + } )(); }; var sumWithArgs_functor := @( arg0, arg1, args ... ) { diff --git a/testsuite/escript/func/var-args-continuation.src b/testsuite/escript/func/var-args-continuation.src index a5ef53996..0932077b8 100644 --- a/testsuite/escript/func/var-args-continuation.src +++ b/testsuite/escript/func/var-args-continuation.src @@ -1,41 +1,40 @@ // Tests via function expression call `(@(){})(...)` with continuation (MTH_FILTER). - // Depending on the signature of the filter function, the rest parameter `args` // will contain elements `{element, index, arr}`. For each additional non-rest // parameter, the rest parameter's `args` goes down: see the .out -var filter1 := @( args... ) { +var filter1 := @( args ... ) { print( $"args={args}" ); return 1; }; -var filter2 := @( element, args... ) { +var filter2 := @( element, args ... ) { print( $"element={element} args={args}" ); return 1; }; -var filter3 := @( element, index, args... ) { +var filter3 := @( element, index, args ... ) { print( $"element={element} index={index} args={args}" ); return 1; }; -var filter4 := @( element, index, arr, args... ) { +var filter4 := @( element, index, arr, args ... ) { print( $"element={element} index={index} arr={arr} args={args}" ); return 1; }; // Single element array. // Continuation callback does not return a continuation -array{"a"}.filter( filter1 ); -array{"a"}.filter( filter2 ); -array{"a"}.filter( filter3 ); -array{"a"}.filter( filter4 ); +array{ "a" }.filter( filter1 ); +array{ "a" }.filter( filter2 ); +array{ "a" }.filter( filter3 ); +array{ "a" }.filter( filter4 ); print( "-" ); // Multiple element array. // Continuation callback returns a continuation, then a non-continuation -array{"a", "b", "c"}.filter( filter1 ); -array{"a", "b", "c"}.filter( filter2 ); -array{"a", "b", "c"}.filter( filter3 ); -array{"a", "b", "c"}.filter( filter4 ); +array{ "a", "b", "c" }.filter( filter1 ); +array{ "a", "b", "c" }.filter( filter2 ); +array{ "a", "b", "c" }.filter( filter3 ); +array{ "a", "b", "c" }.filter( filter4 ); diff --git a/testsuite/escript/func/var-args-err-default-value.err b/testsuite/escript/func/var-args-err-default-value.err index 1b4bf0e74..0d09a479c 100644 --- a/testsuite/escript/func/var-args-err-default-value.err +++ b/testsuite/escript/func/var-args-err-default-value.err @@ -1 +1 @@ -var-args-err-default-value.src:1:15: error: Rest parameter 'args' cannot have a default value. \ No newline at end of file +:1:15: error: Rest parameter 'args' cannot have a default value. \ No newline at end of file diff --git a/testsuite/escript/func/var-args-err-last-param.err b/testsuite/escript/func/var-args-err-last-param.err index e818dd676..3ac3ac3c2 100644 --- a/testsuite/escript/func/var-args-err-last-param.err +++ b/testsuite/escript/func/var-args-err-last-param.err @@ -1 +1 @@ -var-args-err-last-param.src:1:15: error: Rest parameter must be the last parameter in the list. \ No newline at end of file +:1:15: error: Rest parameter must be the last parameter in the list. \ No newline at end of file diff --git a/testsuite/escript/funcexpr/assignment.src b/testsuite/escript/funcexpr/assignment.src index 75783f042..bb7ecd523 100644 --- a/testsuite/escript/funcexpr/assignment.src +++ b/testsuite/escript/funcexpr/assignment.src @@ -1,28 +1,28 @@ var g := 4; // global -if (1) -var z := 0; // local 0 -var func := @( a, b ) { - var c := "local 3"; - if ( a + b > 0 ) - c := a + b; - z := c + 1; - g := g + 1; - endif +if ( 1 ) + var z := 0; // local 0 + var func := @( a, b ) { + var c := "local 3"; + if ( a + b > 0 ) + c := a + b; + z := c + 1; + g := g + 1; + endif - // previous, bugged output: - // - // z=3 - // a=1 - // b=local 31 - // c=local 3 + // previous, bugged output: + // + // z=3 + // a=1 + // b=local 31 + // c=local 3 - print( $"z={z}" ); // z=4 - print( $"a={a}" ); // a=1 - print( $"b={b}" ); // b=2 - print( $"c={c}" ); // c=3 - print( $"g={g}" ); // g=5 -}; + print( $"z={z}" ); // z=4 + print( $"a={a}" ); // a=1 + print( $"b={b}" ); // b=2 + print( $"c={c}" ); // c=3 + print( $"g={g}" ); // g=5 + }; -func( 1, 2 ); + func( 1, 2 ); endif diff --git a/testsuite/escript/funcexpr/complex-nested-struct.src b/testsuite/escript/funcexpr/complex-nested-struct.src index b649d9309..e72206541 100644 --- a/testsuite/escript/funcexpr/complex-nested-struct.src +++ b/testsuite/escript/funcexpr/complex-nested-struct.src @@ -3,84 +3,66 @@ // The most-inner function will create a local (circumstantially, inside an // `if`-block) to test returning locals. -var level1 := @(a, b, c) { - return struct{ - fnA1 := @(d, e, f) { - return struct{ - fnB1 := @(g, h, i) { - return struct{ - fnC1 := @(j, unused k, l) { - var res := a + b + c + d + e + f + g + h + i + j; - if (res > 0) - var out_local := res * l; - return out_local; - endif - return res; - }, - - fnC2 := @(j, unused k, l) { - var res := a * b * c * d * e * f * g * h * i * j; - if (res > 0) - var out_local := res / l; - return out_local; - endif - return res; - }, - - fnC3 := @(j, unused k, l) { - var res := a - b - c - d - e - f - g - h - i - j; - if (res > 0) - var out_local := res + l; - return out_local; - endif - return res; - } - }; - }, - - fnB2 := @(g, h, i) { - return struct{ - fnC1 := @(j, unused k, l) { - var res := a * b + c + d + e + f + g + h + i + j; - if (res > 0) - var out_local := res * l; - return out_local; - endif - return res; - }, - - fnC2 := @(j, unused k, l) { - var res := a + b * c * d * e * f * g * h * i * j; - if (res > 0) - var out_local := res / l; - return out_local; - endif - return res; - }, - - fnC3 := @(j, unused k, l) { - var res := a - b * c - d - e - f - g - h - i - j; - if (res > 0) - var out_local := res + l; - return out_local; - endif - return res; - } - }; - } - }; - } - }; +var level1 := @( a, b, c ) { + return struct{ fnA1 := @( d, e, f ) { + return struct{ fnB1 := @( g, h, i ) { + return struct{ fnC1 := @( j, unused k, l ) { + var res := a + b + c + d + e + f + g + h + i + j; + if ( res > 0 ) + var out_local := res * l; + return out_local; + endif + return res; + }, fnC2 := @( j, unused k, l ) { + var res := a * b * c * d * e * f * g * h * i * j; + if ( res > 0 ) + var out_local := res / l; + return out_local; + endif + return res; + }, fnC3 := @( j, unused k, l ) { + var res := a - b - c - d - e - f - g - h - i - j; + if ( res > 0 ) + var out_local := res + l; + return out_local; + endif + return res; + } }; + }, fnB2 := @( g, h, i ) { + return struct{ fnC1 := @( j, unused k, l ) { + var res := a * b + c + d + e + f + g + h + i + j; + if ( res > 0 ) + var out_local := res * l; + return out_local; + endif + return res; + }, fnC2 := @( j, unused k, l ) { + var res := a + b * c * d * e * f * g * h * i * j; + if ( res > 0 ) + var out_local := res / l; + return out_local; + endif + return res; + }, fnC3 := @( j, unused k, l ) { + var res := a - b * c - d - e - f - g - h - i - j; + if ( res > 0 ) + var out_local := res + l; + return out_local; + endif + return res; + } }; + } }; + } }; }; // (a + b + c + d + e + f + g + h + i + j) * l since inner expression is >0 // (-7 + -6 + -1 + 4 + -4 + 17 + 9 + 3 + 15 + -10) * -7 = -140 -print(level1(-7, -6, -1).fnA1.call(4, -4, 17).fnB1.call(9, 3, 15).fnC1.call(-10, -7, -7)); +print( level1( -7, -6, -1 ).fnA1.call( 4, -4, 17 ).fnB1.call( 9, 3, 15 ).fnC1.call( -10, -7, -7 ) ); // a * b + c + d + e + f + g + h + i + j // -3 * -1 + 2 + -7 + -4 + -5 + -2 + 7 + 1 + -1 = -6 -print(level1(-3, -1, 2).fnA1.call(-7, -4, -5).fnB2.call(-2, 7, 1).fnC1.call(-1, 1, 5)); +print( level1( -3, -1, 2 ).fnA1.call( -7, -4, -5 ).fnB2.call( -2, 7, 1 ).fnC1.call( -1, 1, 5 ) ); // a - b * c - d - e - f - g - h - i - j // 10 - 2 * 11 - 10 - 2 - 4 - -8 - -1 - -5 - 10 = -24 -print(level1(10, 2, 11).fnA1.call(10, 2, 4).fnB2.call(-8, -1, -5).fnC3.call(10, -3, 1)); +print( level1( 10, 2, 11 ).fnA1.call( 10, 2, 4 ).fnB2.call( -8, -1, -5 ).fnC3.call( 10, -3, 1 ) ); diff --git a/testsuite/escript/funcexpr/curry.inc b/testsuite/escript/funcexpr/curry.inc index b10e199eb..9985534fa 100644 --- a/testsuite/escript/funcexpr/curry.inc +++ b/testsuite/escript/funcexpr/curry.inc @@ -1,13 +1,11 @@ function curry( f ) // curry(f) does the currying transform return @( a ) { - return @( b ) { - return f( a, b ); - }; + return @( b ) { return f( a, b ); }; }; endfunction // usage -function sum( a , b ) +function sum( a, b ) return a + b; endfunction diff --git a/testsuite/escript/funcexpr/curry.src b/testsuite/escript/funcexpr/curry.src index ff3095009..97bc5b7dc 100644 --- a/testsuite/escript/funcexpr/curry.src +++ b/testsuite/escript/funcexpr/curry.src @@ -5,6 +5,7 @@ var plus := curry( @sum ); var times := curry( @mul ); var minus := curry( @sub ); +// format-off // ( (4+8) - (5+1) ) * ( (3+2) - (1+2) ) var result := times( diff --git a/testsuite/escript/funcexpr/listfile-complex-1.src b/testsuite/escript/funcexpr/listfile-complex-1.src index 23004b1ff..c864edbb9 100644 --- a/testsuite/escript/funcexpr/listfile-complex-1.src +++ b/testsuite/escript/funcexpr/listfile-complex-1.src @@ -1,36 +1,37 @@ include "listfile"; -if ("") +if ( "" ) -var a; + var a; -@() { // Captures a implicitly - @(b) { // Captures a - a; - @(a) { // Does not capture `a`, so expect a 0-capture functure around this line + @() { // Captures a implicitly + @( b ) { // Captures a a; - @() { // Does not capture `a`, so expect a 0-capture functure around this line - var a; + @( a ) { // Does not capture `a`, so expect a 0-capture functure around this line + a; + @() { // Does not capture `a`, so expect a 0-capture functure around this line + var a; + a; + }; a; }; - a; - }; - @(c, d, e) { // Captures a - a; - @() { // Does not capture `a` but captures 'c', 'd', 'e' so expect a 3-capture functure around this line - var a; + @( c, d, e ) { // Captures a + a; + @() { + // Does not capture `a` but captures 'c', 'd', 'e' so expect a 3-capture functure around this line + var a; + a; + c; + d; + e; + }; a; - c; - d; - e; }; + var a; a; }; - var a; - a; }; -}; endif -print_listfile("listfile-complex-1"); +print_listfile( "listfile-complex-1" ); diff --git a/testsuite/escript/funcexpr/listfile-complex-2.src b/testsuite/escript/funcexpr/listfile-complex-2.src index cc64d13df..04b4ad7ad 100644 --- a/testsuite/escript/funcexpr/listfile-complex-2.src +++ b/testsuite/escript/funcexpr/listfile-complex-2.src @@ -1,33 +1,33 @@ include "listfile"; -if ("") +if ( "" ) -var a, b, c; + var a, b, c; -// A more complex example... + // A more complex example... -@() { + @() { b; // Local 1 in parent becomes local 0 here - @(c) { // c not captured - @(b) { // b not captured - a; // captured - c; // captured from parent - var a; // create new local - @() { - a; // captures local from parent - var b; - @(c) { // creates c - a; - b; - c; - }; - }; - }; + @( c ) { // c not captured + @( b ) { // b not captured a; // captured - c; // local parameter + c; // captured from parent + var a; // create new local + @() { + a; // captures local from parent + var b; + @( c ) { // creates c + a; + b; + c; + }; + }; + }; + a; // captured + c; // local parameter }; -}; + }; endif -print_listfile("listfile-complex-2"); \ No newline at end of file +print_listfile( "listfile-complex-2" ); diff --git a/testsuite/escript/funcexpr/listfile-curry.src b/testsuite/escript/funcexpr/listfile-curry.src index 973f8b724..747b298b2 100644 --- a/testsuite/escript/funcexpr/listfile-curry.src +++ b/testsuite/escript/funcexpr/listfile-curry.src @@ -1,8 +1,8 @@ include "listfile"; include "curry"; -var curriedSum := curry(@sum); +var curriedSum := curry( @sum ); -curriedSum(1)(2); +curriedSum( 1 )( 2 ); -print_listfile("listfile-curry"); +print_listfile( "listfile-curry" ); diff --git a/testsuite/escript/funcexpr/listfile-nested-1.src b/testsuite/escript/funcexpr/listfile-nested-1.src index fa844f5df..a6cfb66e0 100644 --- a/testsuite/escript/funcexpr/listfile-nested-1.src +++ b/testsuite/escript/funcexpr/listfile-nested-1.src @@ -1,23 +1,23 @@ include "listfile"; -if ("") +if ( "" ) -// Add some extra locals to make sure the local variable numbering is correct. -var foo, a, bar; + // Add some extra locals to make sure the local variable numbering is correct. + var foo, a, bar; -@() { @() { @() { @() { - a; - a; - a; - a; + @() { + a; + a; + a; + a; + }; }; }; }; -}; endif -print_listfile("listfile-nested-1"); +print_listfile( "listfile-nested-1" ); diff --git a/testsuite/escript/funcexpr/listfile-nested-2.src b/testsuite/escript/funcexpr/listfile-nested-2.src index a33843e75..e688a11b0 100644 --- a/testsuite/escript/funcexpr/listfile-nested-2.src +++ b/testsuite/escript/funcexpr/listfile-nested-2.src @@ -1,17 +1,14 @@ include "listfile"; -if ("") +if ( "" ) var a; -// Inner functions are preceeded and followed `a`. All variable accesses should -// all show up as `local param #0` in lst. -// -// This tests that when bubbling up captures from inner to outer function, -// variables are not duplicated / recaptured. -@() { - a; - a; + // Inner functions are preceeded and followed `a`. All variable accesses should + // all show up as `local param #0` in lst. + // + // This tests that when bubbling up captures from inner to outer function, + // variables are not duplicated / recaptured. @() { a; a; @@ -21,15 +18,18 @@ if ("") @() { a; a; + @() { + a; + a; + }; + a; + a; }; a; a; }; - a; - a; }; -}; endif -print_listfile("listfile-nested-2"); +print_listfile( "listfile-nested-2" ); diff --git a/testsuite/escript/funcexpr/listfile-nested-3.src b/testsuite/escript/funcexpr/listfile-nested-3.src index c575c36e1..6274e4388 100644 --- a/testsuite/escript/funcexpr/listfile-nested-3.src +++ b/testsuite/escript/funcexpr/listfile-nested-3.src @@ -1,23 +1,21 @@ include "listfile"; -if ("") +if ( "" ) -var a; + var a; -// Creates a chain of functors using zero captures, each using its own local function parameter `a` -@(a) { - a; - @(a) { + // Creates a chain of functors using zero captures, each using its own local function parameter `a` + @( a ) { a; - @(a) { + @( a ) { a; - @(a) { + @( a ) { a; + @( a ) { a; }; }; }; }; -}; endif -print_listfile("listfile-nested-3"); +print_listfile( "listfile-nested-3" ); diff --git a/testsuite/escript/funcexpr/listfile-nested-4.src b/testsuite/escript/funcexpr/listfile-nested-4.src index 4a0e9bab3..f0a006ea4 100644 --- a/testsuite/escript/funcexpr/listfile-nested-4.src +++ b/testsuite/escript/funcexpr/listfile-nested-4.src @@ -1,27 +1,25 @@ include "listfile"; -if ("") +if ( "" ) -var a; + var a; -// Each inner function is followed by `a`, and should all use `local 0`. -// -// This tests that when bubbling up captures from inner to outer function, -// variables are not duplicated / recaptured. + // Each inner function is followed by `a`, and should all use `local 0`. + // + // This tests that when bubbling up captures from inner to outer function, + // variables are not duplicated / recaptured. -@() { @() { @() { @() { + @() { a; }; a; }; a; }; a; }; - a; -}; endif -print_listfile("listfile-nested-4"); +print_listfile( "listfile-nested-4" ); diff --git a/testsuite/escript/funcexpr/listfile-simple.src b/testsuite/escript/funcexpr/listfile-simple.src index 3fb9f2d62..a6882f930 100644 --- a/testsuite/escript/funcexpr/listfile-simple.src +++ b/testsuite/escript/funcexpr/listfile-simple.src @@ -1,16 +1,16 @@ include "listfile"; -if ("") // create a local scope +if ( "" ) // create a local scope var a; // declare local 0 - @(b) { // create functor, 1 capture (a -> local 0) + @( b ) { // create functor, 1 capture (a -> local 0) - var c; // declare local 2, as bound `c` takes local #2 + var c; // declare local 2, as bound `c` takes local #2 - a; // access local 1 - b; // access local 0 - c; // access local 2 + a; // access local 1 + b; // access local 0 + c; // access local 2 }; endif diff --git a/testsuite/escript/funcexpr/listfile-syntax.src b/testsuite/escript/funcexpr/listfile-syntax.src index bd22d54a2..0e03a9981 100644 --- a/testsuite/escript/funcexpr/listfile-syntax.src +++ b/testsuite/escript/funcexpr/listfile-syntax.src @@ -1,9 +1,10 @@ include "listfile"; -@(i, j, k) { return 1; }; -@{}; +@( i, j, k ) { + return 1; +}; +@{ }; @() { return 1; }; -@(i, byref j, k) { return 1; }; - +@( i, byref j, k ) { return 1; }; print_listfile( "listfile-syntax" ); diff --git a/testsuite/escript/funcexpr/listfile.inc b/testsuite/escript/funcexpr/listfile.inc index fce6d8acb..33447f770 100644 --- a/testsuite/escript/funcexpr/listfile.inc +++ b/testsuite/escript/funcexpr/listfile.inc @@ -1,19 +1,19 @@ use file; function print_listfile( test ) - var lines := ReadFile( $"./funcexpr/{test}.lst" ); - if ( !lines ) - return print( lines ); - endif + var lines := ReadFile( $"./funcexpr/{test}.lst" ); + if ( !lines ) + return print( lines ); + endif - var prefix := ""; - foreach line in lines - print( $"{prefix}{line}" ); - // Uses interstrings to make these instructions not indented - if (line[$"{" "}{"create-functor"}"]) - prefix := $"{prefix} "; - elseif (line[$"{" "}{"return"}"]) - prefix := prefix[1, prefix.length() - 4] ?: ""; - endif - endforeach + var prefix := ""; + foreach line in lines + print( $"{prefix}{line}" ); + // Uses interstrings to make these instructions not indented + if ( line[$"{" "}{"create-functor"}"] ) + prefix := $"{prefix} "; + elseif ( line[$"{" "}{"return"}"] ) + prefix := prefix[1, prefix.length() - 4] ?: ""; + endif + endforeach endfunction diff --git a/testsuite/escript/funcexpr/nested-calls.src b/testsuite/escript/funcexpr/nested-calls.src index 7d90b03ab..ac0223a9f 100644 --- a/testsuite/escript/funcexpr/nested-calls.src +++ b/testsuite/escript/funcexpr/nested-calls.src @@ -1,9 +1,7 @@ -var complexOperation := @(x, y) { - return @(z) { - return x * y + z - (x + y); - }; +var complexOperation := @( x, y ) { + return @( z ) { return x * y + z - ( x + y ); }; }; -print(complexOperation(1, 2)(3)); // 1 * 2 + 3 - (1 + 2) = 2 -print(complexOperation(4, 5)(6)); // 4 * 5 + 6 - (4 + 5) = 17 -print(complexOperation(7, 8)(9)); // 7 * 8 + 9 - (7 + 8) = 50 +print( complexOperation( 1, 2 )( 3 ) ); // 1 * 2 + 3 - (1 + 2) = 2 +print( complexOperation( 4, 5 )( 6 ) ); // 4 * 5 + 6 - (4 + 5) = 17 +print( complexOperation( 7, 8 )( 9 ) ); // 7 * 8 + 9 - (7 + 8) = 50 diff --git a/testsuite/escript/funcexpr/syntax.src b/testsuite/escript/funcexpr/syntax.src index cffc90baa..3a3ccc5a7 100644 --- a/testsuite/escript/funcexpr/syntax.src +++ b/testsuite/escript/funcexpr/syntax.src @@ -1,6 +1,6 @@ var foo, bar; // probably the most common case -print(@(i, j, k) { return 1; }); -print(@{}); -print(@() { return 1; }); -print(@(i, byref j, k) { return 1; }); +print( @( i, j, k ) { return 1; } ); +print( @{ } ); +print( @() { return 1; } ); +print( @( i, byref j, k ) { return 1; } ); diff --git a/testsuite/escript/if/if.src b/testsuite/escript/if/if.src index e51ab5f6d..3443d197a 100644 --- a/testsuite/escript/if/if.src +++ b/testsuite/escript/if/if.src @@ -1,5 +1,5 @@ use basic; -if (1) - print( "hello world" ); +if ( 1 ) + print( "hello world" ); endif diff --git a/testsuite/escript/if/if01.src b/testsuite/escript/if/if01.src index 1eab46f75..203e6bef6 100644 --- a/testsuite/escript/if/if01.src +++ b/testsuite/escript/if/if01.src @@ -1,10 +1,9 @@ use basic; -if (1) - print( "hello world" ); -endif; +if ( 1 ) + print( "hello world" ); +endif // note the semicolon up there, after the endif - print( "hello world again" ); diff --git a/testsuite/escript/if/ifthen.src b/testsuite/escript/if/ifthen.src index d95880a62..17d7c4dfc 100644 --- a/testsuite/escript/if/ifthen.src +++ b/testsuite/escript/if/ifthen.src @@ -1,32 +1,32 @@ -if (1) - print( "Success: 1!" ); +if ( 1 ) + print( "Success: 1!" ); endif -if (0) - print( "Failure: 0!" ); -else - print( "Success: 2" ); -endif - -if (1) - print( "Success: 3" ); +if ( 0 ) + print( "Failure: 0!" ); else - if (1) - print( "Failure: 1!" ); - else - print( "Failuer: 2!" ); - endif + print( "Success: 2" ); +endif + +if ( 1 ) + print( "Success: 3" ); +else + if ( 1 ) + print( "Failure: 1!" ); + else + print( "Failuer: 2!" ); + endif endif print( "Out of if--then--if--then--else!" ); -if (0) - print( "Failure: 3!" ); +if ( 0 ) + print( "Failure: 3!" ); else - if (1) - print( "Success: 4!" ); - else - print( "Failure: 4!" ); - endif + if ( 1 ) + print( "Success: 4!" ); + else + print( "Failure: 4!" ); + endif endif print( "Success: 5!" ); diff --git a/testsuite/escript/in/in001.src b/testsuite/escript/in/in001.src index fec90a683..ee62d3c38 100644 --- a/testsuite/escript/in/in001.src +++ b/testsuite/escript/in/in001.src @@ -1,7 +1,7 @@ var a; -if (5 in a) - print( "Failure!" ); +if ( 5 in a ) + print( "Failure!" ); else - print( "Success!" ); + print( "Success!" ); endif diff --git a/testsuite/escript/in/in002.src b/testsuite/escript/in/in002.src index 36ff7c881..88d9ada47 100644 --- a/testsuite/escript/in/in002.src +++ b/testsuite/escript/in/in002.src @@ -1,13 +1,13 @@ var a array; -if (5 in a) - print( "Failure! (1)" ); +if ( 5 in a ) + print( "Failure! (1)" ); else - print( "Success! (1)" ); + print( "Success! (1)" ); endif -if (0 in a) - print( "Failure! (2)" ); +if ( 0 in a ) + print( "Failure! (2)" ); else - print( "Success! (2)" ); + print( "Success! (2)" ); endif diff --git a/testsuite/escript/in/in003.src b/testsuite/escript/in/in003.src index 34082afdf..0e11e3d51 100644 --- a/testsuite/escript/in/in003.src +++ b/testsuite/escript/in/in003.src @@ -3,14 +3,14 @@ var a array; a[1] := 42; a[2] := 4; -if (5 in a) - print( "Failure! (1)" ); +if ( 5 in a ) + print( "Failure! (1)" ); else - print( "Success! (1)" ); + print( "Success! (1)" ); endif -if (0 in a) - print( "Failure! (2)" ); +if ( 0 in a ) + print( "Failure! (2)" ); else - print( "Success! (2)" ); + print( "Success! (2)" ); endif diff --git a/testsuite/escript/in/in004.src b/testsuite/escript/in/in004.src index a05c943de..285f78745 100644 --- a/testsuite/escript/in/in004.src +++ b/testsuite/escript/in/in004.src @@ -4,14 +4,14 @@ a[1] := 42; a[2] := 5; a[3] := 7; -if (5 in a) - print( "Success! (1)" ); +if ( 5 in a ) + print( "Success! (1)" ); else - print( "Failure! (1)" ); + print( "Failure! (1)" ); endif -if (0 in a) - print( "Failure! (2)" ); +if ( 0 in a ) + print( "Failure! (2)" ); else - print( "Success! (2)" ); + print( "Success! (2)" ); endif diff --git a/testsuite/escript/in/inc01.err b/testsuite/escript/in/inc01.err index e47164b87..e16ffd746 100644 --- a/testsuite/escript/in/inc01.err +++ b/testsuite/escript/in/inc01.err @@ -1 +1 @@ -Unable to include file \ No newline at end of file +:1:1: error: Unable to include file \ No newline at end of file diff --git a/testsuite/escript/in/inc01.src b/testsuite/escript/in/inc01.src index 6bc5d3540..9078895f2 100644 --- a/testsuite/escript/in/inc01.src +++ b/testsuite/escript/in/inc01.src @@ -1,4 +1,3 @@ include nofile; print( foo( "bar" ) ); - diff --git a/testsuite/escript/in/inc02.err b/testsuite/escript/in/inc02.err index e47164b87..e16ffd746 100644 --- a/testsuite/escript/in/inc02.err +++ b/testsuite/escript/in/inc02.err @@ -1 +1 @@ -Unable to include file \ No newline at end of file +:1:1: error: Unable to include file \ No newline at end of file diff --git a/testsuite/escript/in/inc02.src b/testsuite/escript/in/inc02.src index f559adbc9..e83d51141 100644 --- a/testsuite/escript/in/inc02.src +++ b/testsuite/escript/in/inc02.src @@ -1,4 +1,3 @@ include testutil; print( foo( "bar" ) ); - diff --git a/testsuite/escript/in/inctst01.inc b/testsuite/escript/in/inctst01.inc index 9c6a2461a..cc828db89 100644 --- a/testsuite/escript/in/inctst01.inc +++ b/testsuite/escript/in/inctst01.inc @@ -1,7 +1,7 @@ function foo() - var a; - if (5) - a := 4; - print(a); - endif -endfunction \ No newline at end of file + var a; + if ( 5 ) + a := 4; + print( a ); + endif +endfunction diff --git a/testsuite/escript/interstring/interstring01.src b/testsuite/escript/interstring/interstring01.src index befdf5495..1830c968a 100644 --- a/testsuite/escript/interstring/interstring01.src +++ b/testsuite/escript/interstring/interstring01.src @@ -1,92 +1,92 @@ var t, id1, id2; var n := 0; -function testPrint(num) - n += 1; - print(CStr(n) + "."); - print(TypeOf(t)); - print(t); +function testPrint( num ) + n += 1; + print( CStr( n ) + "." ); + print( TypeOf( t ) ); + print( t ); endfunction t := $""; // zero parts -testPrint(t); +testPrint( t ); t := $"foo"; // one part, string -testPrint(t); +testPrint( t ); t := $"{1}"; // one part, expression -> integer literal -testPrint(t); +testPrint( t ); id1 := 0xbad.beefp4; -t := $"{id1}"; // one part, expression -> identifier -> hex float literal -testPrint(t); +t := $"{id1}"; // one part, expression -> identifier -> hex float literal +testPrint( t ); // #5 t := $"foo{""}"; // two parts -testPrint(t); +testPrint( t ); t := $"{1}bar"; // one part, expression -> integer literal -testPrint(t); +testPrint( t ); id1 := "foo"; id2 := "bar"; -t := $"{id1}{id2}"; // two parts -testPrint(t); +t := $"{id1}{id2}"; // two parts +testPrint( t ); t := $"{uninit}"; -testPrint(t); +testPrint( t ); t := $"!{uninit}"; -testPrint(t); +testPrint( t ); // #10 t := $"{uninit}!"; -testPrint(t); +testPrint( t ); t := $"!{uninit}!"; -testPrint(t); +testPrint( t ); -t := $"{CAsc("a")}"; // expression -> function call, that returns a Long -testPrint(t); +t := $"{CAsc( "a" )}"; // expression -> function call, that returns a Long +testPrint( t ); t := $"{48879:#x}"; -testPrint(t); +testPrint( t ); t := $"Hello {"string":#x}"; -testPrint(t); +testPrint( t ); // #15 t := $"Hello, {@testPrint}"; -testPrint(t); +testPrint( t ); t := $"Hello{$"\x61\x62\x63"}World"; -testPrint(t); +testPrint( t ); -t := $"Hello, {{{"_".join(array{1,2,3})}}}"; -testPrint(t); +t := $"Hello, {{{"_".join( array{ 1, 2, 3 } )}}}"; +testPrint( t ); t := $"{{"; -testPrint(t); +testPrint( t ); t := $"{{{{"; -testPrint(t); +testPrint( t ); // #20 t := $"}}"; -testPrint(t); +testPrint( t ); t := $"}}}}"; -testPrint(t); +testPrint( t ); t := $"{{}}"; -testPrint(t); +testPrint( t ); t := $"{{{{}}}}"; -testPrint(t); +testPrint( t ); t := $"{{{{{"_"}}}}}!{{{{" - "}}}}"; // interstring MINUS string -testPrint(t); +testPrint( t ); // #25 t := $"{{{{{"-"}}}}}!{{{"-"}}}"; -testPrint(t); +testPrint( t ); diff --git a/testsuite/escript/interstring/interstring02.err b/testsuite/escript/interstring/interstring02.err index 4c7dfcd40..1843f2e59 100644 --- a/testsuite/escript/interstring/interstring02.err +++ b/testsuite/escript/interstring/interstring02.err @@ -1 +1 @@ -interstring02.src:1:17: error: token recognition error at: '"; // no new line on purpose...' +:1:17: error: token recognition error at: '"; // no new line on purpose...' \ No newline at end of file diff --git a/testsuite/escript/interstring/interstring03.err b/testsuite/escript/interstring/interstring03.err index f3ed90069..65c4317b3 100644 --- a/testsuite/escript/interstring/interstring03.err +++ b/testsuite/escript/interstring/interstring03.err @@ -1 +1 @@ -interstring03.src:1:11: error: Expected expression following interpolated string part start +:1:11: error: Expected expression following interpolated string part start \ No newline at end of file diff --git a/testsuite/escript/interstring/interstring04.err b/testsuite/escript/interstring/interstring04.err index fba1d8dd3..c476c6768 100644 --- a/testsuite/escript/interstring/interstring04.err +++ b/testsuite/escript/interstring/interstring04.err @@ -1 +1 @@ -interstring04.src:1:18: error: missing FORMAT_STRING at '"' \ No newline at end of file +:1:18: error: missing FORMAT_STRING at '"' \ No newline at end of file diff --git a/testsuite/escript/interstring/interstring05.err b/testsuite/escript/interstring/interstring05.err index ccd31c0fa..21d7af8df 100644 --- a/testsuite/escript/interstring/interstring05.err +++ b/testsuite/escript/interstring/interstring05.err @@ -1 +1 @@ -interstring05.src:1:15: error: Expected expression following interpolated string part start +:1:15: error: Expected expression following interpolated string part start \ No newline at end of file diff --git a/testsuite/escript/interstring/interstring06.src b/testsuite/escript/interstring/interstring06.src index 74f807de2..e8c9de95a 100644 --- a/testsuite/escript/interstring/interstring06.src +++ b/testsuite/escript/interstring/interstring06.src @@ -1,4 +1,4 @@ var i := 0, j := 0; -print($"{++i}"); -print($"{j++}"); -print($"{i} {j}"); +print( $"{++i}" ); +print( $"{j++}" ); +print( $"{i} {j}" ); diff --git a/testsuite/escript/interstring/interstring07.err b/testsuite/escript/interstring/interstring07.err index 44ff3eb02..de7896c33 100644 --- a/testsuite/escript/interstring/interstring07.err +++ b/testsuite/escript/interstring/interstring07.err @@ -1 +1 @@ -interstring07.src:1:12: error: Expected expression following interpolated string part start +:1:12: error: Expected expression following interpolated string part start \ No newline at end of file diff --git a/testsuite/escript/interstring/interstring08.err b/testsuite/escript/interstring/interstring08.err index ad1dcaa3c..4a8f22bf0 100644 --- a/testsuite/escript/interstring/interstring08.err +++ b/testsuite/escript/interstring/interstring08.err @@ -1 +1 @@ -interstring08.src:1:10: error: token recognition error at: '}"' +:1:10: error: token recognition error at: '}"' \ No newline at end of file diff --git a/testsuite/escript/interstring/interstring09.err b/testsuite/escript/interstring/interstring09.err index 4992c7fb6..255d7bea5 100644 --- a/testsuite/escript/interstring/interstring09.err +++ b/testsuite/escript/interstring/interstring09.err @@ -1 +1 @@ -interstring09.src:1:12: error: token recognition error at: '}"' +:1:12: error: token recognition error at: '}"' \ No newline at end of file diff --git a/testsuite/escript/json/json01.src b/testsuite/escript/json/json01.src index c2eae711f..b1278a5bb 100644 --- a/testsuite/escript/json/json01.src +++ b/testsuite/escript/json/json01.src @@ -1,21 +1,19 @@ program main() - var expr := struct{ - "a" := "hello there", - "b" := Boolean(1), - "c" := array{ Boolean(0), uninit }, - "d" := struct{ "key" := "value" } - }; - var json := PackJSON(expr); - var obj := UnpackJSON(json); - print(TypeOfInt(obj) == OT_STRUCT); - print(obj.size() == 4); - print(obj.a == "hello there"); - print(obj.b == Boolean(1)); - print(obj.c[1] == Boolean(0)); - print(obj.c[2] == uninit); - print(obj.c.size() == 2); - print(TypeOfInt(obj.d) == OT_STRUCT); - print(obj.d.size() == 1); - print(obj.d.key == "value"); - print(PackJSON(expr, 1) != json); -endprogram \ No newline at end of file + var expr := struct{ "a" := "hello there", + "b" := Boolean( 1 ), + "c" := array{ Boolean( 0 ), uninit }, + "d" := struct{ "key" := "value" } }; + var json := PackJSON( expr ); + var obj := UnpackJSON( json ); + print( TypeOfInt( obj ) == OT_STRUCT ); + print( obj.size() == 4 ); + print( obj.a == "hello there" ); + print( obj.b == Boolean( 1 ) ); + print( obj.c[1] == Boolean( 0 ) ); + print( obj.c[2] == uninit ); + print( obj.c.size() == 2 ); + print( TypeOfInt( obj.d ) == OT_STRUCT ); + print( obj.d.size() == 1 ); + print( obj.d.key == "value" ); + print( PackJSON( expr, 1 ) != json ); +endprogram diff --git a/testsuite/escript/math/math0001.src b/testsuite/escript/math/math0001.src index 9c15ba182..572da2a18 100644 --- a/testsuite/escript/math/math0001.src +++ b/testsuite/escript/math/math0001.src @@ -2,4 +2,3 @@ use math; print( "PI is " + ConstPi() ); print( "e is " + ConstE() ); - diff --git a/testsuite/escript/math/math0002.src b/testsuite/escript/math/math0002.src index bed7fb7ff..ea3be8f3e 100644 --- a/testsuite/escript/math/math0002.src +++ b/testsuite/escript/math/math0002.src @@ -4,4 +4,3 @@ var x := ConstPi(); x := x / 10000000.0; print( "x is " + x ); - diff --git a/testsuite/escript/math/math0003.src b/testsuite/escript/math/math0003.src index 194d64da3..fd5ec530b 100644 --- a/testsuite/escript/math/math0003.src +++ b/testsuite/escript/math/math0003.src @@ -3,7 +3,7 @@ use math; var x := ConstPi(); x := x / 10000000.0; -print( "x is " + FormatRealToString(x,40) ); +print( "x is " + FormatRealToString( x, 40 ) ); print( "raw" ); print( 5.0 ); @@ -16,4 +16,3 @@ print( FormatRealToString( 5.0, 40 ) ); print( FormatRealToString( 0.5, 40 ) ); print( FormatRealToString( 0.00005, 40 ) ); print( FormatRealToString( 1, 40 ) ); - diff --git a/testsuite/escript/math/math0004.src b/testsuite/escript/math/math0004.src index aa717f4ca..35b83c5fa 100644 --- a/testsuite/escript/math/math0004.src +++ b/testsuite/escript/math/math0004.src @@ -5,7 +5,7 @@ var y := 2.0; compareTest( x, y ); -compareTest( 1, 2 ); -compareTest( 1, 2.0 ); +compareTest( 1, 2 ); +compareTest( 1, 2.0 ); compareTest( 1.0, 2.0 ); compareTest( 1.0, 2 ); diff --git a/testsuite/escript/math/math0005.src b/testsuite/escript/math/math0005.src index 1c98239b4..7044dbcb4 100644 --- a/testsuite/escript/math/math0005.src +++ b/testsuite/escript/math/math0005.src @@ -1,4 +1,4 @@ var x := 1; var y := 2.0; -print( "x <= y?" + (x<=y) ); +print( "x <= y?" + ( x <= y ) ); diff --git a/testsuite/escript/math/relops.inc b/testsuite/escript/math/relops.inc index 161724cc5..f784538fb 100644 --- a/testsuite/escript/math/relops.inc +++ b/testsuite/escript/math/relops.inc @@ -1,26 +1,26 @@ function Text( b ) - if (b) - return "true"; - else - return "false"; - endif + if ( b ) + return "true"; + else + return "false"; + endif endfunction function compareTest( x, y ) - print( "compare: x=" + x + ", y=" + y ); + print( "compare: x=" + x + ", y=" + y ); - print( "y <= x? " + Text( y <= x ) ); - print( "y < x? " + Text( y < x ) ); - print( "y >= x? " + Text( y >= x ) ); - print( "y > x? " + Text( y > x ) ); - print( "y == x? " + Text( y == x ) ); - print( "y != x? " + Text( y != x ) ); + print( "y <= x? " + Text( y <= x ) ); + print( "y < x? " + Text( y < x ) ); + print( "y >= x? " + Text( y >= x ) ); + print( "y > x? " + Text( y > x ) ); + print( "y == x? " + Text( y == x ) ); + print( "y != x? " + Text( y != x ) ); - print( "x <= y? " + Text( x <= y ) ); - print( "x < y? " + Text( x < y ) ); - print( "x >= y? " + Text( x >= y ) ); - print( "x > y? " + Text( x > y ) ); - print( "x == y? " + Text( x == y ) ); - print( "x != y? " + Text( x != y ) ); + print( "x <= y? " + Text( x <= y ) ); + print( "x < y? " + Text( x < y ) ); + print( "x >= y? " + Text( x >= y ) ); + print( "x > y? " + Text( x > y ) ); + print( "x == y? " + Text( x == y ) ); + print( "x != y? " + Text( x != y ) ); endfunction diff --git a/testsuite/escript/method/meth001.src b/testsuite/escript/method/meth001.src index 339550be4..6dd4748cf 100644 --- a/testsuite/escript/method/meth001.src +++ b/testsuite/escript/method/meth001.src @@ -1,10 +1,10 @@ -function foo(b) - print(b); +function foo( b ) + print( b ); endfunction var a; a.print( "hi there" ); -a.foo("hi again"); +a.foo( "hi again" ); print( "meth001" ); -// really the instructions are being tested here.. \ No newline at end of file +// really the instructions are being tested here.. diff --git a/testsuite/escript/method/method01.src b/testsuite/escript/method/method01.src index 90fd675bc..ef28497ea 100644 --- a/testsuite/escript/method/method01.src +++ b/testsuite/escript/method/method01.src @@ -1,4 +1,4 @@ var a; var res := a.foo( 57 ); -print (res.errortext); +print( res.errortext ); diff --git a/testsuite/escript/method/setmember.src b/testsuite/escript/method/setmember.src index 88b6395fe..c07886cff 100644 --- a/testsuite/escript/method/setmember.src +++ b/testsuite/escript/method/setmember.src @@ -1,64 +1,64 @@ // used member name to test ins_set_member_id_consume -var d:=dictionary{}; -var s:=struct{resist_fire_mod}; -var i:=4; -d.resist_fire_mod:=0; -s.resist_fire_mod:=0; -d.resist_fire_mod+=i; -s.resist_fire_mod+=i; -i-=2; -print(d); -print(s); -print(i); -s.resist_fire_mod-=1; -d.resist_fire_mod-=1; -print(d); -print(s); -s.resist_fire_mod*=i; -d.resist_fire_mod*=i; -print(d); -print(s); -s.resist_fire_mod%=4; -d.resist_fire_mod%=4; -print(d); -print(s); +var d := dictionary{}; +var s := struct{ resist_fire_mod }; +var i := 4; +d.resist_fire_mod := 0; +s.resist_fire_mod := 0; +d.resist_fire_mod += i; +s.resist_fire_mod += i; +i -= 2; +print( d ); +print( s ); +print( i ); +s.resist_fire_mod -= 1; +d.resist_fire_mod -= 1; +print( d ); +print( s ); +s.resist_fire_mod *= i; +d.resist_fire_mod *= i; +print( d ); +print( s ); +s.resist_fire_mod %= 4; +d.resist_fire_mod %= 4; +print( d ); +print( s ); // same test with diff member name -d:=dictionary{}; -s:=struct{blubb}; -i:=4; -d.blubb:=0; -s.blubb:=0; -d.blubb+=i; -s.blubb+=i; -i-=2; -print(d); -print(s); -print(i); -s.blubb-=1; -d.blubb-=1; -print(d); -print(s); -s.blubb*=i; -d.blubb*=i; -print(d); -print(s); -s.blubb%=4; -d.blubb%=4; -print(d); -print(s); +d := dictionary{}; +s := struct{ blubb }; +i := 4; +d.blubb := 0; +s.blubb := 0; +d.blubb += i; +s.blubb += i; +i -= 2; +print( d ); +print( s ); +print( i ); +s.blubb -= 1; +d.blubb -= 1; +print( d ); +print( s ); +s.blubb *= i; +d.blubb *= i; +print( d ); +print( s ); +s.blubb %= 4; +d.blubb %= 4; +print( d ); +print( s ); -//should not work -d:=dictionary{}; -s:=struct{blubb}; -d.blubb+=1; -s.blubb+=1; -print(s); -print(d); +// should not work +d := dictionary{}; +s := struct{ blubb }; +d.blubb += 1; +s.blubb += 1; +print( s ); +print( d ); -d:=dictionary{}; -s:=struct{resist_fire_mod}; -d.resist_fire_mod+=1; -s.resist_fire_mod+=1; -print(s); -print(d); +d := dictionary{}; +s := struct{ resist_fire_mod }; +d.resist_fire_mod += 1; +s.resist_fire_mod += 1; +print( s ); +print( d ); diff --git a/testsuite/escript/misc/assign.src b/testsuite/escript/misc/assign.src index bcb47aedc..e3079c375 100644 --- a/testsuite/escript/misc/assign.src +++ b/testsuite/escript/misc/assign.src @@ -3,17 +3,17 @@ use basic; var a; A := 5; -print( "A="+A); +print( "A=" + A ); - // A should not change here. - // NOTE, a compiler warning should be generated. +// A should not change here. +// NOTE, a compiler warning should be generated. A == "HELLO"; -print( "A="+A); +print( "A=" + A ); A := A + 654; -print( "A="+A); +print( "A=" + A ); -var b:=A; -A+=1; // b should not change -print(a); -print(b); +var b := A; +A += 1; // b should not change +print( a ); +print( b ); diff --git a/testsuite/escript/misc/block001.src b/testsuite/escript/misc/block001.src index 5ff3ba3f9..f16f60482 100644 --- a/testsuite/escript/misc/block001.src +++ b/testsuite/escript/misc/block001.src @@ -1,17 +1,17 @@ program test() - var a; - repeat - var b; - if (1) - var c; - var d; - break; // should leave block(3) and jump past 'until' - var e,f,g; - // here will leave block(5) - endif - var h; // should leave block(2) - until (0); - var g; + var a; + repeat + var b; + if ( 1 ) + var c; + var d; + break; // should leave block(3) and jump past 'until' + var e, f, g; + // here will leave block(5) + endif + var h; // should leave block(2) + until ( 0 ); + var g; - print("ok"); + print( "ok" ); endprogram diff --git a/testsuite/escript/misc/casesensitivity.err b/testsuite/escript/misc/casesensitivity.err index e47164b87..ed1f40dc1 100644 --- a/testsuite/escript/misc/casesensitivity.err +++ b/testsuite/escript/misc/casesensitivity.err @@ -1 +1 @@ -Unable to include file \ No newline at end of file +:2:1: error: Unable to include file 'caseSensitivity': failed to locate. \ No newline at end of file diff --git a/testsuite/escript/misc/casesensitivity.inc b/testsuite/escript/misc/casesensitivity.inc index 8b1378917..e69de29bb 100644 --- a/testsuite/escript/misc/casesensitivity.inc +++ b/testsuite/escript/misc/casesensitivity.inc @@ -1 +0,0 @@ - diff --git a/testsuite/escript/misc/cint001.src b/testsuite/escript/misc/cint001.src index 02329848e..8dee4de63 100644 --- a/testsuite/escript/misc/cint001.src +++ b/testsuite/escript/misc/cint001.src @@ -1,4 +1,4 @@ var a := "12345678"; -print( CInt(a) ); -print( Cint(a[2,3]) ); \ No newline at end of file +print( CInt( a ) ); +print( Cint( a[2, 3] ) ); diff --git a/testsuite/escript/misc/comp001.err b/testsuite/escript/misc/comp001.err index 6cb285cb5..8b2bd3c0e 100644 --- a/testsuite/escript/misc/comp001.err +++ b/testsuite/escript/misc/comp001.err @@ -1 +1 @@ -comp001.src:5:41: error: missing ']' at ')' \ No newline at end of file +:5:41: error: missing ']' at ')' \ No newline at end of file diff --git a/testsuite/escript/misc/comp002.src b/testsuite/escript/misc/comp002.src index ce4aaed7d..7737ce7cf 100644 --- a/testsuite/escript/misc/comp002.src +++ b/testsuite/escript/misc/comp002.src @@ -1,7 +1,7 @@ function foo() - var a; - print("ok"); + var a; + print( "ok" ); endfunction foo(); -foo(); \ No newline at end of file +foo(); diff --git a/testsuite/escript/misc/convert.src b/testsuite/escript/misc/convert.src index 88f8800da..08f99fadf 100644 --- a/testsuite/escript/misc/convert.src +++ b/testsuite/escript/misc/convert.src @@ -1,10 +1,9 @@ -print( 5 + 7); -print( CStr(5)+7); -print( 5+CStr(7)); -print( CStr(5)+CStr(7)); - -print( "5" + "7"); -print( CInt("5") + "7"); -print( "5" + CInt(7)); -print( CInt("5") + CInt("7")); +print( 5 + 7 ); +print( CStr( 5 ) + 7 ); +print( 5 + CStr( 7 ) ); +print( CStr( 5 ) + CStr( 7 ) ); +print( "5" + "7" ); +print( CInt( "5" ) + "7" ); +print( "5" + CInt( 7 ) ); +print( CInt( "5" ) + CInt( "7" ) ); diff --git a/testsuite/escript/misc/cvt001.src b/testsuite/escript/misc/cvt001.src index 5df66137b..9015e7921 100644 --- a/testsuite/escript/misc/cvt001.src +++ b/testsuite/escript/misc/cvt001.src @@ -1,7 +1,7 @@ var a := "abc"; var b := ""; -print( CAsc(a) ); +print( CAsc( a ) ); print( CAsc( a[0] ) ); print( CAsc( a[1] ) ); print( CAsc( a[2] ) ); @@ -10,6 +10,6 @@ print( CChr( 0x41 ) ); print( CChr( 0xed ) ); print( CAsc( CChr( 0xef ) ) ); -print( CAsc(b) ); +print( CAsc( b ) ); print( CAscZ( "hello" ) ); print( CChrZ( { 0x41, 0x42, 0x43, 0x44 } ) ); diff --git a/testsuite/escript/misc/do0.src b/testsuite/escript/misc/do0.src index b0ad9a0ce..a26e6afbc 100644 --- a/testsuite/escript/misc/do0.src +++ b/testsuite/escript/misc/do0.src @@ -3,8 +3,8 @@ var i; i := 0; do - print(i); - i := i + 1; -dowhile (i < 10); + print( i ); + i := i + 1; +dowhile ( i < 10 ); -print("done"); +print( "done" ); diff --git a/testsuite/escript/misc/double01.src b/testsuite/escript/misc/double01.src index 0e2659fa5..654a4ca97 100644 --- a/testsuite/escript/misc/double01.src +++ b/testsuite/escript/misc/double01.src @@ -2,7 +2,7 @@ use math; program MathTest() -var result := CInt((64.1+0.1)*10.0); -Print("Result of CInt((64.1+0.1)*10.0) = "+result); + var result := CInt( ( 64.1 + 0.1 ) * 10.0 ); + Print( "Result of CInt((64.1+0.1)*10.0) = " + result ); -endprogram \ No newline at end of file +endprogram diff --git a/testsuite/escript/misc/double02.src b/testsuite/escript/misc/double02.src index a20b06b31..93c8a2d4b 100644 --- a/testsuite/escript/misc/double02.src +++ b/testsuite/escript/misc/double02.src @@ -2,17 +2,17 @@ use math; program MathTest() -var result := CInt((64.1+0.1)*10.0); -Print("Result of CInt((64.1+0.1)*10.0) = "+result); + var result := CInt( ( 64.1 + 0.1 ) * 10.0 ); + Print( "Result of CInt((64.1+0.1)*10.0) = " + result ); -var val := 64.1; -print( "val(64.1)=" + val ); -val := val + 0.1; -print( "val(64.2)=" + val ); -val := val * 10; -print( "val(642)=" + val ); + var val := 64.1; + print( "val(64.1)=" + val ); + val := val + 0.1; + print( "val(64.2)=" + val ); + val := val * 10; + print( "val(642)=" + val ); -val := CInt( val ); -print( "val(642)=" + val ); + val := CInt( val ); + print( "val(642)=" + val ); -endprogram \ No newline at end of file +endprogram diff --git a/testsuite/escript/misc/dt.src b/testsuite/escript/misc/dt.src index 68b0f5a67..81f1d4e96 100644 --- a/testsuite/escript/misc/dt.src +++ b/testsuite/escript/misc/dt.src @@ -6,4 +6,4 @@ dt1b(); dt2b(); dt2a(); -print("ok"); +print( "ok" ); diff --git a/testsuite/escript/misc/dt1.inc b/testsuite/escript/misc/dt1.inc index efd66e0be..7944c9d26 100644 --- a/testsuite/escript/misc/dt1.inc +++ b/testsuite/escript/misc/dt1.inc @@ -1,13 +1,12 @@ - function dt1a() - var x; - x := 1; - return x; + var x; + x := 1; + return x; endfunction function dt1b() - var y; - y := 1; - return y; + var y; + y := 1; + return y; endfunction diff --git a/testsuite/escript/misc/dt2.inc b/testsuite/escript/misc/dt2.inc index f1496648b..2deb0324f 100644 --- a/testsuite/escript/misc/dt2.inc +++ b/testsuite/escript/misc/dt2.inc @@ -1,14 +1,12 @@ - - function dt2b() - var c; - c := 1; - return c; + var c; + c := 1; + return c; endfunction function dt2a() - var d; - d := 1; - return d; + var d; + d := 1; + return d; endfunction diff --git a/testsuite/escript/misc/dta.src b/testsuite/escript/misc/dta.src index a5ed8b8be..325074901 100644 --- a/testsuite/escript/misc/dta.src +++ b/testsuite/escript/misc/dta.src @@ -6,4 +6,4 @@ x := 3; x := 4; x := 5; -print(x); +print( x ); diff --git a/testsuite/escript/misc/error01.src b/testsuite/escript/misc/error01.src index 4f0220309..83f8d1465 100644 --- a/testsuite/escript/misc/error01.src +++ b/testsuite/escript/misc/error01.src @@ -1,8 +1,8 @@ var i := ""; -if (i == error) - print( "error!" ); +if ( i == error ) + print( "error!" ); else - print( "success!" ); + print( "success!" ); endif diff --git a/testsuite/escript/misc/export01.src b/testsuite/escript/misc/export01.src index 9ba5cc7e0..45c72732c 100644 --- a/testsuite/escript/misc/export01.src +++ b/testsuite/escript/misc/export01.src @@ -1,7 +1,7 @@ -exported function foo(a,b) - print( a + b ); - return a+b; +exported function foo( a, b ) + print( a + b ); + return a + b; endfunction -foo(3,2); -foo("a","cd"); \ No newline at end of file +foo( 3, 2 ); +foo( "a", "cd" ); diff --git a/testsuite/escript/misc/fcall001.err b/testsuite/escript/misc/fcall001.err index becc9fd1d..8ba1ab8cb 100644 --- a/testsuite/escript/misc/fcall001.err +++ b/testsuite/escript/misc/fcall001.err @@ -1 +1 @@ -fcall001.src:2:8: error: In call to 'find': Parameter 'Search' was not passed, and there is no default. \ No newline at end of file +:2:8: error: In call to 'find': Parameter 'Search' was not passed, and there is no default. \ No newline at end of file diff --git a/testsuite/escript/misc/fcall001.src b/testsuite/escript/misc/fcall001.src index 7beb844a1..62aa7f1f2 100644 --- a/testsuite/escript/misc/fcall001.src +++ b/testsuite/escript/misc/fcall001.src @@ -1,2 +1,2 @@ -print( find( "hello" )); +print( find( "hello" ) ); diff --git a/testsuite/escript/misc/float001.src b/testsuite/escript/misc/float001.src index 3e46486a8..5f3df8327 100644 --- a/testsuite/escript/misc/float001.src +++ b/testsuite/escript/misc/float001.src @@ -1,13 +1,13 @@ -var theitem := struct { quality }; +var theitem := struct{ quality }; - theitem.quality := 1.4; +theitem.quality := 1.4; - if (theitem.quality < 1.4) - print ("Quality is < 1.4"); - endif - if (theitem.quality == 1.4) - print ("Quality is == 1.4"); - endif - if (theitem.quality > 1.4) - print ("Quality is > 1.4"); - endif +if ( theitem.quality < 1.4 ) + print( "Quality is < 1.4" ); +endif +if ( theitem.quality == 1.4 ) + print( "Quality is == 1.4" ); +endif +if ( theitem.quality > 1.4 ) + print( "Quality is > 1.4" ); +endif diff --git a/testsuite/escript/misc/glob001.src b/testsuite/escript/misc/glob001.src index 2deb141b4..e81e1b32f 100644 --- a/testsuite/escript/misc/glob001.src +++ b/testsuite/escript/misc/glob001.src @@ -5,6 +5,6 @@ foo(); var b; function foo() - print(b); - b := 5; + print( b ); + b := 5; endfunction diff --git a/testsuite/escript/misc/globloc.src b/testsuite/escript/misc/globloc.src index bf3422820..856329be1 100644 --- a/testsuite/escript/misc/globloc.src +++ b/testsuite/escript/misc/globloc.src @@ -1,9 +1,9 @@ var x := 1; -print(x); +print( x ); -if (1) - var x := 2; - print(x); +if ( 1 ) + var x := 2; + print( x ); endif -print(x); +print( x ); diff --git a/testsuite/escript/misc/hello.src b/testsuite/escript/misc/hello.src index 69e09ec18..a9db16303 100644 --- a/testsuite/escript/misc/hello.src +++ b/testsuite/escript/misc/hello.src @@ -1 +1 @@ -print("hello, world"); +print( "hello, world" ); diff --git a/testsuite/escript/misc/hello2.src b/testsuite/escript/misc/hello2.src index 2b944d4f5..d2419c67b 100644 --- a/testsuite/escript/misc/hello2.src +++ b/testsuite/escript/misc/hello2.src @@ -4,4 +4,4 @@ print( "world" ); print( "xworld" ); print( "hello world" ); print( "hello world again" ); -print( "hello world" ); \ No newline at end of file +print( "hello world" ); diff --git a/testsuite/escript/misc/long001.src b/testsuite/escript/misc/long001.src index 89c54463c..243b74d42 100644 --- a/testsuite/escript/misc/long001.src +++ b/testsuite/escript/misc/long001.src @@ -1,9 +1,9 @@ -print( 2+3); -print( 100+3000); -print( -47 + 47); -print( -47 + 90); -print( 100-50); -print( 100-20); -print( 34 * 42); -print( 12 / 2); -print( 11 / 2); +print( 2 + 3 ); +print( 100 + 3000 ); +print( -47 + 47 ); +print( -47 + 90 ); +print( 100 - 50 ); +print( 100 - 20 ); +print( 34 * 42 ); +print( 12 / 2 ); +print( 11 / 2 ); diff --git a/testsuite/escript/misc/lst001.src b/testsuite/escript/misc/lst001.src index 573fd8565..925f22b9d 100644 --- a/testsuite/escript/misc/lst001.src +++ b/testsuite/escript/misc/lst001.src @@ -1,3 +1,3 @@ print( "hello" ); -print(len( "hello" )); -//left( "hello", 3 ); +print( len( "hello" ) ); +// left( "hello", 3 ); diff --git a/testsuite/escript/misc/lst002.src b/testsuite/escript/misc/lst002.src index 174d97e92..8059674c1 100644 --- a/testsuite/escript/misc/lst002.src +++ b/testsuite/escript/misc/lst002.src @@ -1,4 +1,4 @@ print( "hello" ); -var a,b; -b := len(a); -print(b); +var a, b; +b := len( a ); +print( b ); diff --git a/testsuite/escript/misc/lst003.src b/testsuite/escript/misc/lst003.src index 6fe4ddd24..1d8674dcb 100644 --- a/testsuite/escript/misc/lst003.src +++ b/testsuite/escript/misc/lst003.src @@ -1,15 +1,14 @@ print( "hello" ); -var a,b; -b := len(a); - +var a, b; +b := len( a ); program prog( parama ) - var x := foo(); - x := "hello"; - print(x); + var x := foo(); + x := "hello"; + print( x ); endprogram function foo() - var a := 5; - a := 7; -endfunction \ No newline at end of file + var a := 5; + a := 7; +endfunction diff --git a/testsuite/escript/misc/not.src b/testsuite/escript/misc/not.src index 6520d26e5..b685c1f10 100644 --- a/testsuite/escript/misc/not.src +++ b/testsuite/escript/misc/not.src @@ -1,8 +1,7 @@ -if (not (5 < 3)) - print( "ok"); +if ( not ( 5 < 3 ) ) + print( "ok" ); endif -if (!(5<3)) - print( "ok"); +if ( !( 5 < 3 ) ) + print( "ok" ); endif - diff --git a/testsuite/escript/misc/numbers.src b/testsuite/escript/misc/numbers.src index bb7b25c93..b53b6cf93 100644 --- a/testsuite/escript/misc/numbers.src +++ b/testsuite/escript/misc/numbers.src @@ -4,67 +4,67 @@ var t; var n := 0; -function testPrint(num) - n += 1; - print(CStr(n) + "."); - print(TypeOf(t)); - print(t); +function testPrint( num ) + n += 1; + print( CStr( n ) + "." ); + print( TypeOf( t ) ); + print( t ); endfunction // Int t := 0; -testPrint(t); +testPrint( t ); t := -2147483647; -testPrint(t); +testPrint( t ); t := 2147483647; -testPrint(t); +testPrint( t ); t := 0xfF0123a; -testPrint(t); +testPrint( t ); t := 0Xaaaaaa0; -testPrint(t); +testPrint( t ); t := -0Xff; -testPrint(t); +testPrint( t ); t := 000000; -testPrint(t); +testPrint( t ); t := 0000067; -testPrint(t); +testPrint( t ); t := 0755; -testPrint(t); +testPrint( t ); // Dbl t := 0.0; -testPrint(t); +testPrint( t ); t := -2147483648.123456; -testPrint(t); +testPrint( t ); t := 2147483647.123456; -testPrint(t); +testPrint( t ); t := 077.77; -testPrint(t); +testPrint( t ); t := 1.000000000000000000000000000000001; -testPrint(t); +testPrint( t ); t := 2e9; -testPrint(t); +testPrint( t ); t := 2E9; -testPrint(t); +testPrint( t ); t := 0x10.1p0; -testPrint(t); +testPrint( t ); t := 0xbadc0f.feep2; -testPrint(t); +testPrint( t ); diff --git a/testsuite/escript/misc/rpterr.err b/testsuite/escript/misc/rpterr.err index 8b1f37c97..21d6102d0 100644 --- a/testsuite/escript/misc/rpterr.err +++ b/testsuite/escript/misc/rpterr.err @@ -1 +1 @@ -rpterr.src:6:5: error: Unknown identifier 'foox'. \ No newline at end of file +:5:3: error: Unknown identifier 'foox'. \ No newline at end of file diff --git a/testsuite/escript/misc/rpterr.src b/testsuite/escript/misc/rpterr.src index 364e1c71e..dbb199ddd 100644 --- a/testsuite/escript/misc/rpterr.src +++ b/testsuite/escript/misc/rpterr.src @@ -1,7 +1,6 @@ - print( "hello world" ); repeat - foox; + foox; until i < 5; diff --git a/testsuite/escript/misc/ts.src b/testsuite/escript/misc/ts.src index 9cb881d65..3bff8ae5e 100644 --- a/testsuite/escript/misc/ts.src +++ b/testsuite/escript/misc/ts.src @@ -1,11 +1,10 @@ var v; -print("Testing arithmetic operators."); -print(5+7); -print(7-5); -print(7*5); -print(7/5); -print(7+"hello"); -v := 7+"hello" - "7h"; -print(v); - +print( "Testing arithmetic operators." ); +print( 5 + 7 ); +print( 7 - 5 ); +print( 7 * 5 ); +print( 7 / 5 ); +print( 7 + "hello" ); +v := 7 + "hello" - "7h"; +print( v ); diff --git a/testsuite/escript/narray/narray1.src b/testsuite/escript/narray/narray1.src index bd04ed50c..fcc894eb9 100644 --- a/testsuite/escript/narray/narray1.src +++ b/testsuite/escript/narray/narray1.src @@ -5,4 +5,3 @@ a[4] := "world"; print( a[1] ); print( a[4] ); - diff --git a/testsuite/escript/narray/narray10.src b/testsuite/escript/narray/narray10.src index fef0ff398..be02438cc 100644 --- a/testsuite/escript/narray/narray10.src +++ b/testsuite/escript/narray/narray10.src @@ -1,23 +1,23 @@ program test() - var a := { 1,12,3,32,57 }; - - foreach i in a - print( i ); - endforeach + var a := { 1, 12, 3, 32, 57 }; - print( "deleting 3rd element" ); - a.erase( 3 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + foreach i in a + print( i ); + endforeach - print( "deleting 4th element" ); - a.erase( 4 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "deleting 3rd element" ); + a.erase( 3 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); + + print( "deleting 4th element" ); + a.erase( 4 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); endprogram /**** Expected Output Begins: ***** diff --git a/testsuite/escript/narray/narray11.src b/testsuite/escript/narray/narray11.src index fc9d537a5..8196e6ca1 100644 --- a/testsuite/escript/narray/narray11.src +++ b/testsuite/escript/narray/narray11.src @@ -1,46 +1,46 @@ program test() - var a := { 1,12,3,32,57 }; - - print( "initial" ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + var a := { 1, 12, 3, 32, 57 }; - print( "shrink(17)" ); - a.shrink( 17 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "initial" ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); - print( "shrink(6)" ); - a.shrink( 6 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "shrink(17)" ); + a.shrink( 17 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); - print( "shrink(5)" ); - a.shrink( 5 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "shrink(6)" ); + a.shrink( 6 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); - print( "shrink(3)" ); - a.shrink( 3 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "shrink(5)" ); + a.shrink( 5 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); - print( "shrink(0)" ); - a.shrink( 0 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "shrink(3)" ); + a.shrink( 3 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); + + print( "shrink(0)" ); + a.shrink( 0 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); endprogram /**** Expected Output Begins: ***** diff --git a/testsuite/escript/narray/narray12.src b/testsuite/escript/narray/narray12.src index 81b563ea5..96124bfd7 100644 --- a/testsuite/escript/narray/narray12.src +++ b/testsuite/escript/narray/narray12.src @@ -1,27 +1,27 @@ program test() - var a := { 1,12,3,32,57 }; - - print( "initial" ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + var a := { 1, 12, 3, 32, 57 }; - print( "insert(3,5)" ); - a.insert( 3,5 ); - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "initial" ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); - var b := 6; - print( "insert(2,b)" ); - a.insert( 2, b ); - b := 2; - foreach i in a - print( i ); - endforeach - print( "size: " + a.size() ); + print( "insert(3,5)" ); + a.insert( 3, 5 ); + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); + + var b := 6; + print( "insert(2,b)" ); + a.insert( 2, b ); + b := 2; + foreach i in a + print( i ); + endforeach + print( "size: " + a.size() ); endprogram diff --git a/testsuite/escript/narray/narray13.src b/testsuite/escript/narray/narray13.src index ff5820d99..794773f19 100644 --- a/testsuite/escript/narray/narray13.src +++ b/testsuite/escript/narray/narray13.src @@ -1,10 +1,10 @@ program test() - - var b := {}; - print( b ); - b.insert( 1, "hello" ); - print( b ); + var b := {}; + print( b ); + + b.insert( 1, "hello" ); + print( b ); endprogram diff --git a/testsuite/escript/narray/narray14.src b/testsuite/escript/narray/narray14.src index c41286c5e..71cc60c66 100644 --- a/testsuite/escript/narray/narray14.src +++ b/testsuite/escript/narray/narray14.src @@ -1,9 +1,9 @@ program test() - - var b := { 1, 4, 6, 3, 7, 12, 72, 3 }; - print( b ); - b.reverse(); - print( b ); + + var b := { 1, 4, 6, 3, 7, 12, 72, 3 }; + print( b ); + b.reverse(); + print( b ); endprogram diff --git a/testsuite/escript/narray/narray15.src b/testsuite/escript/narray/narray15.src index 9fb539513..702b77728 100644 --- a/testsuite/escript/narray/narray15.src +++ b/testsuite/escript/narray/narray15.src @@ -1,12 +1,12 @@ program test() - - var b := {}; - print( b ); - b.append( "hello" ); - print( b ); - b.append( "goodbye" ); - print( b ); + var b := {}; + print( b ); + + b.append( "hello" ); + print( b ); + b.append( "goodbye" ); + print( b ); endprogram diff --git a/testsuite/escript/narray/narray16.src b/testsuite/escript/narray/narray16.src index ec7017f96..4d7efe39c 100644 --- a/testsuite/escript/narray/narray16.src +++ b/testsuite/escript/narray/narray16.src @@ -1,9 +1,9 @@ program test() - - var b := { 1, 4, 6, 3, 7, 12, 72, 3 }; - print( b ); - b.sort(); - print( b ); + + var b := { 1, 4, 6, 3, 7, 12, 72, 3 }; + print( b ); + b.sort(); + print( b ); endprogram diff --git a/testsuite/escript/narray/narray17.src b/testsuite/escript/narray/narray17.src index ecfeb4449..f530db111 100644 --- a/testsuite/escript/narray/narray17.src +++ b/testsuite/escript/narray/narray17.src @@ -1,19 +1,19 @@ program test() - - var b := { { 0, 0 } }; - print( b ); - b.insert( 1, { 21, 31 } ); - print( b ); - b.erase( 11 ); + var b := { { 0, 0 } }; + print( b ); - b.insert( 1, { 22, 32 } ); - print( b ); - b.erase( 11 ); + b.insert( 1, { 21, 31 } ); + print( b ); + b.erase( 11 ); - b.insert( 1, { 23, 33 } ); - print( b ); - b.erase( 11 ); + b.insert( 1, { 22, 32 } ); + print( b ); + b.erase( 11 ); + + b.insert( 1, { 23, 33 } ); + print( b ); + b.erase( 11 ); endprogram diff --git a/testsuite/escript/narray/narray18.src b/testsuite/escript/narray/narray18.src index de365549d..972d37278 100644 --- a/testsuite/escript/narray/narray18.src +++ b/testsuite/escript/narray/narray18.src @@ -1,16 +1,16 @@ program test() - - var b := { { 0, 0 } }; - print( b ); - b.insert( 1, { 21, 31 } ); - print( b ); + var b := { { 0, 0 } }; + print( b ); - b.insert( 1, { 22, 32 } ); - print( b ); + b.insert( 1, { 21, 31 } ); + print( b ); - b.insert( 1, { 23, 33 } ); - print( b ); + b.insert( 1, { 22, 32 } ); + print( b ); + + b.insert( 1, { 23, 33 } ); + print( b ); endprogram diff --git a/testsuite/escript/narray/narray2.src b/testsuite/escript/narray/narray2.src index 736f060fa..99e5e81c8 100644 --- a/testsuite/escript/narray/narray2.src +++ b/testsuite/escript/narray/narray2.src @@ -9,4 +9,3 @@ print( a[4] ); a[4] := "hey"; print( a[1] ); print( a[4] ); - diff --git a/testsuite/escript/narray/narray3.src b/testsuite/escript/narray/narray3.src index 630e00a38..ed1ceeffc 100644 --- a/testsuite/escript/narray/narray3.src +++ b/testsuite/escript/narray/narray3.src @@ -3,27 +3,27 @@ var a := {}; a[1] := "hello"; a[4] := "world"; -print( a[1]); -print( a[4]); +print( a[1] ); +print( a[4] ); a[4] := "hey"; -print( a[1]); -print( a[4]); +print( a[1] ); +print( a[4] ); var b; b := a; -print( "b created, initialized"); -print( a[1]); -print( a[4]); -print( b[1]); -print( b[4]); +print( "b created, initialized" ); +print( a[1] ); +print( a[4] ); +print( b[1] ); +print( b[4] ); a[1] := "changed a"; -print( "a modified"); -print( a[1]); -print( a[4]); -print( b[1]); -print( b[4]); +print( "a modified" ); +print( a[1] ); +print( a[4] ); +print( b[1] ); +print( b[4] ); diff --git a/testsuite/escript/narray/narray4.src b/testsuite/escript/narray/narray4.src index 753fce071..b240b86e0 100644 --- a/testsuite/escript/narray/narray4.src +++ b/testsuite/escript/narray/narray4.src @@ -1,10 +1,10 @@ var a := {}; a[1] := "hello"; -print( len(a)); +print( len( a ) ); a[4] := "world"; -print( len(a)); +print( len( a ) ); a[2] := "there"; -print( len(a)); \ No newline at end of file +print( len( a ) ); diff --git a/testsuite/escript/narray/narray5.src b/testsuite/escript/narray/narray5.src index 55eb6cf7b..36964ca54 100644 --- a/testsuite/escript/narray/narray5.src +++ b/testsuite/escript/narray/narray5.src @@ -1,11 +1,11 @@ program test() - var a := { }; + var a := {}; - a[1] := "hello"; - a[4] := "world"; + a[1] := "hello"; + a[4] := "world"; - print( a[1] ); - print( a[4] ); + print( a[1] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/narray/narray6.src b/testsuite/escript/narray/narray6.src index 55eb6cf7b..36964ca54 100644 --- a/testsuite/escript/narray/narray6.src +++ b/testsuite/escript/narray/narray6.src @@ -1,11 +1,11 @@ program test() - var a := { }; + var a := {}; - a[1] := "hello"; - a[4] := "world"; + a[1] := "hello"; + a[4] := "world"; - print( a[1] ); - print( a[4] ); + print( a[1] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/narray/narray7.src b/testsuite/escript/narray/narray7.src index f0ae3463f..a5d603c8a 100644 --- a/testsuite/escript/narray/narray7.src +++ b/testsuite/escript/narray/narray7.src @@ -1,12 +1,12 @@ program test() - var a := { 1 }; + var a := { 1 }; - a[2] := "hello"; - a[4] := "world"; + a[2] := "hello"; + a[4] := "world"; - print( a[1] ); - print( a[2] ); - print( a[4] ); + print( a[1] ); + print( a[2] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/narray/narray8.src b/testsuite/escript/narray/narray8.src index f48ff52eb..7a5830cb3 100644 --- a/testsuite/escript/narray/narray8.src +++ b/testsuite/escript/narray/narray8.src @@ -1,10 +1,10 @@ program test() - var a := { 1,5,8,12 }; + var a := { 1, 5, 8, 12 }; - print( a[1] ); - print( a[2] ); - print( a[3] ); - print( a[4] ); + print( a[1] ); + print( a[2] ); + print( a[3] ); + print( a[4] ); endprogram diff --git a/testsuite/escript/narray/narray9.src b/testsuite/escript/narray/narray9.src index 685262721..2f0772a63 100644 --- a/testsuite/escript/narray/narray9.src +++ b/testsuite/escript/narray/narray9.src @@ -1,7 +1,7 @@ program test() - foreach i in { 1,12,3,32,57 } - print( i ); - endforeach + foreach i in { 1, 12, 3, 32, 57 } + print( i ); + endforeach endprogram /**** Expected Output Begins: ***** diff --git a/testsuite/escript/oper-elvis/elvis005-chained-first.src b/testsuite/escript/oper-elvis/elvis005-chained-first.src index fa1f1055a..de4e9a2da 100644 --- a/testsuite/escript/oper-elvis/elvis005-chained-first.src +++ b/testsuite/escript/oper-elvis/elvis005-chained-first.src @@ -1,5 +1,6 @@ include "support"; +// format-off print( foo( "x" ) ?: bar( "y" ) // not called (short-circuit) diff --git a/testsuite/escript/oper-elvis/elvis006-chained-middle.src b/testsuite/escript/oper-elvis/elvis006-chained-middle.src index 267edbb72..2c06184aa 100644 --- a/testsuite/escript/oper-elvis/elvis006-chained-middle.src +++ b/testsuite/escript/oper-elvis/elvis006-chained-middle.src @@ -1,5 +1,6 @@ include "support"; +// format-off print( foo( 0 ) ?: bar( "y" ) diff --git a/testsuite/escript/oper-elvis/elvis007-chained-last.src b/testsuite/escript/oper-elvis/elvis007-chained-last.src index 7e94c7acc..66db200f4 100644 --- a/testsuite/escript/oper-elvis/elvis007-chained-last.src +++ b/testsuite/escript/oper-elvis/elvis007-chained-last.src @@ -1,6 +1,7 @@ include "support"; var nothing; +// format-off print( foo( 0 ) ?: bar( nothing ) diff --git a/testsuite/escript/oper-elvis/elvis011-precedence-vs-equality.src b/testsuite/escript/oper-elvis/elvis011-precedence-vs-equality.src index 6b39fb7d6..a42d5848e 100644 --- a/testsuite/escript/oper-elvis/elvis011-precedence-vs-equality.src +++ b/testsuite/escript/oper-elvis/elvis011-precedence-vs-equality.src @@ -4,6 +4,7 @@ var g := 0, h := 0; // The elvis operator should have higher precedence than equality operators +// format-off print( a == g ?: b ); // 1 correct: a == ( g ?: b ) 3 incorrect: ( a == g ) ?: b print( b ?: g == a ); // 1 correct: ( b ?: g ) == a 3 incorrect: b ?: ( g == a ) diff --git a/testsuite/escript/oper-elvis/elvis013-precedence-struct-member.src b/testsuite/escript/oper-elvis/elvis013-precedence-struct-member.src index c3a533e15..8857aeba8 100644 --- a/testsuite/escript/oper-elvis/elvis013-precedence-struct-member.src +++ b/testsuite/escript/oper-elvis/elvis013-precedence-struct-member.src @@ -1,5 +1,5 @@ -var a := struct { x := 4 }; -var b := struct { y := 6 }; +var a := struct{ x := 4 }; +var b := struct{ y := 6 }; -print ( a.x ?: b.y ); -print ( a.z ?: b.y ); +print( a.x ?: b.y ); +print( a.z ?: b.y ); diff --git a/testsuite/escript/oper-elvis/support.inc b/testsuite/escript/oper-elvis/support.inc index 153d4e8c6..a53ab27f9 100644 --- a/testsuite/escript/oper-elvis/support.inc +++ b/testsuite/escript/oper-elvis/support.inc @@ -1,14 +1,14 @@ -function foo(v) - print("call foo(" + v + ")"); - return v; +function foo( v ) + print( "call foo(" + v + ")" ); + return v; endfunction -function bar(v) - print("call bar(" + v + ")"); - return v; +function bar( v ) + print( "call bar(" + v + ")" ); + return v; endfunction -function baz(v) - print("call baz(" + v + ")"); - return v; +function baz( v ) + print( "call baz(" + v + ")" ); + return v; endfunction diff --git a/testsuite/escript/oper/minusminus01.src b/testsuite/escript/oper/minusminus01.src index 7b2a97814..945941add 100644 --- a/testsuite/escript/oper/minusminus01.src +++ b/testsuite/escript/oper/minusminus01.src @@ -1,49 +1,49 @@ -var i:=3; -while (--i>0) - print("while"); +var i := 3; +while ( --i > 0 ) + print( "while" ); endwhile -print(i); +print( i ); -for (i:=3;i>0;--i) - print("for"); +for ( i := 3; i > 0; --i ) + print( "for" ); endfor -print(i); -print(--i); +print( i ); +print( --i ); -i:=3; -function p(i) - print("in func after --"); - print(i); +i := 3; +function p( i ) + print( "in func after --" ); + print( i ); --i; endfunction -p(--i); -print("i after func call "+cstr(i)); +p( --i ); +print( "i after func call " + cstr( i ) ); -i:=3; -function pp(byref i) - print("in func after --"); - print(i); +i := 3; +function pp( byref i ) + print( "in func after --" ); + print( i ); --i; endfunction -pp(--i); -print("i after func call "+cstr(i)); +pp( --i ); +print( "i after func call " + cstr( i ) ); -var ii:=--i; -print(ii); -ii-=--i; -print(ii); -ii:=1-(--i); -print(ii); +var ii := --i; +print( ii ); +ii -= --i; +print( ii ); +ii := 1 - ( --i ); +print( ii ); -var d:=1.5; -print(--d); +var d := 1.5; +print( --d ); -const c:=1; +const c := 1; --c; -print("should not change {}".format(c)); -print("should change {}".format(--c)); +print( "should not change {}".format( c ) ); +print( "should change {}".format( --c ) ); -var e:={1}; -print(--e); +var e := { 1 }; +print( --e ); --e[1]; -print(e); +print( e ); diff --git a/testsuite/escript/oper/minusminus03.src b/testsuite/escript/oper/minusminus03.src index fc2d66954..4551f904e 100644 --- a/testsuite/escript/oper/minusminus03.src +++ b/testsuite/escript/oper/minusminus03.src @@ -1,46 +1,45 @@ -var i:=3; -while (i-->0) - print("while"); +var i := 3; +while ( i-- > 0 ) + print( "while" ); endwhile -print(i); +print( i ); -for (i:=3;i>0;i--) - print("for"); +for ( i := 3; i > 0; i-- ) + print( "for" ); endfor -print(i); -print(i--); +print( i ); +print( i-- ); -i:=1; -function p(i) - print("in func after --"); - print(i); +i := 1; +function p( i ) + print( "in func after --" ); + print( i ); i--; endfunction -p(i--); -print("i after func call "+cstr(i)); +p( i-- ); +print( "i after func call " + cstr( i ) ); -i:=1; -function pp(byref i) - print("in func after --"); - print(i); +i := 1; +function pp( byref i ) + print( "in func after --" ); + print( i ); i--; endfunction -pp(i--); // since its post dec, the original i isnt passed to the func -print("i after func call "+cstr(i)); // in contrast to --i pp() does not change outer scope i +pp( i-- ); // since its post dec, the original i isnt passed to the func +print( "i after func call " + cstr( i ) ); // in contrast to --i pp() does not change outer scope i -var ii:=i--; -print(ii); -ii-=i--; -print(ii); -ii:=1-(i--); -print(ii); +var ii := i--; +print( ii ); +ii -= i--; +print( ii ); +ii := 1 - ( i-- ); +print( ii ); -var d:=1.5; +var d := 1.5; d--; -print(d); +print( d ); -const c:=1; +const c := 1; c--; -print("should not change {}".format(c)); -print("should still not change {}".format(c--)); - +print( "should not change {}".format( c ) ); +print( "should still not change {}".format( c-- ) ); diff --git a/testsuite/escript/oper/minusminus05.src b/testsuite/escript/oper/minusminus05.src index 14b9f3768..932d6ad89 100644 --- a/testsuite/escript/oper/minusminus05.src +++ b/testsuite/escript/oper/minusminus05.src @@ -1,11 +1,10 @@ -var s:=struct{resist_fire_mod:=6}; // reserved name, converts to get_member_id -var i:=--s.resist_fire_mod; -print(i); -print(--i); // no ref -print(s); -print(i); -print(s.resist_fire_mod--); -print(--s.resist_fire_mod); +var s := struct{ resist_fire_mod := 6 }; // reserved name, converts to get_member_id +var i := --s.resist_fire_mod; +print( i ); +print( --i ); // no ref +print( s ); +print( i ); +print( s.resist_fire_mod-- ); +print( --s.resist_fire_mod ); --s.resist_fire_mod; -print(s); - +print( s ); diff --git a/testsuite/escript/oper/op001.src b/testsuite/escript/oper/op001.src index 47aece7a6..900300a80 100644 --- a/testsuite/escript/oper/op001.src +++ b/testsuite/escript/oper/op001.src @@ -1,14 +1,14 @@ var a; var b := 5; -if (a < b) - print( "a= s2: FAILED" ); + print( "s1 >= s2: FAILED" ); endif -if (s1[1] < s2) - print( "s1[1] < s2: OK" ); +if ( s1[1] < s2 ) + print( "s1[1] < s2: OK" ); else - print( "s1[1] < s2: FAILED" ); + print( "s1[1] < s2: FAILED" ); endif -if ("abcd" < "d") - print( "abcd < d: OK" ); +if ( "abcd" < "d" ) + print( "abcd < d: OK" ); else - print( "abcd < d: FAILED" ); + print( "abcd < d: FAILED" ); endif -if (s1 < s2[1]) - print( "s1 < s2[1]: OK" ); +if ( s1 < s2[1] ) + print( "s1 < s2[1]: OK" ); else - print( "s1 < s2[1]: FAILED" ); + print( "s1 < s2[1]: FAILED" ); endif - diff --git a/testsuite/escript/oper/oper003.src b/testsuite/escript/oper/oper003.src index b574198f0..bf3c94a37 100644 --- a/testsuite/escript/oper/oper003.src +++ b/testsuite/escript/oper/oper003.src @@ -1,6 +1,4 @@ - - var v := struct; v.+mem; @@ -13,6 +11,6 @@ print( d.exists( "c" ) ); v.mem := d; var a := v.mem.exists( "a" ); -print(a); +print( a ); a := v.mem.exists( "c" ); -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/oper/oper004.src b/testsuite/escript/oper/oper004.src index cdff33090..08f09bb5e 100644 --- a/testsuite/escript/oper/oper004.src +++ b/testsuite/escript/oper/oper004.src @@ -1,6 +1,4 @@ - - var v := struct; v.+mem; @@ -9,10 +7,10 @@ d[1] := 5; d[2] := 6; print( d[1] ); -print( d[2]); +print( d[2] ); v.mem := d; var a := v.mem[1]; -print(a); +print( a ); a := v.mem[2]; -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/oper/oper005.src b/testsuite/escript/oper/oper005.src index d906774f7..be8f9f3c7 100644 --- a/testsuite/escript/oper/oper005.src +++ b/testsuite/escript/oper/oper005.src @@ -1,3 +1,3 @@ var a, b, c; a := a + b.c.d + c; -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/oper/oper006.src b/testsuite/escript/oper/oper006.src index df88afc54..b8eab57cf 100644 --- a/testsuite/escript/oper/oper006.src +++ b/testsuite/escript/oper/oper006.src @@ -1,3 +1,3 @@ var a, b, c; -a := a + b.c.d.foo(4) + c; -print(a); \ No newline at end of file +a := a + b.c.d.foo( 4 ) + c; +print( a ); diff --git a/testsuite/escript/oper/oper007.src b/testsuite/escript/oper/oper007.src index 940ac4243..d87412802 100644 --- a/testsuite/escript/oper/oper007.src +++ b/testsuite/escript/oper/oper007.src @@ -1,71 +1,71 @@ // do crazy senseless stuff // nothing should crash program foo() - var a; - var test:={a,struct,dictionary,array,"",1,1.0}; + var a; + var test := { a, struct, dictionary, array, "", 1, 1.0 }; - foreach t1 in test - foreach t2 in test - print(!t1); - print(~t1); - print(-t1); - print(+t1); - print(t1*t2); - print(t2*t1); - print(t1/t2); - print(t2/t1); - print(t1+t2); - print(t2+t1); - print(t1-t2); - print(t2-t1); - print(t1%t2); - print(t2%t1); - print(t1&t2); - print(t2&t1); - print(t1^t2); - print(t2^t1); - print(t1|t2); - print(t2|t1); - print(t1>>t2); - print(t2>>t1); - print(t1<> t2 ); + print( t2 >> t1 ); + print( t1 << t2 ); + print( t2 << t1 ); + PlusEqual( t1, t2 ); + PlusEqual( t2, t1 ); + MinusEqual( t1, t2 ); + MinusEqual( t2, t1 ); + TimesEqual( t1, t2 ); + TimesEqual( t2, t1 ); + DivEqual( t1, t2 ); + DivEqual( t2, t1 ); + ModulusEqual( t1, t2 ); + ModulusEqual( t2, t1 ); + endforeach + endforeach endprogram -function PlusEqual(t1,t2) - var t:=t1; - t+=t2; - print(t); +function PlusEqual( t1, t2 ) + var t := t1; + t += t2; + print( t ); endfunction -function MinusEqual(t1,t2) - var t:=t1; - t-=t2; - print(t); +function MinusEqual( t1, t2 ) + var t := t1; + t -= t2; + print( t ); endfunction -function TimesEqual(t1,t2) - var t:=t1; - t*=t2; - print(t); +function TimesEqual( t1, t2 ) + var t := t1; + t *= t2; + print( t ); endfunction -function DivEqual(t1,t2) - var t:=t1; - t/=t2; - print(t); +function DivEqual( t1, t2 ) + var t := t1; + t /= t2; + print( t ); +endfunction +function ModulusEqual( t1, t2 ) + var t := t1; + t %= t2; + print( t ); endfunction -function ModulusEqual(t1,t2) - var t:=t1; - t%=t2; - print(t); -endfunction \ No newline at end of file diff --git a/testsuite/escript/oper/oper008.src b/testsuite/escript/oper/oper008.src index ff3c46846..30c4dcd64 100644 --- a/testsuite/escript/oper/oper008.src +++ b/testsuite/escript/oper/oper008.src @@ -4,7 +4,6 @@ // Tests comparison operators // All tests expected to be true - // Int and Double var i1 := 1; var d1 := 1.0; @@ -38,7 +37,7 @@ print( d2 >= d2 ); var sa := "aaaaaaaaaaaa"; var sb := "bbbbbbbbbbbb"; print( sa != sb ); -print( sa == StrReplace(sa,"b","a") ); +print( sa == StrReplace( sa, "b", "a" ) ); print( sa < sb ); print( sa <= sb ); print( sb > sa ); @@ -64,7 +63,7 @@ print( d1 >= un ); // Array var a1 := array{ 1, 2, 3 }; var a2 := array{ 2, 3, 4 }; -var a3 := array{ i1, i2, i2+1 }; +var a3 := array{ i1, i2, i2 + 1 }; print( a1 != a2 ); print( a1 == a3 ); diff --git a/testsuite/escript/oper/plusequal.src b/testsuite/escript/oper/plusequal.src index aa4fe9e6b..0eaa1c75d 100644 --- a/testsuite/escript/oper/plusequal.src +++ b/testsuite/escript/oper/plusequal.src @@ -1,10 +1,10 @@ -var arr:={1,2,3}; -var text:=""; +var arr := { 1, 2, 3 }; +var text := ""; foreach a in arr - text+=" "+a; + text += " " + a; endforeach -print(text); -text:=""; -text+=arr[1]; -print(text); \ No newline at end of file +print( text ); +text := ""; +text += arr[1]; +print( text ); diff --git a/testsuite/escript/oper/plusplus01.src b/testsuite/escript/oper/plusplus01.src index 67c81d4d1..b6506ba98 100644 --- a/testsuite/escript/oper/plusplus01.src +++ b/testsuite/escript/oper/plusplus01.src @@ -1,54 +1,54 @@ -var i:=1; -while (++i<3) - print("while"); +var i := 1; +while ( ++i < 3 ) + print( "while" ); endwhile -print(i); +print( i ); -for (i:=1;i<3;++i) - print("for"); +for ( i := 1; i < 3; ++i ) + print( "for" ); endfor -print(i); -print(++i); +print( i ); +print( ++i ); -i:=1; -function p(i) - print("in func after ++"); - print(i); +i := 1; +function p( i ) + print( "in func after ++" ); + print( i ); ++i; endfunction -p(++i); -print("i after func call "+cstr(i)); +p( ++i ); +print( "i after func call " + cstr( i ) ); -i:=1; -function pp(byref i) - print("in func after ++"); - print(i); +i := 1; +function pp( byref i ) + print( "in func after ++" ); + print( i ); ++i; endfunction -pp(++i); -print("i after func call "+cstr(i)); +pp( ++i ); +print( "i after func call " + cstr( i ) ); -var ii:=++i; -print(ii); -ii+=++i; -print(ii); -ii:=1+(++i); -print(ii); +var ii := ++i; +print( ii ); +ii += ++i; +print( ii ); +ii := 1 + ( ++i ); +print( ii ); -var j:=3; -i:=2; -var b:=i+ ++j; -print(b); +var j := 3; +i := 2; +var b := i + ++j; +print( b ); -var d:=1.5; -print(++d); +var d := 1.5; +print( ++d ); -const c:=1; +const c := 1; ++c; -print("should not change {}".format(c)); -print("should change {}".format(++c)); +print( "should not change {}".format( c ) ); +print( "should change {}".format( ++c ) ); -var e:={1}; -print(++e); +var e := { 1 }; +print( ++e ); ++e[1]; -print(e); +print( e ); diff --git a/testsuite/escript/oper/plusplus02.src b/testsuite/escript/oper/plusplus02.src index 60f88aff2..d58f6f998 100644 --- a/testsuite/escript/oper/plusplus02.src +++ b/testsuite/escript/oper/plusplus02.src @@ -1,27 +1,27 @@ -//some funny valid syntax features -//tokens do not consider spaces inbetween... -var a:=1; -var b:=2; -print(a+++b); -a:=1; -b:=2; -print((a++)+b); -a:=1; -b:=2; -print(a++ +b); -a:=1; -b:=2; -print(a+(++b)); -a:=1; -b:=2; -print(a+ ++b); +// some funny valid syntax features +// tokens do not consider spaces inbetween... +var a := 1; +var b := 2; +print( a++ + b ); +a := 1; +b := 2; +print( ( a++ ) + b ); +a := 1; +b := 2; +print( a++ + b ); +a := 1; +b := 2; +print( a + ( ++b ) ); +a := 1; +b := 2; +print( a + ++b ); -a:=1; +a := 1; // postfix operators are now highest precedence: ++a++; -print(a); -a:=1; +print( a ); +a := 1; // postfix operators are now highest precedence: ++a--; -print(a); -a:=1; -++(++a); -print(a); +print( a ); +a := 1; +++( ++a ); +print( a ); diff --git a/testsuite/escript/oper/plusplus03.src b/testsuite/escript/oper/plusplus03.src index df9705fd3..2e0cb47c0 100644 --- a/testsuite/escript/oper/plusplus03.src +++ b/testsuite/escript/oper/plusplus03.src @@ -1,51 +1,50 @@ -var i:=1; -while (i++<3) - print("while"); +var i := 1; +while ( i++ < 3 ) + print( "while" ); endwhile -print(i); +print( i ); -for (i:=1;i<3;i++) - print("for"); +for ( i := 1; i < 3; i++ ) + print( "for" ); endfor -print(i); -print(i++); +print( i ); +print( i++ ); -i:=1; -function p(i) - print("in func after ++"); - print(i); +i := 1; +function p( i ) + print( "in func after ++" ); + print( i ); i++; endfunction -p(i++); -print("i after func call "+cstr(i)); +p( i++ ); +print( "i after func call " + cstr( i ) ); -i:=1; -function pp(byref i) - print("in func after ++"); - print(i); +i := 1; +function pp( byref i ) + print( "in func after ++" ); + print( i ); i++; endfunction -pp(i++); // since its post inc, the original i isnt passed to the func -print("i after func call "+cstr(i)); // in contrast to ++i pp() does not change outer scope i +pp( i++ ); // since its post inc, the original i isnt passed to the func +print( "i after func call " + cstr( i ) ); // in contrast to ++i pp() does not change outer scope i -var ii:=i++; -print(ii); -ii+=i++; -print(ii); -ii:=1+(i++); -print(ii); +var ii := i++; +print( ii ); +ii += i++; +print( ii ); +ii := 1 + ( i++ ); +print( ii ); -var j:=3; -i:=2; -var b:=i+ j++; -print(b); +var j := 3; +i := 2; +var b := i + j++; +print( b ); -var d:=1.5; +var d := 1.5; d++; -print(d); +print( d ); -const c:=1; +const c := 1; c++; -print("should not change {}".format(c)); -print("should still not change {}".format(c++)); - +print( "should not change {}".format( c ) ); +print( "should still not change {}".format( c++ ) ); diff --git a/testsuite/escript/oper/plusplus04.src b/testsuite/escript/oper/plusplus04.src index 3314dd399..411cafb65 100644 --- a/testsuite/escript/oper/plusplus04.src +++ b/testsuite/escript/oper/plusplus04.src @@ -1,13 +1,13 @@ -var s:=struct{a:=0}; -print(s); +var s := struct{ a := 0 }; +print( s ); s.a++; -print(s); +print( s ); ++s.a; -print(s); -print(s.a++); -print(++s.a); +print( s ); +print( s.a++ ); +print( ++s.a ); -var s1:=struct{a:=s1.a++}; -print(s1); -var s2:=struct{a:=0++, b:=++1}; -print(s2); +var s1 := struct{ a := s1.a++ }; +print( s1 ); +var s2 := struct{ a := 0++, b := ++1 }; +print( s2 ); diff --git a/testsuite/escript/oper/plusplus05.src b/testsuite/escript/oper/plusplus05.src index 7ae679e6d..419168183 100644 --- a/testsuite/escript/oper/plusplus05.src +++ b/testsuite/escript/oper/plusplus05.src @@ -1,11 +1,10 @@ -var s:=struct{resist_fire_mod:=2}; // reserved name, converts to get_member_id -var i:=++s.resist_fire_mod; -print(i); -print(++i); // no ref -print(s); -print(i); -print(s.resist_fire_mod++); -print(++s.resist_fire_mod); +var s := struct{ resist_fire_mod := 2 }; // reserved name, converts to get_member_id +var i := ++s.resist_fire_mod; +print( i ); +print( ++i ); // no ref +print( s ); +print( i ); +print( s.resist_fire_mod++ ); +print( ++s.resist_fire_mod ); ++s.resist_fire_mod; -print(s); - +print( s ); diff --git a/testsuite/escript/oper/singleequal01.err b/testsuite/escript/oper/singleequal01.err index 0259fcdec..22b30a0f7 100644 --- a/testsuite/escript/oper/singleequal01.err +++ b/testsuite/escript/oper/singleequal01.err @@ -1 +1 @@ -Unexpected token: '='. Did you mean := for assign? +:1:10: error: Unexpected token: '='. Did you mean := for assign? \ No newline at end of file diff --git a/testsuite/escript/oper/singleequal02.err b/testsuite/escript/oper/singleequal02.err index b76d77873..944b512e8 100644 --- a/testsuite/escript/oper/singleequal02.err +++ b/testsuite/escript/oper/singleequal02.err @@ -1 +1 @@ -singleequal02.src:3:5: error: Deprecated '=' found: did you mean '==' or ':='? +:3:5: error: Deprecated '=' found: did you mean '==' or ':='? \ No newline at end of file diff --git a/testsuite/escript/opt/opt001.src b/testsuite/escript/opt/opt001.src index 11f9e5c5f..066c9b8d5 100644 --- a/testsuite/escript/opt/opt001.src +++ b/testsuite/escript/opt/opt001.src @@ -2,4 +2,4 @@ var x := { { -2, 0 }, { -2, +1 } }; print( "x is: " ); -print( x ); \ No newline at end of file +print( x ); diff --git a/testsuite/escript/opt/opt002.src b/testsuite/escript/opt/opt002.src index 1b56cecab..a96118276 100644 --- a/testsuite/escript/opt/opt002.src +++ b/testsuite/escript/opt/opt002.src @@ -3,8 +3,8 @@ const B := 5; var x := 7; -if (x == 5) - print(1); -elseif (A != B) - print(2); -endif \ No newline at end of file +if ( x == 5 ) + print( 1 ); +elseif ( A != B ) + print( 2 ); +endif diff --git a/testsuite/escript/opt/opt003.src b/testsuite/escript/opt/opt003.src index 40aadbfdd..cee55d4dd 100644 --- a/testsuite/escript/opt/opt003.src +++ b/testsuite/escript/opt/opt003.src @@ -1,6 +1,6 @@ var x := 2; -if (x) - print(1); -elseif (3) - print(2); +if ( x ) + print( 1 ); +elseif ( 3 ) + print( 2 ); endif diff --git a/testsuite/escript/opt/opt004.src b/testsuite/escript/opt/opt004.src index 09692619d..8081b5cb5 100644 --- a/testsuite/escript/opt/opt004.src +++ b/testsuite/escript/opt/opt004.src @@ -2,9 +2,9 @@ const A := 4; const B := 5; var x := 7; -print(0); -if (x == 5) - print(1); -elseif (A == B) - print(2); -endif \ No newline at end of file +print( 0 ); +if ( x == 5 ) + print( 1 ); +elseif ( A == B ) + print( 2 ); +endif diff --git a/testsuite/escript/opt/opt005-stopped-optimizing-early.src b/testsuite/escript/opt/opt005-stopped-optimizing-early.src index 8e3905ca1..e8355db8d 100644 --- a/testsuite/escript/opt/opt005-stopped-optimizing-early.src +++ b/testsuite/escript/opt/opt005-stopped-optimizing-early.src @@ -4,6 +4,6 @@ var ii; // The OG optimizer had a bug where would exit early // after not optimizing (ii-), and so it would // not optimize the global assignment + consume. -ii := 1 - (--i); -print(i); -print(ii); +ii := 1 - ( --i ); +print( i ); +print( ii ); diff --git a/testsuite/escript/opt/opt006.src b/testsuite/escript/opt/opt006.src index 825f18f21..8b5cc442a 100644 --- a/testsuite/escript/opt/opt006.src +++ b/testsuite/escript/opt/opt006.src @@ -5,23 +5,23 @@ var T := true; var F := false; var U := uninit; -print(true && false); -print(T && F); +print( true && false ); +print( T && F ); -print(true || false); -print(T || F); +print( true || false ); +print( T || F ); -print(false && true); -print(F && T); +print( false && true ); +print( F && T ); -print(false || true); -print(F || T); +print( false || true ); +print( F || T ); -print(!false); -print(!F); +print( !false ); +print( !F ); -print(!true); -print(!T); +print( !true ); +print( !T ); -print(!uninit); -print(!U); +print( !uninit ); +print( !U ); diff --git a/testsuite/escript/pack/pack01.src b/testsuite/escript/pack/pack01.src index 378c21923..c80f2ac66 100644 --- a/testsuite/escript/pack/pack01.src +++ b/testsuite/escript/pack/pack01.src @@ -1,4 +1,4 @@ var a := 57; print( a ); -print( pack(a) ); -print( unpack( pack(a) ) ); \ No newline at end of file +print( pack( a ) ); +print( unpack( pack( a ) ) ); diff --git a/testsuite/escript/pack/pack011-double-with-exponent-then-error.src b/testsuite/escript/pack/pack011-double-with-exponent-then-error.src index 28189010e..4f02b529b 100644 --- a/testsuite/escript/pack/pack011-double-with-exponent-then-error.src +++ b/testsuite/escript/pack/pack011-double-with-exponent-then-error.src @@ -1,5 +1,5 @@ include "packtst"; -var ob := { 76e+16, error { errortext := "oh no" } }; +var ob := { 76e+16, error{ errortext := "oh no" } }; var rep := "a2:r7.6e+17e1:S9:errortextS5:oh no"; test_pack( ob, rep ); diff --git a/testsuite/escript/pack/pack012-double-no-exponent-then-error.src b/testsuite/escript/pack/pack012-double-no-exponent-then-error.src index 22048002f..029f6bab7 100644 --- a/testsuite/escript/pack/pack012-double-no-exponent-then-error.src +++ b/testsuite/escript/pack/pack012-double-no-exponent-then-error.src @@ -1,10 +1,10 @@ include "packtst"; -var ob := { 7.6, error { errortext := "oh no" } }; +var ob := { 7.6, error{ errortext := "oh no" } }; var rep := "a2:r7.6e1:S9:errortextS5:oh no"; // It turns out this has always been broken. -//test_pack( ob, rep ); +// test_pack( ob, rep ); // If it weren't (or if we use the fix for osx builds everywhere) this would be expected: /* @@ -14,4 +14,4 @@ Result representation: a2:r7.6e1:S9:errortextS5:oh no Successful! Unpacked: { 7.6, error{ errortext = "oh no" } } Unpack matches! -*/ \ No newline at end of file +*/ diff --git a/testsuite/escript/pack/pack013-double.src b/testsuite/escript/pack/pack013-double.src index 99f82251d..25452f614 100644 --- a/testsuite/escript/pack/pack013-double.src +++ b/testsuite/escript/pack/pack013-double.src @@ -3,4 +3,3 @@ include "packtst"; var ob := 12345678.12345678; var rep := "r12345678.12345678"; test_pack( ob, rep ); - diff --git a/testsuite/escript/pack/pack04a.src b/testsuite/escript/pack/pack04a.src index 15cf1df2d..ba287f89b 100644 --- a/testsuite/escript/pack/pack04a.src +++ b/testsuite/escript/pack/pack04a.src @@ -1,4 +1,4 @@ include "packtst"; var a := "hello world"; -test_pack( a[1,5], "shello" ); +test_pack( a[1, 5], "shello" ); diff --git a/testsuite/escript/pack/pack07.src b/testsuite/escript/pack/pack07.src index 7b55fd910..0f44c02ce 100644 --- a/testsuite/escript/pack/pack07.src +++ b/testsuite/escript/pack/pack07.src @@ -1,5 +1,5 @@ include "packtst"; -var ob := { 5, 7, "hey there", { 1,2,3,4 }, 42 }; +var ob := { 5, 7, "hey there", { 1, 2, 3, 4 }, 42 }; var rep := "a5:i5i7S9:hey therea4:i1i2i3i4i42"; test_pack( ob, rep ); diff --git a/testsuite/escript/pack/pack08.src b/testsuite/escript/pack/pack08.src index 361574cad..3517fa294 100644 --- a/testsuite/escript/pack/pack08.src +++ b/testsuite/escript/pack/pack08.src @@ -1,9 +1,9 @@ include "packtst"; var ob := dictionary; -ob[ "hey" ] := 57; -ob[ "you" ] := 73; -ob[ "blah" ] := "test"; +ob["hey"] := 57; +ob["you"] := 73; +ob["blah"] := "test"; var rep := "d3:S4:blahS4:testS3:heyi57S3:youi73"; diff --git a/testsuite/escript/pack/pack09.src b/testsuite/escript/pack/pack09.src index 69ee1c1a8..8062f3791 100644 --- a/testsuite/escript/pack/pack09.src +++ b/testsuite/escript/pack/pack09.src @@ -1,5 +1,6 @@ -var d:= "d62:ui1ui2ui3ui4ui5ui6ui7ui8ui9ui10ui11ui12ui13ui14ui15"+ "ui16ui17ui18ui19ui20ui21ui22ui23ui24ui25ui26ui27ui28ui29" + "ui30ui31ui32ui33ui34ui35ui36ui37ui38ui39ui40ui41ui42ui43" + "ui44ui45ui46ui47ui48ui49ui50ui51ui52ui53" + - "ui54ui55ui56ui57ui58ui59ui60ui61ui62"; +var d := "d62:ui1ui2ui3ui4ui5ui6ui7ui8ui9ui10ui11ui12ui13ui14ui15" + "ui16ui17ui18ui19ui20ui21ui22ui23ui24ui25ui26ui27ui28ui29" + + "ui30ui31ui32ui33ui34ui35ui36ui37ui38ui39ui40ui41ui42ui43" + + "ui44ui45ui46ui47ui48ui49ui50ui51ui52ui53" + "ui54ui55ui56ui57ui58ui59ui60ui61ui62"; -var u := unpack(d); -print( u ); \ No newline at end of file +var u := unpack( d ); +print( u ); diff --git a/testsuite/escript/pack/packtst.inc b/testsuite/escript/pack/packtst.inc index e6e924f36..693fe95cc 100644 --- a/testsuite/escript/pack/packtst.inc +++ b/testsuite/escript/pack/packtst.inc @@ -3,31 +3,31 @@ // test_pack( obj, string_representation ) function test_pack( obj, exrep ) - print( "Testing Pack for: " + obj ); - print( "Expected representation: " + exrep ); - - var acrep := pack( obj ); - print( "Result representation: " + acrep ); - if (exrep == acrep) - print( "Successful!" ); - else - print( "Failure!" ); - return 0; - endif + print( "Testing Pack for: " + obj ); + print( "Expected representation: " + exrep ); - var unp := unpack( acrep ); - print( "Unpacked: " + unp ); - if (unp == obj) - print( "Unpack matches!" ); - else - print( "Unpack doesn't match!" ); - if ( pack(unp) == acrep ) - print( "repack does match, however." ); - else - print( "repack is " + pack(unp) ); - endif - return 0; - endif + var acrep := pack( obj ); + print( "Result representation: " + acrep ); + if ( exrep == acrep ) + print( "Successful!" ); + else + print( "Failure!" ); + return 0; + endif - return 1; -endfunction \ No newline at end of file + var unp := unpack( acrep ); + print( "Unpacked: " + unp ); + if ( unp == obj ) + print( "Unpack matches!" ); + else + print( "Unpack doesn't match!" ); + if ( pack( unp ) == acrep ) + print( "repack does match, however." ); + else + print( "repack is " + pack( unp ) ); + endif + return 0; + endif + + return 1; +endfunction diff --git a/testsuite/escript/parity/parity001-identifier-module.src b/testsuite/escript/parity/parity001-identifier-module.src index 182c96f02..cbbdb8469 100644 --- a/testsuite/escript/parity/parity001-identifier-module.src +++ b/testsuite/escript/parity/parity001-identifier-module.src @@ -1,5 +1,4 @@ var a := struct; a.+print := "x"; a.+hex := "y"; -print(a); - +print( a ); diff --git a/testsuite/escript/prec/prec01.src b/testsuite/escript/prec/prec01.src index d6ad72d53..4f97fcf16 100644 --- a/testsuite/escript/prec/prec01.src +++ b/testsuite/escript/prec/prec01.src @@ -1,7 +1,7 @@ var a array; -a .+ text := "hi bank"; +a.+text := "hi bank"; -if (a.text["bank"]) - print( "Success!" ); -endif \ No newline at end of file +if ( a.text["bank"] ) + print( "Success!" ); +endif diff --git a/testsuite/escript/prec/prec02.src b/testsuite/escript/prec/prec02.src index 4658c5936..d8e25d530 100644 --- a/testsuite/escript/prec/prec02.src +++ b/testsuite/escript/prec/prec02.src @@ -2,4 +2,4 @@ var a; a.text["test"]; -print( "dummy"); \ No newline at end of file +print( "dummy" ); diff --git a/testsuite/escript/prec/prec03.src b/testsuite/escript/prec/prec03.src index bbdc12acb..c6365e737 100644 --- a/testsuite/escript/prec/prec03.src +++ b/testsuite/escript/prec/prec03.src @@ -1,9 +1,9 @@ var a := struct; -a .+ text := "hi bank"; +a.+text := "hi bank"; print( a ); -if (a.text["bank"]) - print( "Success!" ); -endif \ No newline at end of file +if ( a.text["bank"] ) + print( "Success!" ); +endif diff --git a/testsuite/escript/prog/prog01.src b/testsuite/escript/prog/prog01.src index 19b3a434a..ac5d82012 100644 --- a/testsuite/escript/prog/prog01.src +++ b/testsuite/escript/prog/prog01.src @@ -1,3 +1,3 @@ program foo() - print( "hello world" ); -endprogram \ No newline at end of file + print( "hello world" ); +endprogram diff --git a/testsuite/escript/prog/prog02.src b/testsuite/escript/prog/prog02.src index f1b9fabe4..a2df10c0e 100644 --- a/testsuite/escript/prog/prog02.src +++ b/testsuite/escript/prog/prog02.src @@ -1,6 +1,6 @@ program foo( a, b ) - print( "hello world" ); - print( "a: " + a ); - print( "b: " + b ); - var c := 7; + print( "hello world" ); + print( "a: " + a ); + print( "b: " + b ); + var c := 7; endprogram diff --git a/testsuite/escript/prog/prog03.src b/testsuite/escript/prog/prog03.src index b6216b7e9..c3195dd95 100644 --- a/testsuite/escript/prog/prog03.src +++ b/testsuite/escript/prog/prog03.src @@ -1,9 +1,9 @@ -program foo( ) - print( "hello world" ); - - print( "bar: " + bar() ); +program foo() + print( "hello world" ); + + print( "bar: " + bar() ); endprogram function bar() - return "rab"; -endfunction \ No newline at end of file + return "rab"; +endfunction diff --git a/testsuite/escript/prog/prog04.src b/testsuite/escript/prog/prog04.src index c01f1c294..36418b79c 100644 --- a/testsuite/escript/prog/prog04.src +++ b/testsuite/escript/prog/prog04.src @@ -1,10 +1,10 @@ -program foo( ) - print( "hello world" ); - - print( "bar: " + bar() ); - return; +program foo() + print( "hello world" ); + + print( "bar: " + bar() ); + return; endprogram function bar() - return "rab"; -endfunction \ No newline at end of file + return "rab"; +endfunction diff --git a/testsuite/escript/prog/prog05.src b/testsuite/escript/prog/prog05.src index 505a6b897..8f631d3ae 100644 --- a/testsuite/escript/prog/prog05.src +++ b/testsuite/escript/prog/prog05.src @@ -1,9 +1,9 @@ -program foo( unused a, unused b) - print( "hello world" ); +program foo( unused a, unused b ) + print( "hello world" ); - print( "sum: " + sum(1, 2) ); + print( "sum: " + sum( 1, 2 ) ); endprogram -function sum(first, unused second) - return first + second; +function sum( first, unused second ) + return first + second; endfunction diff --git a/testsuite/escript/prog/prog06-vars-are-local.src b/testsuite/escript/prog/prog06-vars-are-local.src index fe056a67a..cd14198ed 100644 --- a/testsuite/escript/prog/prog06-vars-are-local.src +++ b/testsuite/escript/prog/prog06-vars-are-local.src @@ -1,11 +1,10 @@ var a := "the global var"; -print(a); +print( a ); program foo() - var a := "the local var"; - print(a); + var a := "the local var"; + print( a ); endprogram -print(a); - +print( a ); diff --git a/testsuite/escript/prog/surrounded.src b/testsuite/escript/prog/surrounded.src index 43891372a..fad00b2f7 100644 --- a/testsuite/escript/prog/surrounded.src +++ b/testsuite/escript/prog/surrounded.src @@ -1,7 +1,7 @@ print( "before" ); program foo() - print( "body" ); + print( "body" ); endprogram print( "after" ); diff --git a/testsuite/escript/quot/quot001.src b/testsuite/escript/quot/quot001.src index d6d5c81b9..585d3ea27 100644 --- a/testsuite/escript/quot/quot001.src +++ b/testsuite/escript/quot/quot001.src @@ -1,2 +1,2 @@ print( "\"Hello world\"" ); -print( "Hello \"again\" world" ); \ No newline at end of file +print( "Hello \"again\" world" ); diff --git a/testsuite/escript/recurs/recurs01.src b/testsuite/escript/recurs/recurs01.src index feff826b2..482709924 100644 --- a/testsuite/escript/recurs/recurs01.src +++ b/testsuite/escript/recurs/recurs01.src @@ -1,9 +1,9 @@ -function fac(x) - if (x == 1) - return 1; - else - return x * fac(x-1); - endif +function fac( x ) + if ( x == 1 ) + return 1; + else + return x * fac( x - 1 ); + endif endfunction -print( fac(4) ); +print( fac( 4 ) ); diff --git a/testsuite/escript/recurs/recurs02.src b/testsuite/escript/recurs/recurs02.src index ce5d179fe..f1c944795 100644 --- a/testsuite/escript/recurs/recurs02.src +++ b/testsuite/escript/recurs/recurs02.src @@ -1,10 +1,10 @@ -function fac(x) - print("fac(" + x + ")"); - if (x == 1) - return 1; - else - return x * fac(x-1); - endif +function fac( x ) + print( "fac(" + x + ")" ); + if ( x == 1 ) + return 1; + else + return x * fac( x - 1 ); + endif endfunction -print( fac(4) ); +print( fac( 4 ) ); diff --git a/testsuite/escript/reff/ref001.err b/testsuite/escript/reff/ref001.err index fb1c26a89..fdc569c10 100644 --- a/testsuite/escript/reff/ref001.err +++ b/testsuite/escript/reff/ref001.err @@ -1 +1 @@ -ref001.src:2:12: error: extraneous input 'b' expecting ';' \ No newline at end of file +:2:12: error: extraneous input 'b' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/reff/ref001a.src b/testsuite/escript/reff/ref001a.src index 5af768647..f8d40d02a 100644 --- a/testsuite/escript/reff/ref001a.src +++ b/testsuite/escript/reff/ref001a.src @@ -1,4 +1,4 @@ var b; b := not b; -print(b); +print( b ); diff --git a/testsuite/escript/reff/ref002.err b/testsuite/escript/reff/ref002.err index 58de7805e..7748f7bf8 100644 --- a/testsuite/escript/reff/ref002.err +++ b/testsuite/escript/reff/ref002.err @@ -1 +1 @@ -ref002.src:5:16: error: extraneous input 'ar' expecting ';' \ No newline at end of file +:5:16: error: extraneous input 'ar' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/reff/reff001.src b/testsuite/escript/reff/reff001.src index 81d48445e..e22d8ca26 100644 --- a/testsuite/escript/reff/reff001.src +++ b/testsuite/escript/reff/reff001.src @@ -1,9 +1,9 @@ function foo( byref a ) - a := 5; + a := 5; endfunction var b; b := 2; -print(b); -foo(b); -print(b); \ No newline at end of file +print( b ); +foo( b ); +print( b ); diff --git a/testsuite/escript/reff/reff002.src b/testsuite/escript/reff/reff002.src index 3387dbe27..ada035099 100644 --- a/testsuite/escript/reff/reff002.src +++ b/testsuite/escript/reff/reff002.src @@ -1,9 +1,9 @@ function foo( byref a ) - a := 5; + a := 5; endfunction -var b := struct { c, d }; +var b := struct{ c, d }; b.c := 17; -print(b); -foo(b.c); -print(b); \ No newline at end of file +print( b ); +foo( b.c ); +print( b ); diff --git a/testsuite/escript/reff/reff003.src b/testsuite/escript/reff/reff003.src index def45390a..bb4950473 100644 --- a/testsuite/escript/reff/reff003.src +++ b/testsuite/escript/reff/reff003.src @@ -1,10 +1,10 @@ function foo( byref a ) - a := 5; + a := 5; endfunction var b := dictionary; b[17] := 46; b[31] := 50; -print(b); -foo(b[17]); -print(b); \ No newline at end of file +print( b ); +foo( b[17] ); +print( b ); diff --git a/testsuite/escript/repeat/repeat01.src b/testsuite/escript/repeat/repeat01.src index fdb98bcd5..a271ebd8b 100644 --- a/testsuite/escript/repeat/repeat01.src +++ b/testsuite/escript/repeat/repeat01.src @@ -1,7 +1,6 @@ var i := 0; repeat - i := i + 1; - print(i); + i := i + 1; + print( i ); until i >= 10; - diff --git a/testsuite/escript/repeat/repeat02.src b/testsuite/escript/repeat/repeat02.src index b091ba035..69c8a82a7 100644 --- a/testsuite/escript/repeat/repeat02.src +++ b/testsuite/escript/repeat/repeat02.src @@ -1,8 +1,7 @@ var i := 0; repeat - i := i + 1; - print(i); - break; + i := i + 1; + print( i ); + break; until i >= 10; - diff --git a/testsuite/escript/repeat/repeat03.src b/testsuite/escript/repeat/repeat03.src index 085a11f80..66311138e 100644 --- a/testsuite/escript/repeat/repeat03.src +++ b/testsuite/escript/repeat/repeat03.src @@ -1,8 +1,7 @@ var i := 0; repeat - i := i + 1; - print(i); - continue; + i := i + 1; + print( i ); + continue; until i >= 10; - diff --git a/testsuite/escript/repeat/repeat04.src b/testsuite/escript/repeat/repeat04.src index de5cd54ae..1cc652b8e 100644 --- a/testsuite/escript/repeat/repeat04.src +++ b/testsuite/escript/repeat/repeat04.src @@ -1,9 +1,8 @@ var i := 0; repeat - i := i + 1; - print(i); - continue; - print(i); + i := i + 1; + print( i ); + continue; + print( i ); until i >= 10; - diff --git a/testsuite/escript/repeat/repeat05.src b/testsuite/escript/repeat/repeat05.src index fd6a1bd46..9f6502d1f 100644 --- a/testsuite/escript/repeat/repeat05.src +++ b/testsuite/escript/repeat/repeat05.src @@ -1,9 +1,8 @@ var i := 0; repeat - i := i + 1; - print(i); - break; - print(i); + i := i + 1; + print( i ); + break; + print( i ); until i >= 10; - diff --git a/testsuite/escript/repeat/repeat06.src b/testsuite/escript/repeat/repeat06.src index 6b6dd7a3c..d6f0bdce4 100644 --- a/testsuite/escript/repeat/repeat06.src +++ b/testsuite/escript/repeat/repeat06.src @@ -1,9 +1,8 @@ var i := 0; repeat - var a := i + 4; - i := i + 1; - print("I="+i); - print("A="+a); + var a := i + 4; + i := i + 1; + print( "I=" + i ); + print( "A=" + a ); until i >= 10; - diff --git a/testsuite/escript/repeat/repeat07.src b/testsuite/escript/repeat/repeat07.src index 8ad4b2aaf..00f97eabd 100644 --- a/testsuite/escript/repeat/repeat07.src +++ b/testsuite/escript/repeat/repeat07.src @@ -1,10 +1,9 @@ var i := 0; repeat - var a := i + 4; - i := i + 1; - print("I="+i); - print("A="+a); - break; + var a := i + 4; + i := i + 1; + print( "I=" + i ); + print( "A=" + a ); + break; until i >= 10; - diff --git a/testsuite/escript/repeat/repeat08.src b/testsuite/escript/repeat/repeat08.src index ba9bb1c37..d984a91a2 100644 --- a/testsuite/escript/repeat/repeat08.src +++ b/testsuite/escript/repeat/repeat08.src @@ -1,10 +1,9 @@ var i := 0; repeat - var a := i + 4; - i := i + 1; - print("A="+a); - break; - print("I="+i); + var a := i + 4; + i := i + 1; + print( "A=" + a ); + break; + print( "I=" + i ); until i >= 10; - diff --git a/testsuite/escript/repeat/repeat09.src b/testsuite/escript/repeat/repeat09.src index a072aea12..7a5aa95e3 100644 --- a/testsuite/escript/repeat/repeat09.src +++ b/testsuite/escript/repeat/repeat09.src @@ -1,10 +1,9 @@ var i := 0; repeat - var a := i + 4; - i := i + 1; - print("A="+a + ", I=" + i); - continue; - print("I="+i); + var a := i + 4; + i := i + 1; + print( "A=" + a + ", I=" + i ); + continue; + print( "I=" + i ); until i >= 10; - diff --git a/testsuite/escript/repeat/repeat10.src b/testsuite/escript/repeat/repeat10.src index 229f64957..2e738b125 100644 --- a/testsuite/escript/repeat/repeat10.src +++ b/testsuite/escript/repeat/repeat10.src @@ -1,11 +1,10 @@ var i := 0; repeat - var a := i + 4; - i := i + 1; - print("A="+a + ", I=" + i); - continue; - var b; - print("I="+i); + var a := i + 4; + i := i + 1; + print( "A=" + a + ", I=" + i ); + continue; + var b; + print( "I=" + i ); until i >= 10; - diff --git a/testsuite/escript/reserved/non_reserved_words.src b/testsuite/escript/reserved/non_reserved_words.src index 3d0605977..2a358e51e 100644 --- a/testsuite/escript/reserved/non_reserved_words.src +++ b/testsuite/escript/reserved/non_reserved_words.src @@ -1,6 +1,5 @@ var NULL := "NULL is not reserved"; var DECLARE := "DECLARE is not reserved"; -print(NULL); -print(DECLARE); - +print( NULL ); +print( DECLARE ); diff --git a/testsuite/escript/scope/scope01.src b/testsuite/escript/scope/scope01.src index fdad40d25..c648a3186 100644 --- a/testsuite/escript/scope/scope01.src +++ b/testsuite/escript/scope/scope01.src @@ -1,5 +1,5 @@ -if (1) - var a; - a := 5; - print( "A=" + a ); -endif \ No newline at end of file +if ( 1 ) + var a; + a := 5; + print( "A=" + a ); +endif diff --git a/testsuite/escript/scope/scope02.err b/testsuite/escript/scope/scope02.err index 8efef2293..19aca2a62 100644 --- a/testsuite/escript/scope/scope02.err +++ b/testsuite/escript/scope/scope02.err @@ -1 +1 @@ -scope02.src:10:15: error: Unknown identifier 'a'. \ No newline at end of file +:10:15: error: Unknown identifier 'a'. \ No newline at end of file diff --git a/testsuite/escript/scope/scope02.src b/testsuite/escript/scope/scope02.src index 1cc6675eb..92cfd1d9e 100644 --- a/testsuite/escript/scope/scope02.src +++ b/testsuite/escript/scope/scope02.src @@ -1,10 +1,10 @@ // Scope02 - make sure locals go out of scope // this should fail to compile. -if (1) - var a; - a := 5; - print( "A=" + a ); +if ( 1 ) + var a; + a := 5; + print( "A=" + a ); endif print( "A=" + a ); diff --git a/testsuite/escript/scope/scope03.src b/testsuite/escript/scope/scope03.src index 8936b38a5..163d67736 100644 --- a/testsuite/escript/scope/scope03.src +++ b/testsuite/escript/scope/scope03.src @@ -2,10 +2,10 @@ var a := 6; -if (1) - var a; - a := 5; - print( "1. A=" + a ); +if ( 1 ) + var a; + a := 5; + print( "1. A=" + a ); endif print( "2. A=" + a ); diff --git a/testsuite/escript/scope/scope04.src b/testsuite/escript/scope/scope04.src index 65fd856fc..babb35c25 100644 --- a/testsuite/escript/scope/scope04.src +++ b/testsuite/escript/scope/scope04.src @@ -1,15 +1,14 @@ // Scope04 - make sure locals in sub-blocks can override other locals -// +// - -if (1) +if ( 1 ) + var a; + a := 5; + print( "1. A=" + a ); + if ( 2 ) var a; - a := 5; - print( "1. A=" + a ); - if (2) - var a; - a := 7; - print( "2. A=" + a ); - endif - print( "3. A=" + a ); + a := 7; + print( "2. A=" + a ); + endif + print( "3. A=" + a ); endif diff --git a/testsuite/escript/scope/scope05.err b/testsuite/escript/scope/scope05.err index e9a22d407..761b38091 100644 --- a/testsuite/escript/scope/scope05.err +++ b/testsuite/escript/scope/scope05.err @@ -1,2 +1,2 @@ -scope05.src:8:9: error: Variable 'a' is already in scope. +:8:7: error: Variable 'a' is already in scope. See previous definition at: \ No newline at end of file diff --git a/testsuite/escript/scope/scope05.src b/testsuite/escript/scope/scope05.src index f2e47cd6f..c3b8666d7 100644 --- a/testsuite/escript/scope/scope05.src +++ b/testsuite/escript/scope/scope05.src @@ -1,11 +1,11 @@ // Scope05 - make sure locals can't be declared twice in the same block. // this should fail to compile -if (1) - var a; - a := 5; - print( "1. A=" + a ); - var a; - a := 6; - print( "2. A=" + a ); +if ( 1 ) + var a; + a := 5; + print( "1. A=" + a ); + var a; + a := 6; + print( "2. A=" + a ); endif diff --git a/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.err b/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.err index e92665118..a2d6c13e9 100644 --- a/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.err +++ b/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.err @@ -1 +1 @@ -scope06-program-arg-same-level-var-conflict.src:5:9: error: Variable 'bar' is already in scope. \ No newline at end of file +:5:7: error: Variable 'bar' is already in scope. \ No newline at end of file diff --git a/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.src b/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.src index 4c5b87016..7367f852a 100644 --- a/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.src +++ b/testsuite/escript/scope/scope06-program-arg-same-level-var-conflict.src @@ -1,6 +1,6 @@ // Scope06 - a variable with the same name as a program argument // cannot be declared at the top level of the program block. -program foo(bar) - var bar; // expect compile error +program foo( bar ) + var bar; // expect compile error endprogram diff --git a/testsuite/escript/scope/scope07-program-arg-scoped-var-ok.src b/testsuite/escript/scope/scope07-program-arg-scoped-var-ok.src index d5d3cebdc..2db095cdd 100644 --- a/testsuite/escript/scope/scope07-program-arg-scoped-var-ok.src +++ b/testsuite/escript/scope/scope07-program-arg-scoped-var-ok.src @@ -1,10 +1,10 @@ // Scope07 - a variable with the same name as a program argument // cannot be declared at the top level of the program block. -program foo(bar) - if ( 1 ) - var bar; // this is ok - bar := "x"; - print(bar); - endif +program foo( bar ) + if ( 1 ) + var bar; // this is ok + bar := "x"; + print( bar ); + endif endprogram diff --git a/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.err b/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.err index 0dc856157..b73cad90a 100644 --- a/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.err +++ b/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.err @@ -1,2 +1,2 @@ -scope08-function-arg-same-level-var-conflict.src:5:9: error: Variable 'bar' is already in scope. +:5:7: error: Variable 'bar' is already in scope. See previous definition at: \ No newline at end of file diff --git a/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.src b/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.src index b2d881fe5..05e37ed24 100644 --- a/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.src +++ b/testsuite/escript/scope/scope08-function-arg-same-level-var-conflict.src @@ -1,8 +1,8 @@ // Scope08 - a variable with the same name as a function argument // cannot be declared at the top level of the function block. -function foo(bar) - var bar; // expect compile error +function foo( bar ) + var bar; // expect compile error endfunction -foo(4); \ No newline at end of file +foo( 4 ); diff --git a/testsuite/escript/scope/scope09-function-arg-scoped-var-ok.src b/testsuite/escript/scope/scope09-function-arg-scoped-var-ok.src index b1485fd3f..0bffd0730 100644 --- a/testsuite/escript/scope/scope09-function-arg-scoped-var-ok.src +++ b/testsuite/escript/scope/scope09-function-arg-scoped-var-ok.src @@ -1,11 +1,11 @@ // Scope09 - a variable with the same name as a function argument // cannot be declared at the top level of the function block. -function foo(bar) - if ( 1 ) - var bar; // this is ok - print(bar); - endif +function foo( bar ) + if ( 1 ) + var bar; // this is ok + print( bar ); + endif endfunction -foo(4); \ No newline at end of file +foo( 4 ); diff --git a/testsuite/escript/size/size001.src b/testsuite/escript/size/size001.src index 702bdca16..35673ea69 100644 --- a/testsuite/escript/size/size001.src +++ b/testsuite/escript/size/size001.src @@ -1,6 +1,6 @@ var QueueList; -QueueList := { }; +QueueList := {}; -Print("Size:"+QueueList.Size()); -Print("Len :"+Len(QueueList)); +Print( "Size:" + QueueList.Size() ); +Print( "Len :" + Len( QueueList ) ); diff --git a/testsuite/escript/spread/doc-sample-1.src b/testsuite/escript/spread/doc-sample-1.src index fd1210e1c..00c6c3e45 100644 --- a/testsuite/escript/spread/doc-sample-1.src +++ b/testsuite/escript/spread/doc-sample-1.src @@ -1,4 +1,4 @@ -function Sum( numbers... ) +function Sum( numbers ... ) var total := 0; foreach number in numbers total += number; @@ -10,6 +10,6 @@ endfunction program main( who ) var numbers1 := array{ 1, 2, 3 }; var numbers2 := array{ 4, 5, 6 }; - var total := Sum( numbers1..., numbers2... ); + var total := Sum( numbers1 ..., numbers2 ... ); Print( total ); // Output: 21 -endprogram \ No newline at end of file +endprogram diff --git a/testsuite/escript/spread/doc-sample-2.src b/testsuite/escript/spread/doc-sample-2.src index 981ee6ab7..300883164 100644 --- a/testsuite/escript/spread/doc-sample-2.src +++ b/testsuite/escript/spread/doc-sample-2.src @@ -2,6 +2,6 @@ program main( who ) var numbers1 := array{ 1, 2, 3 }; var numbers2 := array{ 4, 5, 6 }; - var numbers := array{ numbers1..., numbers2... }; + var numbers := array{ numbers1 ..., numbers2 ... }; Print( numbers ); // Output: { 1, 2, 3, 4, 5, 6 } endprogram diff --git a/testsuite/escript/spread/doc-sample-3.src b/testsuite/escript/spread/doc-sample-3.src index f0e71fb7e..b783f1c5d 100644 --- a/testsuite/escript/spread/doc-sample-3.src +++ b/testsuite/escript/spread/doc-sample-3.src @@ -11,12 +11,12 @@ program main( who ) // total := Sum( numbers... ); // Okay! Use the expression-as-callee syntax - total := (@Sum)( numbers... ); // Or: @Sum.call( numbers... ) + total := ( @Sum )( numbers ... ); // Or: @Sum.call( numbers... ) Print( total ); // Output: 6 // Calling @Sum with the wrong number of arguments will result in an error: numbers := { 1, 2 }; - total := (@Sum)( numbers... ); + total := ( @Sum )( numbers ... ); Print( total ); // Output: Invalid argument count: expected 3, got 2 -endprogram \ No newline at end of file +endprogram diff --git a/testsuite/escript/spread/doc-sample-4.src b/testsuite/escript/spread/doc-sample-4.src index a030a1d07..1d76c9864 100644 --- a/testsuite/escript/spread/doc-sample-4.src +++ b/testsuite/escript/spread/doc-sample-4.src @@ -1,4 +1,4 @@ -function Sum( numbers... ) +function Sum( numbers ... ) var total := 0; foreach number in numbers total += number; @@ -10,13 +10,13 @@ endfunction program main( who ) // Spread a dictionary's values into a function var dict := dictionary{ "a" -> 1, "b" -> 2, "c" -> 3 }; - var total := Sum( dict... ); + var total := Sum( dict ... ); Print( total ); // Output: 6 // `lastcoords` is a struct{ x := 123, y := 456, z := 789 } - who := struct { lastcoords := struct{ x := 123, y := 456, z := 789 } }; + who := struct{ lastcoords := struct{ x := 123, y := 456, z := 789 } }; // Spread a struct's values into an array. - var coords := array{ who.lastcoords... }; + var coords := array{ who.lastcoords ... }; Print( ", ".join( coords ) ); // Output: 123, 456, 789 endprogram diff --git a/testsuite/escript/spread/equivalence.src b/testsuite/escript/spread/equivalence.src index 4bcfee788..09ee5783b 100644 --- a/testsuite/escript/spread/equivalence.src +++ b/testsuite/escript/spread/equivalence.src @@ -1,81 +1,83 @@ -// More checks that calling a user function (compile-time arg checks) -// and function reference (runtime-arg checks). Does more funky things +// More checks that calling a user function ( compile-time arg checks ) +// and function reference ( runtime-arg checks ). Does more funky things // with spreads, eg. multiple and nested. -function args0( args... ) - return $"args={args}"; +function args0( args ... ) + return $"args={args}"; endfunction -function args1( a, args... ) - return $"a={a} args={args}"; +function args1( a, args ... ) + return $"a={a} args={args}"; endfunction -function args2( a, b, args... ) - return $"a={a} b={b} args={args}"; +function args2( a, b, args ... ) + return $"a={a} b={b} args={args}"; endfunction -function Times10( byref what ) return what * 10; endfunction -function Times100( byref what ) return what * 100; endfunction -function Times1000( byref what ) return what * 1000; endfunction +function Times10( byref what ) + return what * 10; +endfunction +function Times100( byref what ) + return what * 100; +endfunction +function Times1000( byref what ) + return what * 1000; +endfunction var total := 0; var sum := 0; -function add(result) - ++total; - sum += result; +function add( result ) + ++total; + sum += result; endfunction -var spreads := { - {}, - {1}, - {1, 2}, - {1, 2, 3} -}; +var spreads := { {}, { 1 }, { 1, 2 }, { 1, 2, 3 } }; +// format-off foreach spread in spreads - add((@args0)(spread...) == args0(spread...)); - add((@args0)("a", spread...) == args0("a", spread...)); - add((@args0)("a", "b", spread...) == args0("a", "b", spread...)); - add((@args0)("a", "b", "c", spread...) == args0("a", "b", "c", spread...)); + add( ( @args0 )( spread ... ) == args0( spread ... ) ); + add( ( @args0 )( "a", spread ... ) == args0( "a", spread ... ) ); + add( ( @args0 )( "a", "b", spread ... ) == args0( "a", "b", spread ... ) ); + add( ( @args0 )( "a", "b", "c", spread ... ) == args0( "a", "b", "c", spread ... ) ); // Multiple spreads, with non-spread args before, after, and in-between - add((@args0)(spread..., spread...) == args0(spread..., spread...)); - add((@args0)("a", spread..., "a", spread...) == args0("a", spread..., "a", spread...)); - add((@args0)("a", "b", spread..., "a", "b", spread...) == args0("a", "b", spread..., "a", "b", spread...)); - add((@args0)("a", "b", "c", spread..., "a", "b", "c", spread...) == args0("a", "b", "c", spread..., "a", "b", "c", spread...)); + add( ( @args0 )( spread ..., spread ... ) == args0( spread ..., spread ... ) ); + add( ( @args0 )( "a", spread ..., "a", spread ... ) == args0( "a", spread ..., "a", spread ... ) ); + add( ( @args0 )( "a", "b", spread ..., "a", "b", spread ... ) == args0( "a", "b", spread ..., "a", "b", spread ... ) ); + add( ( @args0 )( "a", "b", "c", spread ..., "a", "b", "c", spread ... ) == args0( "a", "b", "c", spread ..., "a", "b", "c", spread ... ) ); // Nested spreads, with non-spread args before and after. - add((@args0)( "a", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "z" ) == args0( "a", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "z" ) ); - add((@args0)( "a", "b", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "y", "z" ) == args0( "a", "b", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "y", "z" ) ); - add((@args0)( "a", "b", "c", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "x", "y", "z" ) == args0( "a", "b", "c", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "x", "y", "z" ) ); + add( ( @args0 )( "a", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "z" ) == args0( "a", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "z" ) ); + add( ( @args0 )( "a", "b", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "y", "z" ) == args0( "a", "b", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "y", "z" ) ); + add( ( @args0 )( "a", "b", "c", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "x", "y", "z" ) == args0( "a", "b", "c", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "x", "y", "z" ) ); // compile error, "a" not passed; see below tests for runtime error - // add((@args1)(spread...) == args2(spread...)); - add((@args1)("a", spread...) == args1("a", spread...)); - add((@args1)("a", "b", spread...) == args1("a", "b", spread...)); - add((@args1)("a", "b", "c", spread...) == args1("a", "b", "c", spread...)); - add((@args1)("a", spread..., "a", spread...) == args1("a", spread..., "a", spread...)); - add((@args1)("a", "b", spread..., "a", "b", spread...) == args1("a", "b", spread..., "a", "b", spread...)); - add((@args1)("a", "b", "c", spread..., "a", "b", "c", spread...) == args1("a", "b", "c", spread..., "a", "b", "c", spread...)); - add((@args1)( "a", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "z" ) == args1( "a", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "z" ) ); - add((@args1)( "a", "b", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "y", "z" ) == args1( "a", "b", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "y", "z" ) ); - add((@args1)( "a", "b", "c", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "x", "y", "z" ) == args1( "a", "b", "c", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "x", "y", "z" ) ); + // add( ( @args1 )( spread ... ) == args2( spread ... ) ); + add( ( @args1 )( "a", spread ... ) == args1( "a", spread ... ) ); + add( ( @args1 )( "a", "b", spread ... ) == args1( "a", "b", spread ... ) ); + add( ( @args1 )( "a", "b", "c", spread ... ) == args1( "a", "b", "c", spread ... ) ); + add( ( @args1 )( "a", spread ..., "a", spread ... ) == args1( "a", spread ..., "a", spread ... ) ); + add( ( @args1 )( "a", "b", spread ..., "a", "b", spread ... ) == args1( "a", "b", spread ..., "a", "b", spread ... ) ); + add( ( @args1 )( "a", "b", "c", spread ..., "a", "b", "c", spread ... ) == args1( "a", "b", "c", spread ..., "a", "b", "c", spread ... ) ); + add( ( @args1 )( "a", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "z" ) == args1( "a", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "z" ) ); + add( ( @args1 )( "a", "b", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "y", "z" ) == args1( "a", "b", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "y", "z" ) ); + add( ( @args1 )( "a", "b", "c", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "x", "y", "z" ) == args1( "a", "b", "c", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "x", "y", "z" ) ); // compile error, "a" and "b" not passed - // add((@args2)(spread...) == args2(spread...)); + // add( ( @args2 )( spread ... ) == args2( spread ... ) ); // compile error, "b" not passed - // add((@args2)("a", spread...) == args2("a", spread...)); - add((@args2)("a", "b", spread...) == args2("a", "b", spread...)); - add((@args2)("a", "b", "c", spread...) == args2("a", "b", "c", spread...)); + // add( ( @args2 )( "a", spread ... ) == args2( "a", spread ... ) ); + add( ( @args2 )( "a", "b", spread ... ) == args2( "a", "b", spread ... ) ); + add( ( @args2 )( "a", "b", "c", spread ... ) == args2( "a", "b", "c", spread ... ) ); // compile error, "b" not passed - // add((@args2)("a", spread..., "a", spread...) == args2("a", spread..., "a", spread...)); - add((@args2)("a", "b", spread..., "a", "b", spread...) == args2("a", "b", spread..., "a", "b", spread...)); - add((@args2)("a", "b", "c", spread..., "a", "b", "c", spread...) == args2("a", "b", "c", spread..., "a", "b", "c", spread...)); + // add( ( @args2 )( "a", spread ..., "a", spread ... ) == args2( "a", spread ..., "a", spread ... ) ); + add( ( @args2 )( "a", "b", spread ..., "a", "b", spread ... ) == args2( "a", "b", spread ..., "a", "b", spread ... ) ); + add( ( @args2 )( "a", "b", "c", spread ..., "a", "b", "c", spread ... ) == args2( "a", "b", "c", spread ..., "a", "b", "c", spread ... ) ); // compile error, "b" not passed - // add((@args2)( "a", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "z" ) == args2( "a", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "z" ) ); - add((@args2)( "a", "b", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "y", "z" ) == args2( "a", "b", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "y", "z" ) ); - add((@args2)( "a", "b", "c", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "x", "y", "z" ) == args2( "a", "b", "c", { spread..., { spread.map(@Times10)..., spread.map(@Times100)... }... }... , "x", "y", "z" ) ); + // add( ( @args2 )( "a", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "z" ) == args2( "a", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "z" ) ); + add( ( @args2 )( "a", "b", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "y", "z" ) == args2( "a", "b", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "y", "z" ) ); + add( ( @args2 )( "a", "b", "c", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "x", "y", "z" ) == args2( "a", "b", "c", { spread ..., { spread.map( @Times10 ) ..., spread.map( @Times100 ) ... } ... } ... , "x", "y", "z" ) ); endforeach @@ -85,12 +87,12 @@ endforeach foreach spread in spreads if ( spread.size() < 1 ) // `args1` expects 1 argument, but spread has 0 elements. - add((@args1)(spread...) == uninit); + add( ( @args1 )( spread ... ) == uninit ); endif if ( spread.size() < 2 ) // `args2` expects 2 arguments, but spread has 0-1 elements. - add((@args2)(spread...) == uninit); + add( ( @args2 )( spread ... ) == uninit ); endif endforeach diff --git a/testsuite/escript/spread/into-array.src b/testsuite/escript/spread/into-array.src index 58f5540ec..9d9c86281 100644 --- a/testsuite/escript/spread/into-array.src +++ b/testsuite/escript/spread/into-array.src @@ -3,10 +3,10 @@ var strct := struct{ a := "A", b := "B", c := "C" }; var dict := dictionary{ "a" -> "A", "b" -> "B", "c" -> "C" }; var arr := array{ 1, 2, 3 }; -print({ arr..., arr... }); // { 1, 2, 3, 1, 2, 3 } -print({ arr..., strct... }); // { 1, 2, 3, A, B, C } -print({ arr..., dict... }); // { 1, 2, 3, A, B, C } +print( { arr ..., arr ... } ); // { 1, 2, 3, 1, 2, 3 } +print( { arr ..., strct ... } ); // { 1, 2, 3, A, B, C } +print( { arr ..., dict ... } ); // { 1, 2, 3, A, B, C } // A generic ContIterator imp does nothing -print({ arr..., uninit... }); // { 1, 2, 3 }; -print({ arr..., ("foo")... }); // { 1, 2, 3 }; +print( { arr ..., uninit ... } ); // { 1, 2, 3 }; +print( { arr ..., ( "foo" ) ... } ); // { 1, 2, 3 }; diff --git a/testsuite/escript/spread/module-stubs.inc b/testsuite/escript/spread/module-stubs.inc index 454f95537..36b634343 100644 --- a/testsuite/escript/spread/module-stubs.inc +++ b/testsuite/escript/spread/module-stubs.inc @@ -1,17 +1,35 @@ -function CreateItemAtLocation( unused x, unused y, unused z, unused objtype, unused amount := 1, unused realm := "britannia" ) return "item"; endfunction -function CreateMultiAtLocation( unused x, unused y, unused z, objtype, unused flags := 0, unused realm := "britannia" ) - return TypeOfInt(objtype) == OT_STRING ? "multi" : error{ errortext := "Invalid parameter type" }; +function CreateItemAtLocation( unused x, unused y, unused z, unused objtype, unused amount := 1, + unused realm := "britannia" ) + return "item"; +endfunction + +function CreateMultiAtLocation( unused x, unused y, unused z, objtype, unused flags := 0, + unused realm := "britannia" ) + return TypeOfInt( objtype ) == OT_STRING ? "multi" : error{ errortext := "Invalid parameter type" }; +endfunction + +function CreateNpcFromTemplate( unused template, unused x, unused y, unused z, + unused override_properties := 0, unused realm := "britannia", + unused forcelocation := 0 ) + return "npc"; endfunction -function CreateNpcFromTemplate( unused template, unused x, unused y, unused z, unused override_properties := 0, unused realm := "britannia", unused forcelocation := 0) return "npc"; endfunction function TypeOfInt_( what ) case ( what ) - "item": return OT_ITEMREF; + "item": return OT_ITEMREF; "multi": return OT_MULTIREF; - "npc": return OT_MOBILEREF; + "npc": return OT_MOBILEREF; default: return OT_UNKNOWN; endcase endfunction -function DisposeItem( unused what... ) print( "DisposeItem" ); endfunction -function DisposeMulti( unused what... ) print( "DisposeMulti" ); endfunction -function DisposeNpc( unused what... ) print( "DisposeNpc" ); endfunction +function DisposeItem( unused what ... ) + print( "DisposeItem" ); +endfunction + +function DisposeMulti( unused what ... ) + print( "DisposeMulti" ); +endfunction + +function DisposeNpc( unused what ... ) + print( "DisposeNpc" ); +endfunction diff --git a/testsuite/escript/spread/print-spreads.src b/testsuite/escript/spread/print-spreads.src index c6b17c07d..b072256ec 100644 --- a/testsuite/escript/spread/print-spreads.src +++ b/testsuite/escript/spread/print-spreads.src @@ -1,73 +1,68 @@ -function args0( args... ) - return( $"args={args}" ); +function args0( args ... ) + return ( $"args={args}" ); endfunction -function args1( a, args... ) - return( $"a={a} args={args}" ); +function args1( a, args ... ) + return ( $"a={a} args={args}" ); endfunction -function args2( a, b, args... ) - return( $"a={a} b={b} args={args}" ); +function args2( a, b, args ... ) + return ( $"a={a} b={b} args={args}" ); endfunction -function args3( a, b, c, args... ) - return( $"a={a} b={b} c={c} args={args}" ); +function args3( a, b, c, args ... ) + return ( $"a={a} b={b} c={c} args={args}" ); endfunction -var f_set := array{ - {}, - { "x" }, - { "x","y" }, - { "x","y","z" } -}; +var f_set := array{ {}, { "x" }, { "x", "y" }, { "x", "y", "z" } }; foreach f in f_set print( "bareArrayInitializer" ); - print( { f... } ); - print( { 1, f... } ); - print( { 1, 2, f... } ); - print( { 1, 2, 3, f... } ); + print( { f ... } ); + print( { 1, f ... } ); + print( { 1, 2, f ... } ); + print( { 1, 2, 3, f ... } ); print( "-" ); print( "arrayInitializer" ); - print( array{ f... } ); - print( array{ 1, f... } ); - print( array{ 1, 2, f... } ); - print( array{ 1, 2, 3, f... } ); + print( array{ f ... } ); + print( array{ 1, f ... } ); + print( array{ 1, 2, f ... } ); + print( array{ 1, 2, 3, f ... } ); print( "-" ); print( "functionCallSuffix" ); - print( @args0( f... ) ); - print( @args0( 1, f... ) ); - print( @args0( 1, 2, f... ) ); - print( @args0( 1, 2, 3, f... ) ); + print( @args0( f ... ) ); + print( @args0( 1, f ... ) ); + print( @args0( 1, 2, f ... ) ); + print( @args0( 1, 2, 3, f ... ) ); print( "-" ); print( "functionCallSuffix" ); - print( @args1( f... ) ); - print( @args1( 1, f... ) ); - print( @args1( 1, 2, f... ) ); - print( @args1( 1, 2, 3, f... ) ); + print( @args1( f ... ) ); + print( @args1( 1, f ... ) ); + print( @args1( 1, 2, f ... ) ); + print( @args1( 1, 2, 3, f ... ) ); print( "-" ); print( "functionCallSuffix" ); - print( @args2( f... ) ); - print( @args2( 1, f... ) ); - print( @args2( 1, 2, f... ) ); - print( @args2( 1, 2, 3, f... ) ); + print( @args2( f ... ) ); + print( @args2( 1, f ... ) ); + print( @args2( 1, 2, f ... ) ); + print( @args2( 1, 2, 3, f ... ) ); print( "-" ); print( "methodCallSuffix" ); // via `s.insert()` var s := struct{}; - print( s.insert( f... ) ); // This will be BError unless `f` has two arguments (key and value) + print( s.insert( f ... ) ); // This will be BError unless `f` has two arguments (key and value) print( $"s={s}" ); print( "-" ); print( "functionCall" ); - print( args0( f... ) ); - print( args1( 1, f... ) ); - print( args2( 1, 2, f... ) ); - print( args3( 1, 2, 3, f... ) ); + print( args0( f ... ) ); + print( args1( 1, f ... ) ); + print( args2( 1, 2, f ... ) ); + print( args3( 1, 2, 3, f ... ) ); print( "-----" ); endforeach diff --git a/testsuite/escript/spread/resource-tracker-functional.src b/testsuite/escript/spread/resource-tracker-functional.src index 20b5a3987..62a962a95 100644 --- a/testsuite/escript/spread/resource-tracker-functional.src +++ b/testsuite/escript/spread/resource-tracker-functional.src @@ -5,26 +5,21 @@ print( "----" ); print( test( false ) ); function test( has_success ) - return with_resources( - @{ return CreateItemAtLocation(1, 2, 3, 0xeed); }, + return with_resources( @{ + return CreateItemAtLocation( 1, 2, 3, 0xeed ); + }, @{ + return CreateMultiAtLocation( 1, 2, 3, "SmallHouse" ); + }, with_dispose( @{ + return CreateMultiAtLocation( 1, 2, 3, has_success ? "SmallHouse" : error{} ); + }, @( what, item, unused multi /* from the first SmallHouse */ ) { + print( $"DisposeCustom on '{what}' but do something with item '{item}' first" ); + } ), @{ + return CreateNPCFromTemplate( "brigand", 1, 2, 3 ); + }, @( item, multi, multi2, npc ) { + print( $"In test: item={item} multi={multi} multi2={multi2} npc={npc}" ); - @{ return CreateMultiAtLocation(1, 2, 3, "SmallHouse"); }, - - with_dispose( - @{ return CreateMultiAtLocation(1, 2, 3, has_success ? "SmallHouse" : error{}); }, - @( what, item, unused multi /*from the first SmallHouse*/ ) { - print( $"DisposeCustom on '{what}' but do something with item '{item}' first" ); - } - ), - - @{ return CreateNPCFromTemplate("brigand", 1, 2, 3); }, - - @(item, multi, multi2, npc) { - print( $"In test: item={item} multi={multi} multi2={multi2} npc={npc}" ); - - return 1; - } - ); + return 1; + } ); endfunction function DisposeCustom( what ) @@ -37,7 +32,7 @@ function with_dispose( resource, finalizer ) return array{ resource, finalizer }; endfunction -function with_resources( args... ) +function with_resources( args ... ) var resources := array{}; var cleanup := @{ @@ -50,30 +45,30 @@ function with_resources( args... ) var call_args := resources.map( @( resource ) { return resource[1]; - }); + } ); - cleanup_fn( resource, call_args... ); + cleanup_fn( resource, call_args ... ); endwhile }; foreach arg in args - if (_arg_iter == args.size()) + if ( _arg_iter == args.size() ) var call_args := resources.map( @( resource ) { return resource[1]; - }); + } ); - var result := arg( call_args... ); + var result := arg( call_args ... ); cleanup(); return result; endif - if (TypeOfInt(arg) == OT_ARRAY) - var resource := (arg[1])(); + if ( TypeOfInt( arg ) == OT_ARRAY ) + var resource := ( arg[1] )(); - if (!resource) + if ( !resource ) cleanup(); return resource; endif @@ -82,10 +77,10 @@ function with_resources( args... ) resources.append( with_dispose( resource, finalizer ) ); - elseif (TypeOfInt(arg) == OT_FUNCOBJECT) + elseif ( TypeOfInt( arg ) == OT_FUNCOBJECT ) var resource := arg(); - if (!resource) + if ( !resource ) cleanup(); return resource; endif @@ -95,13 +90,14 @@ function with_resources( args... ) var type := TypeOfInt_( resource ); case ( type ) - OT_ITEMREF: finalizer := @DisposeItem; - OT_MULTIREF: finalizer := @DisposeMulti; + OT_ITEMREF: finalizer := @DisposeItem; + OT_MULTIREF: finalizer := @DisposeMulti; OT_MOBILEREF: finalizer := @DisposeNpc; - default: finalizer := @(what) { print( $"Cannot dispose @{what}" ); }; + default: + finalizer := @( what ) { print( $"Cannot dispose @{what}" ); }; endcase - resources.append( with_dispose(resource, finalizer) ); + resources.append( with_dispose( resource, finalizer ) ); endif endforeach diff --git a/testsuite/escript/spread/resource-tracker-procedural.src b/testsuite/escript/spread/resource-tracker-procedural.src index 2c93a472a..76cfb8fde 100644 --- a/testsuite/escript/spread/resource-tracker-procedural.src +++ b/testsuite/escript/spread/resource-tracker-procedural.src @@ -5,26 +5,27 @@ print( "----" ); print( test( false ) ); function test( has_success ) - return with_tracker( @(track) { - var item := track( CreateItemAtLocation(1, 2, 3, 0xeed ) ); + return with_tracker( @( track ) { + var item := track( CreateItemAtLocation( 1, 2, 3, 0xeed ) ); if ( !item ) return item; endif - var multi := track( CreateMultiAtLocation(1, 2, 3, "SmallHouse" ) ); + var multi := track( CreateMultiAtLocation( 1, 2, 3, "SmallHouse" ) ); if ( !multi ) return multi; endif - var multi2 := track( CreateMultiAtLocation(1, 2, 3, has_success ? "SmallHouse" : error{}), @(what) { + var multi2 := track( CreateMultiAtLocation( 1, 2, 3, has_success ? + "SmallHouse" : error{} ), @( what ) { print( $"DisposeCustom on '{what}' but do something with item '{item}' first" ); - }); + } ); if ( !multi2 ) return multi2; endif - var npc := track( CreateNPCFromTemplate("brigand", 1, 2, 3) ); + var npc := track( CreateNPCFromTemplate( "brigand", 1, 2, 3 ) ); if ( !npc ) return npc; endif @@ -32,7 +33,7 @@ function test( has_success ) print( $"In test: item={item} multi={multi} multi2={multi2} npc={npc}" ); return 1; - }); + } ); endfunction function DisposeCustom( what ) @@ -42,7 +43,7 @@ endfunction ////////////////////////////////////////////////////// function with_tracker( tracked_fn ) - var resources := array{ }; + var resources := array{}; var cleanup := @{ while ( resources.size() ) @@ -55,7 +56,7 @@ function with_tracker( tracked_fn ) endwhile }; - var track := @( args... ){ + var track := @( args ... ) { var resource := args[1]; if ( !resource ) @@ -65,20 +66,21 @@ function with_tracker( tracked_fn ) var finalizer; - if ( TypeOfInt(args[2]) == OT_FUNCOBJECT ) + if ( TypeOfInt( args[2] ) == OT_FUNCOBJECT ) finalizer := args[2]; else var type := TypeOfInt_( resource ); case ( type ) - OT_ITEMREF: finalizer := @DisposeItem; - OT_MULTIREF: finalizer := @DisposeMulti; + OT_ITEMREF: finalizer := @DisposeItem; + OT_MULTIREF: finalizer := @DisposeMulti; OT_MOBILEREF: finalizer := @DisposeNpc; - default: finalizer := @(what) { print( $"Cannot dispose @{what}" ); }; + default: + finalizer := @( what ) { print( $"Cannot dispose @{what}" ); }; endcase endif - resources.append( { resource, finalizer }); + resources.append( { resource, finalizer } ); return resource; }; diff --git a/testsuite/escript/spread/syntax-err-1.err b/testsuite/escript/spread/syntax-err-1.err index 749a41e28..069e7e966 100644 --- a/testsuite/escript/spread/syntax-err-1.err +++ b/testsuite/escript/spread/syntax-err-1.err @@ -1 +1 @@ -syntax-err-1.src:5:24: error: In call to 'bar': Spread operator can only be used for arguments on or after the formal rest parameter. \ No newline at end of file +:6:30: error: In call to 'bar': Spread operator can only be used for arguments on or after the formal rest parameter. \ No newline at end of file diff --git a/testsuite/escript/spread/syntax-err-1.src b/testsuite/escript/spread/syntax-err-1.src index 0f64e9e09..c93c65bd8 100644 --- a/testsuite/escript/spread/syntax-err-1.src +++ b/testsuite/escript/spread/syntax-err-1.src @@ -1,5 +1,6 @@ var foo; -function bar( a, b, c, d, unused args ...) endfunction +function bar( a, b, c, d, unused args ... ) +endfunction // errors nice -bar( a:=1, d:=2, b:=4, foo... ); +bar( a := 1, d := 2, b := 4, foo ... ); diff --git a/testsuite/escript/spread/syntax-err-2.err b/testsuite/escript/spread/syntax-err-2.err index befc2ebb1..90f6ba9b8 100644 --- a/testsuite/escript/spread/syntax-err-2.err +++ b/testsuite/escript/spread/syntax-err-2.err @@ -1 +1 @@ -syntax-err-2.src:1:7: error: In call to 'print': Spread operator cannot be used in module function call. \ No newline at end of file +:1:8: error: In call to 'print': Spread operator cannot be used in module function call. \ No newline at end of file diff --git a/testsuite/escript/spread/syntax-err-2.src b/testsuite/escript/spread/syntax-err-2.src index b97d18dea..989df84ba 100644 --- a/testsuite/escript/spread/syntax-err-2.src +++ b/testsuite/escript/spread/syntax-err-2.src @@ -1 +1 @@ -print(""...); +print( "" ... ); diff --git a/testsuite/escript/spread/syntax-err-3.err b/testsuite/escript/spread/syntax-err-3.err index de65e7e41..333d1bb28 100644 --- a/testsuite/escript/spread/syntax-err-3.err +++ b/testsuite/escript/spread/syntax-err-3.err @@ -1 +1 @@ -syntax-err-3.src:3:5: error: In call to 'foo': Spread operator can only be used in variadic functions. \ No newline at end of file +:4:6: error: In call to 'foo': Spread operator can only be used in variadic functions. \ No newline at end of file diff --git a/testsuite/escript/spread/syntax-err-3.src b/testsuite/escript/spread/syntax-err-3.src index aec37c902..fc80b103d 100644 --- a/testsuite/escript/spread/syntax-err-3.src +++ b/testsuite/escript/spread/syntax-err-3.src @@ -1,3 +1,4 @@ -function foo(a, b) endfunction +function foo( a, b ) +endfunction -foo(""...); +foo( "" ... ); diff --git a/testsuite/escript/spread/syntax-err-4.err b/testsuite/escript/spread/syntax-err-4.err index ed05ade43..bcb5a99a2 100644 --- a/testsuite/escript/spread/syntax-err-4.err +++ b/testsuite/escript/spread/syntax-err-4.err @@ -1 +1 @@ -syntax-err-4.src:3:10: error: extraneous input '...' \ No newline at end of file +:3:10: error: extraneous input '...' expecting ']' \ No newline at end of file diff --git a/testsuite/escript/spread/syntax-err-5.err b/testsuite/escript/spread/syntax-err-5.err index 6df422eaa..bcb5a99a2 100644 --- a/testsuite/escript/spread/syntax-err-5.err +++ b/testsuite/escript/spread/syntax-err-5.err @@ -1 +1 @@ -syntax-err-5.src:3:10: error: extraneous input '...' \ No newline at end of file +:3:10: error: extraneous input '...' expecting ']' \ No newline at end of file diff --git a/testsuite/escript/spread/syntax.src b/testsuite/escript/spread/syntax.src index bb1e7ac92..0ff0844b1 100644 --- a/testsuite/escript/spread/syntax.src +++ b/testsuite/escript/spread/syntax.src @@ -1,26 +1,27 @@ -var foo := {3}; +var foo := { 3 }; -function bar( a, b, c, d, unused args ...) endfunction +function bar( a, b, c, d, unused args ... ) +endfunction // bareArrayInitializer -{ 1 , 2, foo... }; -{ 1 , 2, foo..., foo..., { 1 , 2, foo..., foo... }... }; +{ 1, 2, foo ... }; +{ 1, 2, foo ..., foo ..., { 1, 2, foo ..., foo ... } ... }; // functionCallSuffix -( @bar ) ( foo... ); -( @bar ) ( foo..., 1, 2, foo..., {1, 2, 3}..., {{1,2,3}...,4} ); +( @bar )( foo ... ); +( @bar )( foo ..., 1, 2, foo ..., { 1, 2, 3 } ..., { { 1, 2, 3 } ..., 4 } ); // indexingSuffix -- NOT ALLOWED // foo[1, 2, foo...]; // but the indexingSuffix can have children that are spread -foo[1, { 1, 2, foo... }]; +foo[1, { 1, 2, foo ... }]; // methodCallSuffix -foo.bar( 1, 2, foo... ); +foo.bar( 1, 2, foo ... ); // functionCall -bar( a:=1, d:=2, c:=3, b:=4, foo... ); +bar( a := 1, d := 2, c := 3, b := 4, foo ... ); // arrayInitializer -array{ 1, 2, foo... }; +array{ 1, 2, foo ... }; diff --git a/testsuite/escript/string/string01.src b/testsuite/escript/string/string01.src index 45f84db44..10a3c722b 100644 --- a/testsuite/escript/string/string01.src +++ b/testsuite/escript/string/string01.src @@ -1,4 +1,3 @@ -if ("test" == "test") - print( "1: Success" ); +if ( "test" == "test" ) + print( "1: Success" ); endif - diff --git a/testsuite/escript/string/string02.src b/testsuite/escript/string/string02.src index 380d3a96c..b7cddeed0 100644 --- a/testsuite/escript/string/string02.src +++ b/testsuite/escript/string/string02.src @@ -1,13 +1,13 @@ var a := "testvalue"; -if (a[3] == "s") - print( "1: Success"); +if ( a[3] == "s" ) + print( "1: Success" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if (a[2] == "f") - print( "2: Failure" ); +if ( a[2] == "f" ) + print( "2: Failure" ); else - print( "2: Success" ); + print( "2: Success" ); endif diff --git a/testsuite/escript/string/string03.src b/testsuite/escript/string/string03.src index d44444f5c..3f7e2b469 100644 --- a/testsuite/escript/string/string03.src +++ b/testsuite/escript/string/string03.src @@ -1,13 +1,13 @@ var a := "testvalue"; -if ("s" == a[3]) - print( "1: Success"); +if ( "s" == a[3] ) + print( "1: Success" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if ("f" == a[2]) - print( "2: Failure" ); +if ( "f" == a[2] ) + print( "2: Failure" ); else - print( "2: Success" ); + print( "2: Success" ); endif diff --git a/testsuite/escript/string/string04.src b/testsuite/escript/string/string04.src index a9b4f0d6e..081425265 100644 --- a/testsuite/escript/string/string04.src +++ b/testsuite/escript/string/string04.src @@ -1,13 +1,13 @@ var a := "testvalue"; -if ("FRED" < "WILMA") - print( "1: Success"); +if ( "FRED" < "WILMA" ) + print( "1: Success" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if ("WILMA" < "FRED") - print( "2: Failure" ); +if ( "WILMA" < "FRED" ) + print( "2: Failure" ); else - print( "2: Success" ); + print( "2: Success" ); endif diff --git a/testsuite/escript/string/string05.src b/testsuite/escript/string/string05.src index c83c8325f..209f9f4ce 100644 --- a/testsuite/escript/string/string05.src +++ b/testsuite/escript/string/string05.src @@ -1,13 +1,13 @@ var a := "testvalue"; -if ("FRED" < "FREDDY") - print( "1: Success!"); +if ( "FRED" < "FREDDY" ) + print( "1: Success!" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if ("FREDDY" < "FRED") - print( "2: Failure!" ); +if ( "FREDDY" < "FRED" ) + print( "2: Failure!" ); else - print( "2: Success!" ); + print( "2: Success!" ); endif diff --git a/testsuite/escript/string/string06.src b/testsuite/escript/string/string06.src index cc67edd1d..8a756c1b8 100644 --- a/testsuite/escript/string/string06.src +++ b/testsuite/escript/string/string06.src @@ -5,29 +5,29 @@ var b := "value2"; var c := "value"; /**************************/ -if (b[1,5] == c) - print( "1: Success!"); +if ( b[1, 5] == c ) + print( "1: Success!" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if (c == b[1,5]) - print( "1: Success!"); +if ( c == b[1, 5] ) + print( "1: Success!" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif /**************************/ /**************************/ -if (b[1,5] != c) - print( "1: Failure!"); +if ( b[1, 5] != c ) + print( "1: Failure!" ); else - print( "1: Success!"); + print( "1: Success!" ); endif -if (c != b[1,5]) - print( "1: Failure!"); +if ( c != b[1, 5] ) + print( "1: Failure!" ); else - print( "1: Success!"); + print( "1: Success!" ); endif /**************************/ diff --git a/testsuite/escript/string/string07.src b/testsuite/escript/string/string07.src index adecd3645..40d83d799 100644 --- a/testsuite/escript/string/string07.src +++ b/testsuite/escript/string/string07.src @@ -1,9 +1,7 @@ var cmd := "marion walk NW"; -var walkcmd := cmd["walk",7]; - +var walkcmd := cmd["walk", 7]; + print( walkcmd ); - -print( walkcmd[6,2] ); - +print( walkcmd[6, 2] ); diff --git a/testsuite/escript/string/string08.src b/testsuite/escript/string/string08.src index 58c640272..a484bd870 100644 --- a/testsuite/escript/string/string08.src +++ b/testsuite/escript/string/string08.src @@ -1,9 +1,7 @@ var cmd := "marion walk N"; -var walkcmd := cmd["walk",7]; - -print("'" + walkcmd + "'"); +var walkcmd := cmd["walk", 7]; +print( "'" + walkcmd + "'" ); -print( "'" + walkcmd[6,2] + "'"); - +print( "'" + walkcmd[6, 2] + "'" ); diff --git a/testsuite/escript/string/string09.src b/testsuite/escript/string/string09.src index f9fd7e910..227536b21 100644 --- a/testsuite/escript/string/string09.src +++ b/testsuite/escript/string/string09.src @@ -1,13 +1,13 @@ var cmd := "marion walk N"; -if (cmd["marion"]) - print( "ok!" ); +if ( cmd["marion"] ) + print( "ok!" ); else - print( "failure 1!" ); + print( "failure 1!" ); endif -if (cmd["blah"]) - print( "failure 2!" ); +if ( cmd["blah"] ) + print( "failure 2!" ); else - print( "ok!" ); + print( "ok!" ); endif diff --git a/testsuite/escript/string/string10.src b/testsuite/escript/string/string10.src index 092673525..14851a88c 100644 --- a/testsuite/escript/string/string10.src +++ b/testsuite/escript/string/string10.src @@ -1,4 +1,4 @@ var a := "hello world"; var space := 4; -print( a[space+2, 6] ); -print( a[6,6] ); +print( a[space + 2, 6] ); +print( a[6, 6] ); diff --git a/testsuite/escript/string/string11.src b/testsuite/escript/string/string11.src index 6659e3c61..79b492c38 100644 --- a/testsuite/escript/string/string11.src +++ b/testsuite/escript/string/string11.src @@ -4,21 +4,20 @@ var a := "testvalue"; var b := "value2"; var c := "value"; -print( "a="+a ); -print( "b="+b ); -print( "c="+c ); +print( "a=" + a ); +print( "b=" + b ); +print( "c=" + c ); var d := a["val"]; - // This is key: this assignment must not modify 'a'. +// This is key: this assignment must not modify 'a'. d := "hello"; -print( "a="+a ); -print( "d="+d ); +print( "a=" + a ); +print( "d=" + d ); - // Now, this one _should_. +// Now, this one _should_. a["val"] := "hello"; -print( "a="+a ); -print( "d="+d ); - +print( "a=" + a ); +print( "d=" + d ); diff --git a/testsuite/escript/string/string12.src b/testsuite/escript/string/string12.src index 74e29bc2c..640c894a4 100644 --- a/testsuite/escript/string/string12.src +++ b/testsuite/escript/string/string12.src @@ -1,10 +1,9 @@ function foo() - var keyid := "0"; - var keyarray := { "blahblahblah", "blahexxblah" }; - var keystr := CStr(keyid)+": "; - var datstr := keyarray[CInt(keyid)]; - return datstr[len(keystr)+1,len(datstr)]; + var keyid := "0"; + var keyarray := { "blahblahblah", "blahexxblah" }; + var keystr := CStr( keyid ) + ": "; + var datstr := keyarray[CInt( keyid )]; + return datstr[len( keystr ) + 1, len( datstr )]; endfunction print( foo() ); - diff --git a/testsuite/escript/string/string13.src b/testsuite/escript/string/string13.src index 496968105..af79975cf 100644 --- a/testsuite/escript/string/string13.src +++ b/testsuite/escript/string/string13.src @@ -4,5 +4,4 @@ var a := "testvalue"; a["val"] := "hello"; - -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/string/string14.src b/testsuite/escript/string/string14.src index 4aed8d033..f27ea0d91 100644 --- a/testsuite/escript/string/string14.src +++ b/testsuite/escript/string/string14.src @@ -1,6 +1,5 @@ var a := "abcdefg"; -var b := a[1,4]; -print(a); -print(b); - +var b := a[1, 4]; +print( a ); +print( b ); diff --git a/testsuite/escript/string/string15.src b/testsuite/escript/string/string15.src index e059309da..f631a9e70 100644 --- a/testsuite/escript/string/string15.src +++ b/testsuite/escript/string/string15.src @@ -3,8 +3,8 @@ var b := "value2"; var c := "value"; -if (c == b[1,5]) - print( "1: Success!"); +if ( c == b[1, 5] ) + print( "1: Success!" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif diff --git a/testsuite/escript/string/string16.src b/testsuite/escript/string/string16.src index f70087c0a..32cd594e7 100644 --- a/testsuite/escript/string/string16.src +++ b/testsuite/escript/string/string16.src @@ -1,13 +1,13 @@ var a := "testvalue"; -if (a[3] < "t") - print( "1: Success"); +if ( a[3] < "t" ) + print( "1: Success" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if (a[2] > "f") - print( "2: Failure" ); +if ( a[2] > "f" ) + print( "2: Failure" ); else - print( "2: Success" ); + print( "2: Success" ); endif diff --git a/testsuite/escript/string/string17.src b/testsuite/escript/string/string17.src index 51d962b0b..3986b182b 100644 --- a/testsuite/escript/string/string17.src +++ b/testsuite/escript/string/string17.src @@ -1,13 +1,13 @@ var a := "testvalue"; -if (a[3] < a[4]) - print( "1: Success"); +if ( a[3] < a[4] ) + print( "1: Success" ); else - print( "1: Failure!"); + print( "1: Failure!" ); endif -if (a[2] > a[1]) - print( "2: Failure" ); +if ( a[2] > a[1] ) + print( "2: Failure" ); else - print( "2: Success" ); + print( "2: Success" ); endif diff --git a/testsuite/escript/string/string18.src b/testsuite/escript/string/string18.src index 700590ec7..01de8c68f 100644 --- a/testsuite/escript/string/string18.src +++ b/testsuite/escript/string/string18.src @@ -1,38 +1,37 @@ -print("testing length"); -foreach str in {"","1234","1"} - print("testing '"+str+"' length: "+len(str) ); - if (len(str)!=str.length()) - print("failed size "+len(str)+"!="+str.length()); - endif +print( "testing length" ); +foreach str in { "", "1234", "1" } + print( "testing '" + str + "' length: " + len( str ) ); + if ( len( str ) != str.length() ) + print( "failed size " + len( str ) + "!=" + str.length() ); + endif endforeach -print("\ntesting join"); -var str:=","; -var arr := {1,"2",3.1,4,5}; -arr[10]:="test"; -var res:=str.join(arr); -print(str); -print(res); -print("\none "+"test".join({1})); +print( "\ntesting join" ); +var str := ","; +var arr := { 1, "2", 3.1, 4, 5 }; +arr[10] := "test"; +var res := str.join( arr ); +print( str ); +print( res ); +print( "\none " + "test".join( { 1 } ) ); -print("\nemptytest '"+ "empty".join({})+"'"); +print( "\nemptytest '" + "empty".join( {} ) + "'" ); -print("\ntesting upper"); -str:="asbcxysd"; -var orig:=str; -var up:=str.upper(); -print(up); -print("\ntesting lower"); -print(up.lower()); -if (up != orig) - print("compare failed"); +print( "\ntesting upper" ); +str := "asbcxysd"; +var orig := str; +var up := str.upper(); +print( up ); +print( "\ntesting lower" ); +print( up.lower() ); +if ( up != orig ) + print( "compare failed" ); endif -print("\ntesting find"); -str:="1234567"; -print(str.find("2",1)); -print(str.find("2",3)); -print(str.find("7")); -print(str.find("1")); -print(str.find("1",1)); - +print( "\ntesting find" ); +str := "1234567"; +print( str.find( "2", 1 ) ); +print( str.find( "2", 3 ) ); +print( str.find( "7" ) ); +print( str.find( "1" ) ); +print( str.find( "1", 1 ) ); diff --git a/testsuite/escript/string/string19.src b/testsuite/escript/string/string19.src index 2fce29283..1d7b7a025 100644 --- a/testsuite/escript/string/string19.src +++ b/testsuite/escript/string/string19.src @@ -1,3 +1,3 @@ // 2015-19-12 Bodom, testing escape sequences -print("testing\nescapes:\t\\\x48\x65\x6c\x6Co\x21"); +print( "testing\nescapes:\t\\\x48\x65\x6c\x6Co\x21" ); diff --git a/testsuite/escript/string/string20.src b/testsuite/escript/string/string20.src index 7a049cbfb..8a90628da 100644 --- a/testsuite/escript/string/string20.src +++ b/testsuite/escript/string/string20.src @@ -8,207 +8,214 @@ var t := "hello"; var sep := "---------------------------------------------"; // Basic types -print( TypeOf(t) ); -print( t.isA(POLCLASS_UOBJECT) ); -print( t.isA(POLCLASS_MOBILE) ); -print(sep); +print( TypeOf( t ) ); +print( t.isA( POLCLASS_UOBJECT ) ); +print( t.isA( POLCLASS_MOBILE ) ); +print( sep ); // pack/unpack -var p := Pack(t); +var p := Pack( t ); print( p ); -var u := Unpack(p); +var u := Unpack( p ); print( u ); print( u == t ); print( p != u ); -print(sep); +print( sep ); -var optests := array{ - "1234", "hello", "b", "ab", "a", "caterpillar", - 1234, 0, -6, - 12.11, 0.0, -8.8, - array{ "a", "b", "c", 19 }, - dictionary{ "1234" -> "456", "eeee" -> 0 }, - struct{ a := t, b := 21, c := "0" }, - error{ errortext := "ERROR" }, - uninit -}; +var optests := array{ "1234", + "hello", + "b", + "ab", + "a", + "caterpillar", + 1234, + 0, + -6, + 12.11, + 0.0, + -8.8, array{ "a", "b", "c", 19 }, + dictionary{ "1234" -> "456", "eeee" -> 0 }, + struct{ a := t, b := 21, c := "0" }, + error{ errortext := "ERROR" }, uninit }; // Binary operators foreach ot in optests - var tmp; + var tmp; - // comparison - print( "t == " + ot ); - print( t == ot ); - print( CStr(ot) + " == t " ); - print( ot == t ); - print( "t != " + ot ); - print( t != ot ); - print( "t < " + ot ); - print( t < ot ); - print( "t <= " + ot ); - print( t <= ot ); - print( "t > " + ot ); - print( t > ot ); - print( "t >= " + ot ); - print( t >= ot ); + // comparison + print( "t == " + ot ); + print( t == ot ); + print( CStr( ot ) + " == t " ); + print( ot == t ); + print( "t != " + ot ); + print( t != ot ); + print( "t < " + ot ); + print( t < ot ); + print( "t <= " + ot ); + print( t <= ot ); + print( "t > " + ot ); + print( t > ot ); + print( "t >= " + ot ); + print( t >= ot ); - // arithmetic - print( "t + " + ot ); - print( t + ot ); - print( CStr(ot) + " + t" ); - print( ot + t ); - print( "t - " + ot ); - print( t - ot ); - print( CStr(ot) + " - t" ); - print( ot - t ); - print( "t * " + ot ); - print( t * ot ); - print( CStr(ot) + " * t" ); - print( ot * t ); - print( "t / " + ot ); - print( t / ot ); - print( CStr(ot) + " / t" ); - print( ot / t ); - print( "t % " + ot ); - print( t % ot ); - print( CStr(ot) + " % t" ); - print( ot % t ); + // arithmetic + print( "t + " + ot ); + print( t + ot ); + print( CStr( ot ) + " + t" ); + print( ot + t ); + print( "t - " + ot ); + print( t - ot ); + print( CStr( ot ) + " - t" ); + print( ot - t ); + print( "t * " + ot ); + print( t * ot ); + print( CStr( ot ) + " * t" ); + print( ot * t ); + print( "t / " + ot ); + print( t / ot ); + print( CStr( ot ) + " / t" ); + print( ot / t ); + print( "t % " + ot ); + print( t % ot ); + print( CStr( ot ) + " % t" ); + print( ot % t ); - // arithmetic with assignment - tmp := t; - print( "tmp += " + ot ); - tmp += ot; - print( tmp ); - tmp := t; - print( "tmp -= " + ot ); - tmp -= ot; - print( tmp ); - tmp := t; - print( "tmp *= " + ot ); - tmp *= ot; - print( tmp ); - tmp := t; - print( "tmp /= " + ot ); - tmp /= ot; - print( tmp ); - tmp := t; - print( "tmp %= " + ot ); - tmp %= ot; - print( tmp ); + // arithmetic with assignment + tmp := t; + print( "tmp += " + ot ); + tmp += ot; + print( tmp ); + tmp := t; + print( "tmp -= " + ot ); + tmp -= ot; + print( tmp ); + tmp := t; + print( "tmp *= " + ot ); + tmp *= ot; + print( tmp ); + tmp := t; + print( "tmp /= " + ot ); + tmp /= ot; + print( tmp ); + tmp := t; + print( "tmp %= " + ot ); + tmp %= ot; + print( tmp ); - // bitwise - print( "t & " + ot ); - print( t & ot ); - print( CStr(ot) + " & t" ); - print( ot & t ); - print( "t | " + ot ); - print( t | ot ); - print( CStr(ot) + " | t" ); - print( ot | t ); - print( "t ^ " + ot ); - print( t ^ ot ); - print( CStr(ot) + " ^ t" ); - print( ot ^ t ); - print( "t << " + ot ); - print( t << ot ); - print( CStr(ot) + " << t" ); - print( ot << t ); - print( "t >> " + ot ); - print( t >> ot ); - print( CStr(ot) + " >> t" ); - print( ot >> t ); + // bitwise + print( "t & " + ot ); + print( t & ot ); + print( CStr( ot ) + " & t" ); + print( ot & t ); + print( "t | " + ot ); + print( t | ot ); + print( CStr( ot ) + " | t" ); + print( ot | t ); + print( "t ^ " + ot ); + print( t ^ ot ); + print( CStr( ot ) + " ^ t" ); + print( ot ^ t ); + print( "t << " + ot ); + print( t << ot ); + print( CStr( ot ) + " << t" ); + print( ot << t ); + print( "t >> " + ot ); + print( t >> ot ); + print( CStr( ot ) + " >> t" ); + print( ot >> t ); - // member - tmp := t; - print( "tmp .+ " + ot ); - tmp .+ ot; - print( tmp ); - tmp := t; - print( "tmp .- " + ot ); - tmp .- ot; - print( tmp ); - tmp := t; + // member + tmp := t; + print( "tmp .+ " + ot ); + tmp.+ot; + print( tmp ); + tmp := t; + print( "tmp .- " + ot ); + tmp.-ot; + print( tmp ); + tmp := t; - // subscript - print( "t[" + ot + "]" ); - print( t[ot] ); + // subscript + print( "t[" + ot + "]" ); + print( t[ot] ); - print(sep); + print( sep ); endforeach // Unary operators print( "~ t" ); -print( ~ t ); -print(sep); +print( ~t ); +print( sep ); // Cast -print(CAsc(t)); -print(CAscZ(t)); -print(CChr(t)); -print(CChrZ(t)); -print(CDbl(t)); -print(CInt(t)); -print(CStr(t)); -print(sep); +print( CAsc( t ) ); +print( CAscZ( t ) ); +print( CChr( t ) ); +print( CChrZ( t ) ); +print( CDbl( t ) ); +print( CInt( t ) ); +print( CStr( t ) ); +print( sep ); // substring -print(t[0,1]); -print(t[1,99]); -print(t[1,0]); -print(t[1,10]); -print(t[2,2]); -print(t["ll"]); +print( t[0, 1] ); +print( t[1, 99] ); +print( t[1, 0] ); +print( t[1, 10] ); +print( t[2, 2] ); +print( t["ll"] ); var tmp := t; tmp["ll"] := "__"; -print(tmp); -print(sep); +print( tmp ); +print( sep ); // is true -if( t ) - print("t is true"); +if ( t ) + print( "t is true" ); else - print("t is false"); + print( "t is false" ); endif -if( "" ) - print("\"\" is true"); +if ( "" ) + print( "\"\" is true" ); else - print("\"\" is false"); + print( "\"\" is false" ); endif -if( "0" ) - print("0 is true"); +if ( "0" ) + print( "0 is true" ); else - print("0 is false"); + print( "0 is false" ); endif -print(sep); +print( sep ); // manipulation functions -print( Compare(t, "bello", 2, 3, 2, 3) ); -print( Find(t, "ll", 1) ); -print( Len(t) ); -print( Lower("HeLlo") ); -print( SplitWords("123 456 789", " ", 1) ); -print( StrReplace(t, "ll", "__") ); -print( SubStr(t, 2, 2) ); -print( SubStrReplace(t, "XXXXXX", 2, 3) ); -print( Trim(" hello ") ); -print( Upper(t) ); -print(sep); +print( Compare( t, "bello", 2, 3, 2, 3 ) ); +print( Find( t, "ll", 1 ) ); +print( Len( t ) ); +print( Lower( "HeLlo" ) ); +print( SplitWords( "123 456 789", " ", 1 ) ); +print( StrReplace( t, "ll", "__" ) ); +print( SubStr( t, 2, 2 ) ); +print( SubStrReplace( t, "XXXXXX", 2, 3 ) ); +print( Trim( " hello " ) ); +print( Upper( t ) ); +print( sep ); // methods print( t.length() ); -print(t); -print(t.find("e")); -print(t.upper()); -print(t.lower()); -print("{:x}".format(10)); -print("{:#x}".format(10)); -print("You have {} gold coins".format(120)); -print("{} hits {} for {} of damage".format("John", "Bob", 120)); -print("You hit {2} for {1} damage".format(120, "John Doe")); -print("Spell {1.spell_name} requires reagents: {1.reagents}".format(struct{spell_name:="Fire Wrath", reagents:="Ba, Bm, Ga"})); -print("{name} you hit level {level}".format(struct{name:="Jane Doe", level:=4})); -print(sep); +print( t ); +print( t.find( "e" ) ); +print( t.upper() ); +print( t.lower() ); +print( "{:x}".format( 10 ) ); +print( "{:#x}".format( 10 ) ); +print( "You have {} gold coins".format( 120 ) ); +print( "{} hits {} for {} of damage".format( "John", "Bob", 120 ) ); +print( "You hit {2} for {1} damage".format( 120, "John Doe" ) ); +print( "Spell {1.spell_name} requires reagents: {1.reagents}".format( struct{ spell_name := "Fire Wrath", + reagents := "Ba, Bm, Ga" } + ) ); +print( "{name} you hit level {level}".format( struct{ name := "Jane Doe", level := 4 } ) ); +print( sep ); // check that t is unaltered -print(t); +print( t ); diff --git a/testsuite/escript/string/string21.src b/testsuite/escript/string/string21.src index ad2ff31c9..cce60bb83 100644 --- a/testsuite/escript/string/string21.src +++ b/testsuite/escript/string/string21.src @@ -1 +1 @@ -print("{0}".format("hello")); +print( "{0}".format( "hello" ) ); diff --git a/testsuite/escript/string/string22.src b/testsuite/escript/string/string22.src index 33c7dddee..f6c453056 100644 --- a/testsuite/escript/string/string22.src +++ b/testsuite/escript/string/string22.src @@ -1 +1 @@ -print(Compare("\\", "\\")); +print( Compare( "\\", "\\" ) ); diff --git a/testsuite/escript/string/string23.src b/testsuite/escript/string/string23.src index 350883a15..77c0de19b 100644 --- a/testsuite/escript/string/string23.src +++ b/testsuite/escript/string/string23.src @@ -1,2 +1,2 @@ -print(Len(SplitWords("1 -2"))); +print( Len( SplitWords( "1 +2" ) ) ); diff --git a/testsuite/escript/struct/struct.src b/testsuite/escript/struct/struct.src index 9df65e317..3a6963f58 100644 --- a/testsuite/escript/struct/struct.src +++ b/testsuite/escript/struct/struct.src @@ -1,4 +1,4 @@ -var a :=array{}, b; +var a := array{}, b; a.+name; a.+value; @@ -26,13 +26,13 @@ a.name := "x"; a.value := 42; b := a; -print(b); +print( b ); b.value := "b's value"; -print(a.name); -print( a.value); -print( a.test); -print( b.name); -print( b.value); -print( b.test); +print( a.name ); +print( a.value ); +print( a.test ); +print( b.name ); +print( b.value ); +print( b.test ); diff --git a/testsuite/escript/struct/struct002.src b/testsuite/escript/struct/struct002.src index d81155f7b..2e625895d 100644 --- a/testsuite/escript/struct/struct002.src +++ b/testsuite/escript/struct/struct002.src @@ -27,13 +27,13 @@ a.name := "x"; a.value := 42; b := a; -print(b); +print( b ); b.value := "b's value"; -print(a.name); -print( a.value); -print( a.test); -print( b.name); -print( b.value); -print( b.test); +print( a.name ); +print( a.value ); +print( a.test ); +print( b.name ); +print( b.value ); +print( b.test ); diff --git a/testsuite/escript/struct/struct003.src b/testsuite/escript/struct/struct003.src index 1982703bc..8ccfe7499 100644 --- a/testsuite/escript/struct/struct003.src +++ b/testsuite/escript/struct/struct003.src @@ -4,4 +4,4 @@ a.+name; a.name := "x"; -print(a); +print( a ); diff --git a/testsuite/escript/struct/struct004.src b/testsuite/escript/struct/struct004.src index 71b71b5d2..f4c7cfb48 100644 --- a/testsuite/escript/struct/struct004.src +++ b/testsuite/escript/struct/struct004.src @@ -1,5 +1,5 @@ var a := struct; var b := a; -print(a); -print(b); +print( a ); +print( b ); diff --git a/testsuite/escript/struct/struct005.src b/testsuite/escript/struct/struct005.src index ef9e74631..34086ed42 100644 --- a/testsuite/escript/struct/struct005.src +++ b/testsuite/escript/struct/struct005.src @@ -1,8 +1,8 @@ program foo() - var d := 57+8, e := "abc"; - var t := struct{ a, b, c }; - t.a := 5; - print(t); + var d := 57 + 8, e := "abc"; + var t := struct{ a, b, c }; + t.a := 5; + print( t ); endprogram diff --git a/testsuite/escript/struct/struct006.src b/testsuite/escript/struct/struct006.src index 7b9fc919e..3e96ebd56 100644 --- a/testsuite/escript/struct/struct006.src +++ b/testsuite/escript/struct/struct006.src @@ -1,3 +1,3 @@ var a := struct; a.+b := 6; -print(a); +print( a ); diff --git a/testsuite/escript/struct/struct007.src b/testsuite/escript/struct/struct007.src index 62f1ea693..be7ca6663 100644 --- a/testsuite/escript/struct/struct007.src +++ b/testsuite/escript/struct/struct007.src @@ -1,7 +1,7 @@ program foo() - var t := struct{ a, b := 7, c := "abc" }; - t.a := 5; - print(t); + var t := struct{ a, b := 7, c := "abc" }; + t.a := 5; + print( t ); endprogram diff --git a/testsuite/escript/struct/struct008.src b/testsuite/escript/struct/struct008.src index b762cdee6..cd5cfae6f 100644 --- a/testsuite/escript/struct/struct008.src +++ b/testsuite/escript/struct/struct008.src @@ -1,11 +1,11 @@ function bar( r ) - return r*3; + return r * 3; endfunction program foo() - var t := struct{ a, b := struct { f := 6+7, g := bar(6), h := "xyz" }, c := "abc" }; - t.a := 5; - print(t); + var t := struct{ a, b := struct{ f := 6 + 7, g := bar( 6 ), h := "xyz" }, c := "abc" }; + t.a := 5; + print( t ); endprogram diff --git a/testsuite/escript/struct/struct009.src b/testsuite/escript/struct/struct009.src index 49a4d6a8d..ab85aed77 100644 --- a/testsuite/escript/struct/struct009.src +++ b/testsuite/escript/struct/struct009.src @@ -1,11 +1,11 @@ program foo() - var d := 57+8, e := "abc"; - var t := struct{ a:=4, b:=9, c:=12 }; - - print( t["b"] ); - print( t["B"] ); - t[ "c" ] := 42; - print(t); + var d := 57 + 8, e := "abc"; + var t := struct{ a := 4, b := 9, c := 12 }; + + print( t["b"] ); + print( t["B"] ); + t["c"] := 42; + print( t ); endprogram diff --git a/testsuite/escript/struct/struct010.src b/testsuite/escript/struct/struct010.src index 64d3b18ae..7fc429175 100644 --- a/testsuite/escript/struct/struct010.src +++ b/testsuite/escript/struct/struct010.src @@ -1,11 +1,11 @@ program foo() - var d := 57+8, e := "abc"; - var t := struct{ a:=4, b:=9, c:=12 }; - - print( t["b"] ); - print( t[2] ); // this should die - t[ "c" ] := 42; - print(t); + var d := 57 + 8, e := "abc"; + var t := struct{ a := 4, b := 9, c := 12 }; + + print( t["b"] ); + print( t[2] ); // this should die + t["c"] := 42; + print( t ); endprogram diff --git a/testsuite/escript/struct/struct011.src b/testsuite/escript/struct/struct011.src index 1b9eebeff..458dcc9dd 100644 --- a/testsuite/escript/struct/struct011.src +++ b/testsuite/escript/struct/struct011.src @@ -1,16 +1,16 @@ program foo() - var i:=1; - var s1 := struct{i:=i}; - var s2 := struct{}; - var s3 := struct{}; - var s4 := struct{}; - s2.+i := i; - s3.insert("i",i); - s4["i"]:=i; - i+=1; - print(i); - print(s1); // structs should not change - print(s2); - print(s3); - print(s4); + var i := 1; + var s1 := struct{ i := i }; + var s2 := struct{}; + var s3 := struct{}; + var s4 := struct{}; + s2.+i := i; + s3.insert( "i", i ); + s4["i"] := i; + i += 1; + print( i ); + print( s1 ); // structs should not change + print( s2 ); + print( s3 ); + print( s4 ); endprogram diff --git a/testsuite/escript/substr/substr01.src b/testsuite/escript/substr/substr01.src index e379b63c2..de4b714ee 100644 --- a/testsuite/escript/substr/substr01.src +++ b/testsuite/escript/substr/substr01.src @@ -1,4 +1,4 @@ var a := "abcdef"; -print(a); -a[2,3] := "zyx"; -print(a); \ No newline at end of file +print( a ); +a[2, 3] := "zyx"; +print( a ); diff --git a/testsuite/escript/substr/substr02.src b/testsuite/escript/substr/substr02.src index 75c5bf029..23c65bbf0 100644 --- a/testsuite/escript/substr/substr02.src +++ b/testsuite/escript/substr/substr02.src @@ -1,4 +1,4 @@ var a := "abcdef"; -print(a); +print( a ); a[2] := "zyx"; -print(a); \ No newline at end of file +print( a ); diff --git a/testsuite/escript/substr/substr03.src b/testsuite/escript/substr/substr03.src index 8301d728a..844d2102d 100644 --- a/testsuite/escript/substr/substr03.src +++ b/testsuite/escript/substr/substr03.src @@ -1,7 +1,7 @@ program textcmd_test( who ) - var props := "0x1001"; - Print("Props --> "+Props); - var tmp := props[3,1]; - Print("Props --> "+Props); - Print("Tmp --> "+tmp); -Endprogram + var props := "0x1001"; + Print( "Props --> " + Props ); + var tmp := props[3, 1]; + Print( "Props --> " + Props ); + Print( "Tmp --> " + tmp ); +endprogram diff --git a/testsuite/escript/substr/substr04.src b/testsuite/escript/substr/substr04.src index bed29770a..f1672829f 100644 --- a/testsuite/escript/substr/substr04.src +++ b/testsuite/escript/substr/substr04.src @@ -1,8 +1,8 @@ program textcmd_test( who ) - var props := "0x1001"; - Print("Props --> "+Props); - var tmp; - tmp := props[3,1]; - Print("Props --> "+Props); - Print("Tmp --> "+tmp); -Endprogram + var props := "0x1001"; + Print( "Props --> " + Props ); + var tmp; + tmp := props[3, 1]; + Print( "Props --> " + Props ); + Print( "Tmp --> " + tmp ); +endprogram diff --git a/testsuite/escript/sw/sw001.src b/testsuite/escript/sw/sw001.src index f14998379..b69f89373 100644 --- a/testsuite/escript/sw/sw001.src +++ b/testsuite/escript/sw/sw001.src @@ -1,8 +1,8 @@ program test() - var x := ""; - foreach a in SplitWords(x) - print("A: " + a); - endforeach - print("finished"); -endprogram \ No newline at end of file + var x := ""; + foreach a in SplitWords( x ) + print( "A: " + a ); + endforeach + print( "finished" ); +endprogram diff --git a/testsuite/escript/sw/sw002.src b/testsuite/escript/sw/sw002.src index 50e3a80ee..d1e2a724a 100644 --- a/testsuite/escript/sw/sw002.src +++ b/testsuite/escript/sw/sw002.src @@ -1,7 +1,7 @@ program test() - var x := "hello"; - foreach a in SplitWords(x) - print("A: " + a); - endforeach -endprogram \ No newline at end of file + var x := "hello"; + foreach a in SplitWords( x ) + print( "A: " + a ); + endforeach +endprogram diff --git a/testsuite/escript/sw/sw003.src b/testsuite/escript/sw/sw003.src index e7dc4551d..7a0a3a473 100644 --- a/testsuite/escript/sw/sw003.src +++ b/testsuite/escript/sw/sw003.src @@ -1,7 +1,7 @@ program test() - var x := "hello world again,blah"; - foreach a in SplitWords(x) - print("A: " + a); - endforeach -endprogram \ No newline at end of file + var x := "hello world again,blah"; + foreach a in SplitWords( x ) + print( "A: " + a ); + endforeach +endprogram diff --git a/testsuite/escript/sw/sw004.src b/testsuite/escript/sw/sw004.src index becc1427c..0ae669c2b 100644 --- a/testsuite/escript/sw/sw004.src +++ b/testsuite/escript/sw/sw004.src @@ -1,19 +1,19 @@ program test() - var x := "hello world again,blah three four,blah"; - foreach a in SplitWords(x) - print("A: '" + a + "'"); - endforeach - - foreach a in SplitWords(x,",") - print("B: '" + a + "'"); - endforeach - - foreach a in SplitWords(x,max_split:=2) - print("C: '" + a + "'"); - endforeach - - foreach a in SplitWords(x,",",1) - print("D: '" + a + "'"); - endforeach -endprogram \ No newline at end of file + var x := "hello world again,blah three four,blah"; + foreach a in SplitWords( x ) + print( "A: '" + a + "'" ); + endforeach + + foreach a in SplitWords( x, "," ) + print( "B: '" + a + "'" ); + endforeach + + foreach a in SplitWords( x, max_split := 2 ) + print( "C: '" + a + "'" ); + endforeach + + foreach a in SplitWords( x, ",", 1 ) + print( "D: '" + a + "'" ); + endforeach +endprogram diff --git a/testsuite/escript/switch/switch01.src b/testsuite/escript/switch/switch01.src index f8a1e77e9..87b391468 100644 --- a/testsuite/escript/switch/switch01.src +++ b/testsuite/escript/switch/switch01.src @@ -1,12 +1,9 @@ -// switch01 -// +// switch01 +// var a := 5; -case (a) - 4: - print( "four" ); - 5: - print( "five" ); - 6: - print( "six" ); +case ( a ) + 4: print( "four" ); + 5: print( "five" ); + 6: print( "six" ); endcase diff --git a/testsuite/escript/switch/switch02.src b/testsuite/escript/switch/switch02.src index 989c10857..8908e43d3 100644 --- a/testsuite/escript/switch/switch02.src +++ b/testsuite/escript/switch/switch02.src @@ -1,14 +1,11 @@ // switch02 -// +// var a := 7; -case (a) - 4: - print( "four" ); - 5: - print( "five" ); - 6: - print( "six" ); +case ( a ) + 4: print( "four" ); + 5: print( "five" ); + 6: print( "six" ); endcase -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch03.src b/testsuite/escript/switch/switch03.src index 4b7f232b0..040fcc545 100644 --- a/testsuite/escript/switch/switch03.src +++ b/testsuite/escript/switch/switch03.src @@ -1,16 +1,12 @@ // switch02 -// +// var a := 7; -case (a) - 4: - print( "four" ); - 5: - print( "five" ); - 6: - print( "six" ); - default: - print( "none of the above" ); +case ( a ) + 4: print( "four" ); + 5: print( "five" ); + 6: print( "six" ); + default: print( "none of the above" ); endcase -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch04.src b/testsuite/escript/switch/switch04.src index 8274faf62..d24bbbae4 100644 --- a/testsuite/escript/switch/switch04.src +++ b/testsuite/escript/switch/switch04.src @@ -1,16 +1,12 @@ // switch02 -// +// var a := "hello"; -case (a) - "abc": - print( "first" ); - "hello": - print( "second" ); - "def": - print( "third" ); - default: - print( "none of the above" ); +case ( a ) + "abc": print( "first" ); + "hello": print( "second" ); + "def": print( "third" ); + default: print( "none of the above" ); endcase -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch05.src b/testsuite/escript/switch/switch05.src index 39f04fc06..afda56853 100644 --- a/testsuite/escript/switch/switch05.src +++ b/testsuite/escript/switch/switch05.src @@ -1,16 +1,12 @@ // switch02 -// +// var a := "hello world"; -case (a) - "abc": - print( "first" ); - "hello": - print( "second" ); - "def": - print( "third" ); - default: - print( "none of the above" ); +case ( a ) + "abc": print( "first" ); + "hello": print( "second" ); + "def": print( "third" ); + default: print( "none of the above" ); endcase -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch06.src b/testsuite/escript/switch/switch06.src index 8ed7eecc7..5f6be6cdb 100644 --- a/testsuite/escript/switch/switch06.src +++ b/testsuite/escript/switch/switch06.src @@ -1,5 +1,5 @@ // switch06 -// +// var a array; a[1] := "hello"; @@ -8,12 +8,12 @@ a[3] := "again"; a[4] := "there"; foreach elem in a - case( elem ) - "world": continue; // this should continue the FOREACH - "again": break; // this should exit the CASE - default: print( "case element: " + elem ); - endcase + case ( elem ) + "world": continue; // this should continue the FOREACH + "again": break; // this should exit the CASE + default: print( "case element: " + elem ); + endcase - print( "element: " + elem ); + print( "element: " + elem ); endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch07.src b/testsuite/escript/switch/switch07.src index 8ed7eecc7..5f6be6cdb 100644 --- a/testsuite/escript/switch/switch07.src +++ b/testsuite/escript/switch/switch07.src @@ -1,5 +1,5 @@ // switch06 -// +// var a array; a[1] := "hello"; @@ -8,12 +8,12 @@ a[3] := "again"; a[4] := "there"; foreach elem in a - case( elem ) - "world": continue; // this should continue the FOREACH - "again": break; // this should exit the CASE - default: print( "case element: " + elem ); - endcase + case ( elem ) + "world": continue; // this should continue the FOREACH + "again": break; // this should exit the CASE + default: print( "case element: " + elem ); + endcase - print( "element: " + elem ); + print( "element: " + elem ); endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch08.src b/testsuite/escript/switch/switch08.src index ae675a8e6..d2e677853 100644 --- a/testsuite/escript/switch/switch08.src +++ b/testsuite/escript/switch/switch08.src @@ -1,17 +1,16 @@ // switch06 -// +// function foo( p ) - case (p) - 4: return "four"; - 5: return "five"; - "fourteen": return 14; - "thirteen": return 13; - default: return "NOTA: " + p; - endcase + case ( p ) + 4: return "four"; + 5: return "five"; + "fourteen": return 14; + "thirteen": return 13; + default: return "NOTA: " + p; + endcase endfunction - print( foo( 1 ) ); print( foo( 4 ) ); print( foo( "thirteen" ) ); diff --git a/testsuite/escript/switch/switch09.src b/testsuite/escript/switch/switch09.src index ca1abd99e..dd348e301 100644 --- a/testsuite/escript/switch/switch09.src +++ b/testsuite/escript/switch/switch09.src @@ -1,18 +1,18 @@ // switch06 -// +// function foo2( p ) - case (p) - 4: return "four"; - 5: return "five"; - "fourteen": return 14; - "thirteen": return 13; - default: return "NOTA: " + p; - endcase + case ( p ) + 4: return "four"; + 5: return "five"; + "fourteen": return 14; + "thirteen": return 13; + default: return "NOTA: " + p; + endcase endfunction function foo( p ) - return "p " + foo2(p) + " d"; + return "p " + foo2( p ) + " d"; endfunction print( foo( 1 ) ); diff --git a/testsuite/escript/switch/switch10.src b/testsuite/escript/switch/switch10.src index b4b5f6a4a..333efd472 100644 --- a/testsuite/escript/switch/switch10.src +++ b/testsuite/escript/switch/switch10.src @@ -1,15 +1,15 @@ // switch06 -// +// const CVAL := 4; function foo( p ) - case (p) - CVAL: return "[CVAL]"; - 5: return "five"; - "fourteen": return 14; - "thirteen": return 13; - default: return "NOTA: " + p; - endcase + case ( p ) + CVAL: return "[CVAL]"; + 5: return "five"; + "fourteen": return 14; + "thirteen": return 13; + default: return "NOTA: " + p; + endcase endfunction print( foo( CVAL ) ); diff --git a/testsuite/escript/switch/switch11.src b/testsuite/escript/switch/switch11.src index b80606705..33185d407 100644 --- a/testsuite/escript/switch/switch11.src +++ b/testsuite/escript/switch/switch11.src @@ -1,11 +1,11 @@ // switch11 -// +// function foo( p ) - case (p) - 4: return "four"; - default: - endcase + case ( p ) + 4: return "four"; + default: + endcase endfunction print( foo( 1 ) ); diff --git a/testsuite/escript/switch/switch12.src b/testsuite/escript/switch/switch12.src index 8ed7eecc7..5f6be6cdb 100644 --- a/testsuite/escript/switch/switch12.src +++ b/testsuite/escript/switch/switch12.src @@ -1,5 +1,5 @@ // switch06 -// +// var a array; a[1] := "hello"; @@ -8,12 +8,12 @@ a[3] := "again"; a[4] := "there"; foreach elem in a - case( elem ) - "world": continue; // this should continue the FOREACH - "again": break; // this should exit the CASE - default: print( "case element: " + elem ); - endcase + case ( elem ) + "world": continue; // this should continue the FOREACH + "again": break; // this should exit the CASE + default: print( "case element: " + elem ); + endcase - print( "element: " + elem ); + print( "element: " + elem ); endforeach -print( "done" ); \ No newline at end of file +print( "done" ); diff --git a/testsuite/escript/switch/switch13.src b/testsuite/escript/switch/switch13.src index c686dc175..333efd472 100644 --- a/testsuite/escript/switch/switch13.src +++ b/testsuite/escript/switch/switch13.src @@ -1,15 +1,15 @@ // switch06 -// +// const CVAL := 4; function foo( p ) - case (p) - CVAL: return "[CVAL]"; - 5 : return "five"; - "fourteen" : return 14; - "thirteen" : return 13; - default: return "NOTA: " + p; - endcase + case ( p ) + CVAL: return "[CVAL]"; + 5: return "five"; + "fourteen": return 14; + "thirteen": return 13; + default: return "NOTA: " + p; + endcase endfunction print( foo( CVAL ) ); diff --git a/testsuite/escript/switch/switch14.src b/testsuite/escript/switch/switch14.src index 8ab408c40..9c9631aef 100644 --- a/testsuite/escript/switch/switch14.src +++ b/testsuite/escript/switch/switch14.src @@ -1,7 +1,7 @@ program test() - var uselessvar := 1; - case (uselessvar) - 1: var testvar; break; - endcase + var uselessvar := 1; + case ( uselessvar ) + 1: var testvar; break; + endcase print( "end" ); endprogram diff --git a/testsuite/escript/switch/switch15.src b/testsuite/escript/switch/switch15.src index 89150ed64..804f684cc 100644 --- a/testsuite/escript/switch/switch15.src +++ b/testsuite/escript/switch/switch15.src @@ -1,9 +1,8 @@ program test() - var a := 1; - case (a) - 1: var b,c; - break; - default: break; - endcase - print("done"); + var a := 1; + case ( a ) + 1: var b, c; break; + default: break; + endcase + print( "done" ); endprogram diff --git a/testsuite/escript/switch/switch16-negative-case.err b/testsuite/escript/switch/switch16-negative-case.err index 4d184da83..8e7425a7a 100644 --- a/testsuite/escript/switch/switch16-negative-case.err +++ b/testsuite/escript/switch/switch16-negative-case.err @@ -1 +1 @@ -switch16-negative-case.src:8:9: error: mismatched input ':' expecting ';' \ No newline at end of file +:8:9: error: mismatched input ':' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/switch/switch16.src b/testsuite/escript/switch/switch16.src index af3080852..f2f7b72e6 100644 --- a/testsuite/escript/switch/switch16.src +++ b/testsuite/escript/switch/switch16.src @@ -5,24 +5,24 @@ const CONST_false := false; const CONST_uninit := uninit; const CONST_string := "string"; -foreach value in array{1, 0, true, false, uninit, "string", struct{} } - case(value) - 1: print("Got 1"); - 0: print("Got 0"); - true: print("Got true"); - false: print("Got false"); - uninit: print("Got uninit"); - "string": print("Got string"); - default: print("Got default"); +foreach value in array{ 1, 0, true, false, uninit, "string", struct{} } + case ( value ) + 1: print( "Got 1" ); + 0: print( "Got 0" ); + true: print( "Got true" ); + false: print( "Got false" ); + uninit: print( "Got uninit" ); + "string": print( "Got string" ); + default: print( "Got default" ); endcase - case(value) - CONST_1: print("Got 1"); - CONST_0: print("Got 0"); - CONST_true: print("Got true"); - CONST_false: print("Got false"); - CONST_uninit: print("Got uninit"); - CONST_string: print("Got string"); - default: print("Got default"); + case ( value ) + CONST_1: print( "Got 1" ); + CONST_0: print( "Got 0" ); + CONST_true: print( "Got true" ); + CONST_false: print( "Got false" ); + CONST_uninit: print( "Got uninit" ); + CONST_string: print( "Got string" ); + default: print( "Got default" ); endcase endforeach diff --git a/testsuite/escript/switch/switch17-duplicate-default.err b/testsuite/escript/switch/switch17-duplicate-default.err index 757193da1..fa76ce9df 100644 --- a/testsuite/escript/switch/switch17-duplicate-default.err +++ b/testsuite/escript/switch/switch17-duplicate-default.err @@ -1 +1 @@ -switch17-duplicate-default.src:5:5: error: case statement already has a default clause. \ No newline at end of file +:4:3: error: case statement already has a default clause. \ No newline at end of file diff --git a/testsuite/escript/switch/switch17-duplicate-default.src b/testsuite/escript/switch/switch17-duplicate-default.src index 1456cadc3..a162e0faf 100644 --- a/testsuite/escript/switch/switch17-duplicate-default.src +++ b/testsuite/escript/switch/switch17-duplicate-default.src @@ -1,7 +1,5 @@ var x; -case (x) - default: - print("first"); - default: - print("second"); -endcase \ No newline at end of file +case ( x ) + default: print( "first" ); + default: print( "second" ); +endcase diff --git a/testsuite/escript/switch/switch18-duplicate-string.err b/testsuite/escript/switch/switch18-duplicate-string.err index 2fdb9876a..e0617a8d0 100644 --- a/testsuite/escript/switch/switch18-duplicate-string.err +++ b/testsuite/escript/switch/switch18-duplicate-string.err @@ -1 +1 @@ -switch18-duplicate-string.src:5:5: error: case statement already has a selector for string value "abc". \ No newline at end of file +:4:3: error: case statement already has a selector for string value "abc". \ No newline at end of file diff --git a/testsuite/escript/switch/switch18-duplicate-string.src b/testsuite/escript/switch/switch18-duplicate-string.src index 7ee05fff7..f75dc9ea4 100644 --- a/testsuite/escript/switch/switch18-duplicate-string.src +++ b/testsuite/escript/switch/switch18-duplicate-string.src @@ -1,13 +1,11 @@ var x; -case (x) - "abc": - print("first"); - "abc": - print("second"); +case ( x ) + "abc": print( "first" ); + "abc": print( "second" ); endcase // The OG compiler does not detect the above as an error. function foo() - a; + a; endfunction foo(); diff --git a/testsuite/escript/switch/switch19-duplicate-integer.err b/testsuite/escript/switch/switch19-duplicate-integer.err index 310a81c1e..5b7bbbc01 100644 --- a/testsuite/escript/switch/switch19-duplicate-integer.err +++ b/testsuite/escript/switch/switch19-duplicate-integer.err @@ -1 +1 @@ -switch19-duplicate-integer.src:5:5: error: case statement already has a selector for integer value 7. \ No newline at end of file +:4:3: error: case statement already has a selector for integer value 7. \ No newline at end of file diff --git a/testsuite/escript/switch/switch19-duplicate-integer.src b/testsuite/escript/switch/switch19-duplicate-integer.src index 262988163..31d47599e 100644 --- a/testsuite/escript/switch/switch19-duplicate-integer.src +++ b/testsuite/escript/switch/switch19-duplicate-integer.src @@ -1,13 +1,11 @@ var x; -case (x) - 7: - print("first"); - 7: - print("second"); +case ( x ) + 7: print( "first" ); + 7: print( "second" ); endcase // The OG compiler does not detect the above as an error. function foo() - a; + a; endfunction foo(); diff --git a/testsuite/escript/syntax/syntax01.err b/testsuite/escript/syntax/syntax01.err index 8df0005a5..2e72f27d7 100644 --- a/testsuite/escript/syntax/syntax01.err +++ b/testsuite/escript/syntax/syntax01.err @@ -1 +1 @@ -syntax01.src:1:12: error: missing ';' at 'array' \ No newline at end of file +:1:12: error: missing ';' at 'array' \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax02.err b/testsuite/escript/syntax/syntax02.err index 149fef9e2..e627652f1 100644 --- a/testsuite/escript/syntax/syntax02.err +++ b/testsuite/escript/syntax/syntax02.err @@ -1 +1 @@ -Expected expression following comma before right-brace in struct initializer list \ No newline at end of file +:1:26: error: Expected expression following comma before right-brace in struct initializer list \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax03.err b/testsuite/escript/syntax/syntax03.err index 4b516ef93..7f9ef9fe5 100644 --- a/testsuite/escript/syntax/syntax03.err +++ b/testsuite/escript/syntax/syntax03.err @@ -1 +1 @@ -Expected expression following comma before right-brace in dictionary initializer list \ No newline at end of file +:1:34: error: Expected expression following comma before right-brace in dictionary initializer list \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax04.err b/testsuite/escript/syntax/syntax04.err index 646106f92..58e93d5ed 100644 --- a/testsuite/escript/syntax/syntax04.err +++ b/testsuite/escript/syntax/syntax04.err @@ -1 +1 @@ -Expected expression following comma before right-brace in array initializer list \ No newline at end of file +:1:18: error: Expected expression following comma before right-brace in array initializer list \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax05.err b/testsuite/escript/syntax/syntax05.err index 1f20c33b5..bdbb8f2e9 100644 --- a/testsuite/escript/syntax/syntax05.err +++ b/testsuite/escript/syntax/syntax05.err @@ -1 +1 @@ -syntax05.src:1:23: error: Expected expression following comma before right-paren in array initializer list \ No newline at end of file +:1:23: error: Expected expression following comma before right-paren in array initializer list \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax06.err b/testsuite/escript/syntax/syntax06.err index 5563f00a6..d57928d24 100644 --- a/testsuite/escript/syntax/syntax06.err +++ b/testsuite/escript/syntax/syntax06.err @@ -1 +1 @@ -syntax06.src:1:17: error: extraneous input '+' expecting ';' \ No newline at end of file +:1:17: error: extraneous input '+' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax07.err b/testsuite/escript/syntax/syntax07.err index 0ff647b24..0c9dc0b7e 100644 --- a/testsuite/escript/syntax/syntax07.err +++ b/testsuite/escript/syntax/syntax07.err @@ -1 +1 @@ -syntax07.src:3:7: error: mismatched input ';' expecting \ No newline at end of file +:3:7: error: mismatched input ';' expecting {'!', 'not', 'error', 'dictionary', 'struct', 'array', 'uninit', 'true', 'false', DECIMAL_LITERAL, HEX_LITERAL, OCT_LITERAL, BINARY_LITERAL, FLOAT_LITERAL, HEX_FLOAT_LITERAL, STRING_LITERAL, INTERPOLATED_STRING_START, '(', '{', '+', '-', '~', '@', '++', '--', IDENTIFIER} \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax08.src b/testsuite/escript/syntax/syntax08.src index 9f2c4b09b..9dd490058 100644 --- a/testsuite/escript/syntax/syntax08.src +++ b/testsuite/escript/syntax/syntax08.src @@ -1,5 +1,5 @@ var a; a := +a; -//2015-19-12 Bodom, this is not a syntax error, it's unary +, meanining noop -print(a); +// 2015-19-12 Bodom, this is not a syntax error, it's unary +, meanining noop +print( a ); diff --git a/testsuite/escript/syntax/syntax09.err b/testsuite/escript/syntax/syntax09.err index b20469079..2cf1667e4 100644 --- a/testsuite/escript/syntax/syntax09.err +++ b/testsuite/escript/syntax/syntax09.err @@ -1 +1 @@ -syntax09.src:1:16: error: no viable alternative at input '{ 4, +,' \ No newline at end of file +:1:16: error: no viable alternative at input '{ 4, +,' \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax10.err b/testsuite/escript/syntax/syntax10.err index 826eb9f23..348babf47 100644 --- a/testsuite/escript/syntax/syntax10.err +++ b/testsuite/escript/syntax/syntax10.err @@ -1 +1 @@ -syntax10.src:1:21: error: extraneous input '+' expecting ';' \ No newline at end of file +:1:21: error: extraneous input '+' expecting ';' \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax11-final-semi-required.err b/testsuite/escript/syntax/syntax11-final-semi-required.err index c328836c4..ced8a5fe1 100644 --- a/testsuite/escript/syntax/syntax11-final-semi-required.err +++ b/testsuite/escript/syntax/syntax11-final-semi-required.err @@ -1 +1 @@ -syntax11-final-semi-required.src:2:1: error: missing ';' at '' \ No newline at end of file +:2:1: error: missing ';' at '' \ No newline at end of file diff --git a/testsuite/escript/syntax/syntax12-unterminated-expression.err b/testsuite/escript/syntax/syntax12-unterminated-expression.err index 0fcae05fc..aa3ea9a63 100644 --- a/testsuite/escript/syntax/syntax12-unterminated-expression.err +++ b/testsuite/escript/syntax/syntax12-unterminated-expression.err @@ -1 +1 @@ -syntax12-unterminated-expression.src:1:2: error: missing ';' at '' \ No newline at end of file +:1:2: error: missing ';' at '' \ No newline at end of file diff --git a/testsuite/escript/test/test.src b/testsuite/escript/test/test.src index 681cfb986..ab3d37308 100644 --- a/testsuite/escript/test/test.src +++ b/testsuite/escript/test/test.src @@ -1,59 +1,62 @@ -var a,b,c,d,e,p,r,ab, aab; +var a, b, c, d, e, p, r, ab, aab; -if (5 == 6) - print( "equal, ..."); +if ( 5 == 6 ) + print( "equal, ..." ); endif -IF ("TEST" == "TEST") then print( "Equal again!"); endif +if ( "TEST" == "TEST" ) then + print( "Equal again!" ); +endif PRINT( "Hello World!" ); -A:="TEST" + "STRING"; -PRINT("A="+A); +A := "TEST" + "STRING"; +PRINT( "A=" + A ); -B:="TEST" - "STRING"; -PRINT("B=" + B); +B := "TEST" - "STRING"; +PRINT( "B=" + B ); -C:=A - "TS"; -PRINT("C=" + C); +C := A - "TS"; +PRINT( "C=" + C ); -D:=A - "TEST"; -PRINT("D=" +D); +D := A - "TEST"; +PRINT( "D=" + D ); -E:=A - "ING"; -print("E=" + E); +E := A - "ING"; +print( "E=" + E ); -print( "A="+A); -IF ( 7==7+0 ) A := 6; endif -print( "A="+A); +print( "A=" + A ); +if ( 7 == 7 + 0 ) + A := 6; +endif +print( "A=" + A ); -A:=7; -A:="Hello"; -B:="Hello"; +A := 7; +A := "Hello"; +B := "Hello"; -AAb:=2; -A:=2; -C:=5; -D:=6; -P:=7; -R:=8; -if ( A == B ) +AAb := 2; +A := 2; +C := 5; +D := 6; +P := 7; +R := 8; +if ( A == B ) C := d; else - if (1) + if ( 1 ) R := P; else C := A; endif endif -print( A+" "+C+" "+D+" "+P+" "+R); -print( "hello world!"); -D := 5+7/(6+2); -C :=5; -A :=B+C; -AB :="HELLO AGAIN"; -print( AB); -print( D); -print( C); -print( A); -print( B); - +print( A + " " + C + " " + D + " " + P + " " + R ); +print( "hello world!" ); +D := 5 + 7 / ( 6 + 2 ); +C := 5; +A := B + C; +AB := "HELLO AGAIN"; +print( AB ); +print( D ); +print( C ); +print( A ); +print( B ); diff --git a/testsuite/escript/test/test2.src b/testsuite/escript/test/test2.src index 3cc3e4a23..65d81e2f1 100644 --- a/testsuite/escript/test/test2.src +++ b/testsuite/escript/test/test2.src @@ -1,4 +1,7 @@ -print( "hello world!"); -if (5 == 6) print( "equal, ..."); endif -if ("TEST"=="TEST") print("ah ha!"); endif - +print( "hello world!" ); +if ( 5 == 6 ) + print( "equal, ..." ); +endif +if ( "TEST" == "TEST" ) + print( "ah ha!" ); +endif diff --git a/testsuite/escript/test/test3.src b/testsuite/escript/test/test3.src index bba549b41..40c9d1d00 100644 --- a/testsuite/escript/test/test3.src +++ b/testsuite/escript/test/test3.src @@ -1 +1 @@ -print( "Hello" + " " + ("Hello" - "el")); +print( "Hello" + " " + ( "Hello" - "el" ) ); diff --git a/testsuite/escript/test/test6.src b/testsuite/escript/test/test6.src index 53296385b..dc839ff6c 100644 --- a/testsuite/escript/test/test6.src +++ b/testsuite/escript/test/test6.src @@ -1,9 +1,9 @@ -print( "this is a test script."); -print("This is really more correct,"); -print("But the parser is currently somewhat"); -print("flexible."); -print( "This kind of " + ("Thing" + " " + "is") + " trouble, though,"); -print( "because after the parser sees a left paren, it exits on the"); -print( "next one (if it is parsing a function)."); +print( "this is a test script." ); +print( "This is really more correct," ); +print( "But the parser is currently somewhat" ); +print( "flexible." ); +print( "This kind of " + ( "Thing" + " " + "is" ) + " trouble, though," ); +print( "because after the parser sees a left paren, it exits on the" ); +print( "next one (if it is parsing a function)." ); -print("This " + "is " + ("the correct fucking way" - " fucking") + " to do this."); +print( "This " + "is " + ( "the correct fucking way" - " fucking" ) + " to do this." ); diff --git a/testsuite/escript/test/testutil.inc b/testsuite/escript/test/testutil.inc index 594aff988..473bfde91 100644 --- a/testsuite/escript/test/testutil.inc +++ b/testsuite/escript/test/testutil.inc @@ -1,3 +1,3 @@ function foo( x ) - return "foo called with " + x; -endfunction \ No newline at end of file + return "foo called with " + x; +endfunction diff --git a/testsuite/escript/unicode/unicode01.src b/testsuite/escript/unicode/unicode01.src index 97731b324..5bc49f420 100644 --- a/testsuite/escript/unicode/unicode01.src +++ b/testsuite/escript/unicode/unicode01.src @@ -1,4 +1,4 @@ // This file contains invalid UTF8 characters and should fail to compile// but its valid ISO8859 -> fallback should work -//var i:=" àòùç"; -var i:=" àòùç"; +// var i:=" àòùç"; +var i := " àòùç"; diff --git a/testsuite/escript/unicode/unicode02.src b/testsuite/escript/unicode/unicode02.src index 4bbaca293..dad98720a 100644 --- a/testsuite/escript/unicode/unicode02.src +++ b/testsuite/escript/unicode/unicode02.src @@ -8,196 +8,200 @@ var t := "Ðè└└☺"; var sep := "―――――――――――――――――――――――――――――――――――――――――――――"; // pack/unpack -var p := Pack(t); +var p := Pack( t ); print( p ); -var u := Unpack(p); +var u := Unpack( p ); print( u ); print( u == t ); print( p != u ); -print(sep); +print( sep ); -var optests := array{ - "1234", "Ðè└└☺", "b", "ab", "a", "caterpillar", - array{ "α", "β", "γ", 19 }, - dictionary{ "ⅠⅡⅢⅣ" -> "ð„œð„ð„ž", "eeee" -> 0 } -}; +var optests := array{ "1234", + "Ðè└└☺", + "b", + "ab", + "a", + "caterpillar", array{ "α", "β", "γ", 19 }, + dictionary{ "ⅠⅡⅢⅣ" -> "ð„œð„ð„ž", "eeee" -> 0 } }; // Binary operators foreach ot in optests - var tmp; + var tmp; - // comparison - print( "t == " + ot ); - print( t == ot ); - print( CStr(ot) + " == t " ); - print( ot == t ); - print( "t != " + ot ); - print( t != ot ); - print( "t < " + ot ); - print( t < ot ); - print( "t <= " + ot ); - print( t <= ot ); - print( "t > " + ot ); - print( t > ot ); - print( "t >= " + ot ); - print( t >= ot ); + // comparison + print( "t == " + ot ); + print( t == ot ); + print( CStr( ot ) + " == t " ); + print( ot == t ); + print( "t != " + ot ); + print( t != ot ); + print( "t < " + ot ); + print( t < ot ); + print( "t <= " + ot ); + print( t <= ot ); + print( "t > " + ot ); + print( t > ot ); + print( "t >= " + ot ); + print( t >= ot ); - // arithmetic - print( "t + " + ot ); - print( t + ot ); - print( CStr(ot) + " + t" ); - print( ot + t ); - print( "t - " + ot ); - print( t - ot ); - print( CStr(ot) + " - t" ); - print( ot - t ); - print( "t * " + ot ); - print( t * ot ); - print( CStr(ot) + " * t" ); - print( ot * t ); - print( "t / " + ot ); - print( t / ot ); - print( CStr(ot) + " / t" ); - print( ot / t ); - print( "t % " + ot ); - print( t % ot ); - print( CStr(ot) + " % t" ); - print( ot % t ); + // arithmetic + print( "t + " + ot ); + print( t + ot ); + print( CStr( ot ) + " + t" ); + print( ot + t ); + print( "t - " + ot ); + print( t - ot ); + print( CStr( ot ) + " - t" ); + print( ot - t ); + print( "t * " + ot ); + print( t * ot ); + print( CStr( ot ) + " * t" ); + print( ot * t ); + print( "t / " + ot ); + print( t / ot ); + print( CStr( ot ) + " / t" ); + print( ot / t ); + print( "t % " + ot ); + print( t % ot ); + print( CStr( ot ) + " % t" ); + print( ot % t ); - // arithmetic with assignment - tmp := t; - print( "tmp += " + ot ); - tmp += ot; - print( tmp ); - tmp := t; - print( "tmp -= " + ot ); - tmp -= ot; - print( tmp ); - tmp := t; - print( "tmp *= " + ot ); - tmp *= ot; - print( tmp ); - tmp := t; - print( "tmp /= " + ot ); - tmp /= ot; - print( tmp ); - tmp := t; - print( "tmp %= " + ot ); - tmp %= ot; - print( tmp ); + // arithmetic with assignment + tmp := t; + print( "tmp += " + ot ); + tmp += ot; + print( tmp ); + tmp := t; + print( "tmp -= " + ot ); + tmp -= ot; + print( tmp ); + tmp := t; + print( "tmp *= " + ot ); + tmp *= ot; + print( tmp ); + tmp := t; + print( "tmp /= " + ot ); + tmp /= ot; + print( tmp ); + tmp := t; + print( "tmp %= " + ot ); + tmp %= ot; + print( tmp ); - // bitwise - print( "t & " + ot ); - print( t & ot ); - print( CStr(ot) + " & t" ); - print( ot & t ); - print( "t | " + ot ); - print( t | ot ); - print( CStr(ot) + " | t" ); - print( ot | t ); - print( "t ^ " + ot ); - print( t ^ ot ); - print( CStr(ot) + " ^ t" ); - print( ot ^ t ); - print( "t << " + ot ); - print( t << ot ); - print( CStr(ot) + " << t" ); - print( ot << t ); - print( "t >> " + ot ); - print( t >> ot ); - print( CStr(ot) + " >> t" ); - print( ot >> t ); + // bitwise + print( "t & " + ot ); + print( t & ot ); + print( CStr( ot ) + " & t" ); + print( ot & t ); + print( "t | " + ot ); + print( t | ot ); + print( CStr( ot ) + " | t" ); + print( ot | t ); + print( "t ^ " + ot ); + print( t ^ ot ); + print( CStr( ot ) + " ^ t" ); + print( ot ^ t ); + print( "t << " + ot ); + print( t << ot ); + print( CStr( ot ) + " << t" ); + print( ot << t ); + print( "t >> " + ot ); + print( t >> ot ); + print( CStr( ot ) + " >> t" ); + print( ot >> t ); - // member - tmp := t; - print( "tmp .+ " + ot ); - tmp .+ ot; - print( tmp ); - tmp := t; - print( "tmp .- " + ot ); - tmp .- ot; - print( tmp ); - tmp := t; + // member + tmp := t; + print( "tmp .+ " + ot ); + tmp.+ot; + print( tmp ); + tmp := t; + print( "tmp .- " + ot ); + tmp.-ot; + print( tmp ); + tmp := t; - // subscript - print( "t[" + ot + "]" ); - print( t[ot] ); + // subscript + print( "t[" + ot + "]" ); + print( t[ot] ); - print(sep); + print( sep ); endforeach // Unary operators print( "~ t" ); -print( ~ t ); -print(sep); +print( ~t ); +print( sep ); // Cast -print(CAsc(t)); -print(CAscZ(t)); -print(CChr(t)); -print(CChrZ(t)); -print(CDbl(t)); -print(CInt(t)); -print(CStr(t)); -print(sep); +print( CAsc( t ) ); +print( CAscZ( t ) ); +print( CChr( t ) ); +print( CChrZ( t ) ); +print( CDbl( t ) ); +print( CInt( t ) ); +print( CStr( t ) ); +print( sep ); // substring -print(t[0,1]); -print(t[1,99]); -print(t[1,0]); -print(t[1,10]); -print(t[2,2]); -print(t["└└"]); +print( t[0, 1] ); +print( t[1, 99] ); +print( t[1, 0] ); +print( t[1, 10] ); +print( t[2, 2] ); +print( t["└└"] ); var tmp := t; tmp["└└"] := "__"; -print(tmp); -print(sep); +print( tmp ); +print( sep ); // is true -if( t ) - print("t is true"); +if ( t ) + print( "t is true" ); else - print("t is false"); + print( "t is false" ); endif -if( "" ) - print("\"\" is true"); +if ( "" ) + print( "\"\" is true" ); else - print("\"\" is false"); + print( "\"\" is false" ); endif -if( "0" ) - print("0 is true"); +if ( "0" ) + print( "0 is true" ); else - print("0 is false"); + print( "0 is false" ); endif -print(sep); +print( sep ); // manipulation functions -print( Compare(t, "bè└└☺", 2, 3, 2, 3) ); -print( Find(t, "└└", 1) ); -print( Len(t) ); -print( Lower("Здраво!") ); -print( SplitWords("â… â…¡â…¢ 456 789", " ", 1) ); -print( StrReplace(t, "└└", "__") ); -print( SubStr(t, 2, 2) ); -print( SubStrReplace(t, "XXXXXX", 2, 3) ); -print( Trim(" Ћао ") ); -print( Upper("Здраво!") ); -print(sep); +print( Compare( t, "bè└└☺", 2, 3, 2, 3 ) ); +print( Find( t, "└└", 1 ) ); +print( Len( t ) ); +print( Lower( "Здраво!" ) ); +print( SplitWords( "â… â…¡â…¢ 456 789", " ", 1 ) ); +print( StrReplace( t, "└└", "__" ) ); +print( SubStr( t, 2, 2 ) ); +print( SubStrReplace( t, "XXXXXX", 2, 3 ) ); +print( Trim( " Ћао " ) ); +print( Upper( "Здраво!" ) ); +print( sep ); // methods print( t.length() ); -print(t); -print(t.find("è")); -print(t.upper()); -print(t.lower()); -print("{:x}".format(10)); -print("{:#x}".format(10)); -print("You hàve {} ☉ coins".format(120)); -print("{} hits {} for {} of ☠".format("John", "Bob", 120)); -print("You hit {2} for {1} ☠".format(120, "John Doe")); -print("âš— {1.spell_name} requires reagents: {1.reagents}".format(struct{spell_name:="Firè Wrath", reagents:="Ba, Bm, Ga"})); -print("{name} you âš” level {level}".format(struct{name:="Jane Doe", level:=4})); -print(sep); +print( t ); +print( t.find( "è" ) ); +print( t.upper() ); +print( t.lower() ); +print( "{:x}".format( 10 ) ); +print( "{:#x}".format( 10 ) ); +print( "You hàve {} ☉ coins".format( 120 ) ); +print( "{} hits {} for {} of ☠".format( "John", "Bob", 120 ) ); +print( "You hit {2} for {1} ☠".format( 120, "John Doe" ) ); +print( "âš— {1.spell_name} requires reagents: {1.reagents}".format( struct{ spell_name := "Firè Wrath", + reagents := "Ba, Bm, Ga" } + ) ); +print( "{name} you âš” level {level}".format( struct{ name := "Jane Doe", level := 4 } ) ); +print( sep ); // check that t is unaltered -print(t); +print( t ); diff --git a/testsuite/escript/unicode/unicode03.src b/testsuite/escript/unicode/unicode03.src index 48bf572d8..3f02fe572 100644 --- a/testsuite/escript/unicode/unicode03.src +++ b/testsuite/escript/unicode/unicode03.src @@ -1,3 +1,3 @@ // invalid Utf8 (wrong file encoding) but sanitizable "geändert" -var t:="geändert"; -print(t); +var t := "geändert"; +print( t ); diff --git a/testsuite/escript/unicode/unicode04.inc b/testsuite/escript/unicode/unicode04.inc index 7d2771d52..1574734a5 100644 --- a/testsuite/escript/unicode/unicode04.inc +++ b/testsuite/escript/unicode/unicode04.inc @@ -1 +1 @@ -print("more BOM"); +print( "more BOM" ); diff --git a/testsuite/escript/unicode/unicode04.src b/testsuite/escript/unicode/unicode04.src index 60da22dc0..f68076918 100644 --- a/testsuite/escript/unicode/unicode04.src +++ b/testsuite/escript/unicode/unicode04.src @@ -1,2 +1,2 @@ -print("useless BOM"); +print( "useless BOM" ); include "unicode04"; diff --git a/testsuite/escript/unicode/unicode05.src b/testsuite/escript/unicode/unicode05.src index a267ade99..fbd429dd0 100644 --- a/testsuite/escript/unicode/unicode05.src +++ b/testsuite/escript/unicode/unicode05.src @@ -1,7 +1,7 @@ -var a:="you should test with some special russian letters like Ñ‘ÐйЙьЬъЪ "; -print(lower(a)); -print(upper(a)); -print(pack(a)); -print(unpack(pack(a))); -print(encodebase64(a)); -print(decodebase64(encodebase64(a))); +var a := "you should test with some special russian letters like Ñ‘ÐйЙьЬъЪ "; +print( lower( a ) ); +print( upper( a ) ); +print( pack( a ) ); +print( unpack( pack( a ) ) ); +print( encodebase64( a ) ); +print( decodebase64( encodebase64( a ) ) ); diff --git a/testsuite/escript/unicode/unicode06.src b/testsuite/escript/unicode/unicode06.src index 4ddf446a6..46d3e3567 100644 --- a/testsuite/escript/unicode/unicode06.src +++ b/testsuite/escript/unicode/unicode06.src @@ -1 +1 @@ -print("tab"+CChr(0x9)+"bell"+CChr(0x7)+"bell"); +print( "tab" + CChr( 0x9 ) + "bell" + CChr( 0x7 ) + "bell" ); diff --git a/testsuite/escript/unicode/unicode07-unicode-lower-case.src b/testsuite/escript/unicode/unicode07-unicode-lower-case.src index 9e057e496..64016fd5d 100644 --- a/testsuite/escript/unicode/unicode07-unicode-lower-case.src +++ b/testsuite/escript/unicode/unicode07-unicode-lower-case.src @@ -1,4 +1,4 @@ // If the ConformingCharStream tries to convert everything to // lowercase, this will trip it up -print("â„¢"); +print( "â„¢" ); diff --git a/testsuite/escript/uninit/uninit01.src b/testsuite/escript/uninit/uninit01.src index 5401d0edf..a6f4eb855 100644 --- a/testsuite/escript/uninit/uninit01.src +++ b/testsuite/escript/uninit/uninit01.src @@ -1,23 +1,25 @@ -print(uninit); +print( uninit ); uninit := 5; -print(uninit); +print( uninit ); // `uninit` is an expression, so this should work, just like `++1++`. ++uninit++; -print(uninit); +print( uninit ); -print({ 1, 2, uninit }); -print(struct{ foo := uninit }); -print(dictionary{ "foo" -> uninit }); +print( { 1, 2, uninit } ); +print( struct{ foo := uninit } ); +print( dictionary{ "foo" -> uninit } ); enum E - FOO := uninit + FOO := uninit endenum -print(FOO); +print( FOO ); const BAR := uninit; -print(BAR); +print( BAR ); -function blubb(bar, baz := uninit) print($"bar: {bar} baz: {baz}"); endfunction -blubb("BAR"); +function blubb( bar, baz := uninit ) + print( $"bar: {bar} baz: {baz}" ); +endfunction +blubb( "BAR" ); diff --git a/testsuite/escript/uninit/uninit02.err b/testsuite/escript/uninit/uninit02.err index af4feb742..99558301d 100644 --- a/testsuite/escript/uninit/uninit02.err +++ b/testsuite/escript/uninit/uninit02.err @@ -1 +1 @@ -uninit02.src:1:5: error: mismatched input 'uninit' expecting IDENTIFIER +:1:5: error: mismatched input 'uninit' expecting IDENTIFIER \ No newline at end of file diff --git a/testsuite/escript/uninit/uninit03.err b/testsuite/escript/uninit/uninit03.err index 7f037425f..47a0048a1 100644 --- a/testsuite/escript/uninit/uninit03.err +++ b/testsuite/escript/uninit/uninit03.err @@ -1 +1 @@ -uninit03.src:1:14: error: extraneous input 'uninit' expecting {'byref', 'unused', ')', IDENTIFIER} +:1:14: error: extraneous input 'uninit' expecting {'byref', 'unused', ')', IDENTIFIER} \ No newline at end of file diff --git a/testsuite/escript/update_err.py b/testsuite/escript/update_err.py new file mode 100755 index 000000000..9a240635f --- /dev/null +++ b/testsuite/escript/update_err.py @@ -0,0 +1,62 @@ +import sys +from pathlib import Path +import subprocess + +# Too lazy to make recursion + error checking in Python... But watch out for +# `escript/in/inc0{1,2}.err` because they give different error messages across +# POSIX and Windows. +# +# find . -iname '*.err' -exec python3 update_err.py {} \; + +def read_file(file_path): + try: + with open(file_path, 'r') as file: + file_contents = file.read() + return file_contents.strip() + except FileNotFoundError: + print(f"File '{file_path}' not found.") + return None + +if __name__ == "__main__": + if len(sys.argv) < 2: + print(f"Usage: python {sys.argv[0]} ") + else: + file_path = Path(sys.argv[1]) + + if file_path.is_file(): + file_src = file_path.with_suffix(".src") + file_err = file_path.with_suffix(".err") + + contents = read_file(file_err) + if contents is None: + sys.exit(1) + + index = contents.find(": error: ") + if index != -1: + contents = contents[index + len(": error: "):] + + relative_src = file_src.relative_to(Path.cwd()) if file_src.is_absolute() else file_src + + # Run the "ecompile" program with file_src as the first argument + result = subprocess.run(["../../bin/ecompile", "-C", "ecompile.cfg", str(relative_src)], capture_output=True, text=True) + + # Store both stderr and stdout into the same variable + output = result.stderr + + # Find the line that contains 'contents' + lines = output.split('\n') + line_with_contents = next((line for line in lines if contents in line), None) + + if line_with_contents: + # :line:column: error message + # err_string = f"{file_src.name}{line_with_contents[line_with_contents.find(":"):]}" + + # :line:column: error message + err_string = line_with_contents[line_with_contents.find(":"):] + print(err_string) + with open(file_err, 'w') as file: + file.write(err_string) + else: + print(f"No line containing\n-\n{contents}\n-\nfound in\n-\n{output}\n-") + else: + print(f"File '{file_path}' not found.") diff --git a/testsuite/escript/utilmod/strftime.src b/testsuite/escript/utilmod/strftime.src index 9654639cf..5baa51ee2 100644 --- a/testsuite/escript/utilmod/strftime.src +++ b/testsuite/escript/utilmod/strftime.src @@ -1,9 +1,8 @@ use util; -print(strformattime("%")); -print(strformattime("%-")); -print(typeof(strformattime("%Y",1))); -print(strformattime("ancient %S time",1)); -var v:=strformattime("reserve buffer %T%T%T%T%T%T",1); -print(len(v)); -print(v[len(v)-4,5]); - +print( strformattime( "%" ) ); +print( strformattime( "%-" ) ); +print( typeof( strformattime( "%Y", 1 ) ) ); +print( strformattime( "ancient %S time", 1 ) ); +var v := strformattime( "reserve buffer %T%T%T%T%T%T", 1 ); +print( len( v ) ); +print( v[len( v ) - 4, 5] ); diff --git a/testsuite/escript/var/var001.err b/testsuite/escript/var/var001.err index 99c3799ee..995dc2088 100644 --- a/testsuite/escript/var/var001.err +++ b/testsuite/escript/var/var001.err @@ -1 +1 @@ -var001.src:8:1: error: Unknown identifier 'b'. \ No newline at end of file +:7:1: error: Unknown identifier 'b'. \ No newline at end of file diff --git a/testsuite/escript/var/var001.src b/testsuite/escript/var/var001.src index ef54f614f..6f0946baf 100644 --- a/testsuite/escript/var/var001.src +++ b/testsuite/escript/var/var001.src @@ -1,6 +1,5 @@ var a; - a := 5; a.b := 6; @@ -8,4 +7,3 @@ a.b := 6; b := 7; c := 8; - diff --git a/testsuite/escript/var/var01.src b/testsuite/escript/var/var01.src index ff04d1780..69c72edd0 100644 --- a/testsuite/escript/var/var01.src +++ b/testsuite/escript/var/var01.src @@ -1,3 +1,3 @@ var x := 1; -print( x ); \ No newline at end of file +print( x ); diff --git a/testsuite/escript/var/var02.src b/testsuite/escript/var/var02.src index 53b7c8e54..fb34d810d 100644 --- a/testsuite/escript/var/var02.src +++ b/testsuite/escript/var/var02.src @@ -2,7 +2,7 @@ var x := 1; print( x ); -if (1) - var y := 2; - print( y ); +if ( 1 ) + var y := 2; + print( y ); endif diff --git a/testsuite/escript/var/var03.src b/testsuite/escript/var/var03.src index 725ced4c7..611ac7471 100644 --- a/testsuite/escript/var/var03.src +++ b/testsuite/escript/var/var03.src @@ -2,9 +2,9 @@ var x := 4; function foo() - var x := 1; + var x := 1; - print( x ); + print( x ); endfunction print( x ); diff --git a/testsuite/escript/while/while01.src b/testsuite/escript/while/while01.src index abe644f48..1f562e910 100644 --- a/testsuite/escript/while/while01.src +++ b/testsuite/escript/while/while01.src @@ -1,6 +1,6 @@ var cont := 2; -while (cont) - print( "cont: " + cont ); - cont := 0; +while ( cont ) + print( "cont: " + cont ); + cont := 0; endwhile diff --git a/testsuite/escript/while/while02.src b/testsuite/escript/while/while02.src index 4d8e083b7..116d0ccf7 100644 --- a/testsuite/escript/while/while02.src +++ b/testsuite/escript/while/while02.src @@ -1,6 +1,6 @@ var cont := 4; -while (cont) - print( "cont: " + cont ); - cont := cont - 1; +while ( cont ) + print( "cont: " + cont ); + cont := cont - 1; endwhile diff --git a/testsuite/escript/while/while03.src b/testsuite/escript/while/while03.src index a3384f9e1..c759c26b4 100644 --- a/testsuite/escript/while/while03.src +++ b/testsuite/escript/while/while03.src @@ -1,7 +1,7 @@ var cont := 4; -while (cont) - print( "cont: " + cont ); - cont := cont - 1; - break; +while ( cont ) + print( "cont: " + cont ); + cont := cont - 1; + break; endwhile diff --git a/testsuite/escript/while/while04.src b/testsuite/escript/while/while04.src index e3e1c4c83..79016cc7f 100644 --- a/testsuite/escript/while/while04.src +++ b/testsuite/escript/while/while04.src @@ -1,10 +1,10 @@ var cont := 6; -while (cont) - print( "cont: " + cont ); - cont := cont - 1; - if (cont == 3) - cont := 2; - continue; - endif +while ( cont ) + print( "cont: " + cont ); + cont := cont - 1; + if ( cont == 3 ) + cont := 2; + continue; + endif endwhile diff --git a/testsuite/escript/while/while05.src b/testsuite/escript/while/while05.src index 027060526..92819bcd5 100644 --- a/testsuite/escript/while/while05.src +++ b/testsuite/escript/while/while05.src @@ -1,19 +1,18 @@ var cont := 6; -outer: -while (cont) - print( "cont: " + cont ); - cont := cont - 1; - if (cont == 3) - var x := 1; - while( x < 5) - print( "X=" + X ); - if (x == cont) - continue outer; - endif - x := x + 1; - endwhile - endif - print( "cont2: " + cont ); +outer: while ( cont ) + print( "cont: " + cont ); + cont := cont - 1; + if ( cont == 3 ) + var x := 1; + while ( x < 5 ) + print( "X=" + X ); + if ( x == cont ) + continue outer; + endif + x := x + 1; + endwhile + endif + print( "cont2: " + cont ); endwhile diff --git a/testsuite/escript/while/while06.src b/testsuite/escript/while/while06.src index d19c3fa4a..a8c51e266 100644 --- a/testsuite/escript/while/while06.src +++ b/testsuite/escript/while/while06.src @@ -1,9 +1,9 @@ var cont := 3; -while (cont) - print( "cont: " + cont ); - cont := cont - 1; - break; - print( "cont: " + cont ); +while ( cont ) + print( "cont: " + cont ); + cont := cont - 1; + break; + print( "cont: " + cont ); endwhile diff --git a/testsuite/escript/while/while07.src b/testsuite/escript/while/while07.src index fa49ed0fe..280555193 100644 --- a/testsuite/escript/while/while07.src +++ b/testsuite/escript/while/while07.src @@ -1,9 +1,9 @@ var cont := 3; -while (cont) - print( "cont: " + cont ); - cont := cont - 1; - continue; - print( "cont: " + cont ); +while ( cont ) + print( "cont: " + cont ); + cont := cont - 1; + continue; + print( "cont: " + cont ); endwhile diff --git a/testsuite/escript/while/while08.src b/testsuite/escript/while/while08.src index c30293c4a..d9c0422db 100644 --- a/testsuite/escript/while/while08.src +++ b/testsuite/escript/while/while08.src @@ -1,9 +1,9 @@ var cont := 3; -while (cont) - var a := cont + 17; - print( "cont: " + cont ); - print( "a: " + a ); - cont := cont - 1; +while ( cont ) + var a := cont + 17; + print( "cont: " + cont ); + print( "a: " + a ); + cont := cont - 1; endwhile diff --git a/testsuite/escript/while/while09.src b/testsuite/escript/while/while09.src index 1e571cda3..1bfa4b80c 100644 --- a/testsuite/escript/while/while09.src +++ b/testsuite/escript/while/while09.src @@ -1,10 +1,10 @@ var cont := 3; -while (cont) - var a := cont + 17; - print( "cont: " + cont ); - print( "a: " + a ); - break; - cont := cont - 1; +while ( cont ) + var a := cont + 17; + print( "cont: " + cont ); + print( "a: " + a ); + break; + cont := cont - 1; endwhile diff --git a/testsuite/escript/while/while10.src b/testsuite/escript/while/while10.src index f22afef22..36fd50021 100644 --- a/testsuite/escript/while/while10.src +++ b/testsuite/escript/while/while10.src @@ -1,11 +1,11 @@ var cont := 3; -while (cont) - var a := cont + 17; - print( "cont: " + cont ); - print( "a: " + a ); - cont := cont - 1; - continue; - print( "cont: " + cont ); +while ( cont ) + var a := cont + 17; + print( "cont: " + cont ); + print( "a: " + a ); + cont := cont - 1; + continue; + print( "cont: " + cont ); endwhile diff --git a/testsuite/escript/while/while11.src b/testsuite/escript/while/while11.src index e4fc24e75..54c3374ef 100644 --- a/testsuite/escript/while/while11.src +++ b/testsuite/escript/while/while11.src @@ -1,13 +1,13 @@ var cont := 3; -while (cont) - var a := cont + 17; - print( "cont: " + cont ); - print( "a: " + a ); - cont := cont - 1; - continue; - var b := 5; - print( "cont: " + cont ); - print( "b: " + b ); +while ( cont ) + var a := cont + 17; + print( "cont: " + cont ); + print( "a: " + a ); + cont := cont - 1; + continue; + var b := 5; + print( "cont: " + cont ); + print( "b: " + b ); endwhile diff --git a/testsuite/escript/while/while12.src b/testsuite/escript/while/while12.src index f7a5aad93..ffc0d8145 100644 --- a/testsuite/escript/while/while12.src +++ b/testsuite/escript/while/while12.src @@ -1,17 +1,17 @@ program test() - var startX := 3, endX := 8; - var startY := 2, endY := 7; + var startX := 3, endX := 8; + var startY := 2, endY := 7; - var fooY := 2; - while (startX <= endX) - while (startY <= endY) - print( "startX=" +startX + ", startY=" + startY ); - startY := startY + 1; - endwhile - startY := fooY; - startX := startX + 1; - print( "startX=" + startX ); - endwhile + var fooY := 2; + while ( startX <= endX ) + while ( startY <= endY ) + print( "startX=" + startX + ", startY=" + startY ); + startY := startY + 1; + endwhile + startY := fooY; + startX := startX + 1; + print( "startX=" + startX ); + endwhile -endprogram \ No newline at end of file +endprogram diff --git a/testsuite/escript/while/while13.src b/testsuite/escript/while/while13.src index 556d5555d..1e0d647fc 100644 --- a/testsuite/escript/while/while13.src +++ b/testsuite/escript/while/while13.src @@ -1,7 +1,7 @@ var a; -while (1) - var b; - print( "in while" ); - break; +while ( 1 ) + var b; + print( "in while" ); + break; endwhile -print( "end" ); \ No newline at end of file +print( "end" ); diff --git a/testsuite/pol/scripts/busyloop.src b/testsuite/pol/scripts/busyloop.src index d5b0f64e9..6e45e6ebb 100644 --- a/testsuite/pol/scripts/busyloop.src +++ b/testsuite/pol/scripts/busyloop.src @@ -9,7 +9,7 @@ So trick the scheduler by having this script run endless with a minimum of delay */ use os; -print("starting busyloop"); -while (1) - sleepms(1); +print( "starting busyloop" ); +while ( 1 ) + sleepms( 1 ); endwhile diff --git a/testsuite/pol/scripts/include/sysevent.inc b/testsuite/pol/scripts/include/sysevent.inc index 0131f51e4..4da57fb47 100644 --- a/testsuite/pol/scripts/include/sysevent.inc +++ b/testsuite/pol/scripts/include/sysevent.inc @@ -11,7 +11,7 @@ // // - +// format-off const SYSEVENT_SPEECH := 0x00000001; const SYSEVENT_ENGAGED := 0x00000002; diff --git a/testsuite/pol/scripts/include/testutil.inc b/testsuite/pol/scripts/include/testutil.inc index 73c79c3d1..1a56230e3 100644 --- a/testsuite/pol/scripts/include/testutil.inc +++ b/testsuite/pol/scripts/include/testutil.inc @@ -1,38 +1,39 @@ use uo; -const IGNORE_TEST:=255; // only valid for setup or programs +const IGNORE_TEST := 255; // only valid for setup or programs -function ret_error(str) - return error{errortext:=str}; +function ret_error( str ) + return error{ errortext := str }; endfunction function ret_error_not_equal( actual, expected, message ) if ( actual != expected ) - return ret_error( $"{message}" ); + return ret_error( $"{message}" ); endif return 1; endfunction -function createAccountWithChar(accname, psw) - var a:=FindAccount(accname); - if (!a) - a:=CreateAccount(accname,psw,1); - if (!a) - return ret_error("Failed to create account"); +function createAccountWithChar( accname, psw ) + var a := FindAccount( accname ); + if ( !a ) + a := CreateAccount( accname, psw, 1 ); + if ( !a ) + return ret_error( "Failed to create account" ); endif - a.addcharacter(0); + a.addcharacter( 0 ); endif - var char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif return char; endfunction var __resources := array{}; -function dprint(unused what) endfunction +function dprint( unused what ) +endfunction function destroy_multi_resource( multi ) dprint( $"cleanup multi 0x{multi.serial:x}" ); @@ -59,8 +60,7 @@ function destroy_npc_resource( npc ) endif endforeach - return ret_error( $"Could not find corpse for NPC 0x{serial:x} at ({x}, {y}, {z}) (corpses: {corpses.size()})" - ); + return ret_error( $"Could not find corpse for NPC 0x{serial:x} at ({x}, {y}, {z}) (corpses: {corpses.size()})" ); endfunction function new_item_resource( x, y, z, objtype, amount := 1, realm := _DEFAULT_REALM ) @@ -81,10 +81,10 @@ function new_multi_resource( x, y, z, objtype, flags := 0, realm := _DEFAULT_REA return resource; endfunction -function new_npc_resource( template, x, y, z, override_properties := 0, - realm := _DEFAULT_REALM, forcelocation := 0 ) - var resource := CreateNPCFromTemplate( template, x, y, z, override_properties, - realm, forcelocation ); +function new_npc_resource( template, x, y, z, override_properties := 0, realm := _DEFAULT_REALM, + forcelocation := 0 ) + var resource := CreateNPCFromTemplate( template, x, y, z, override_properties, realm, + forcelocation ); if ( !resource ) return resource; endif diff --git a/testsuite/pol/scripts/misc/boat.src b/testsuite/pol/scripts/misc/boat.src index b8b2d28a7..c6cbcfe05 100644 --- a/testsuite/pol/scripts/misc/boat.src +++ b/testsuite/pol/scripts/misc/boat.src @@ -1,12 +1,13 @@ use os; program start_boat( param ) - var ev, listener := start_script( ":testboat:boat", param ); + var ev, + listener := start_script( ":testboat:boat", param ); // The default control script starts forwards events from the boat control // script to the created listener. while ( param ) - if ( ev := wait_for_event(10) ) + if ( ev := wait_for_event( 10 ) ) listener.sendevent( ev ); endif endwhile diff --git a/testsuite/pol/scripts/start.src b/testsuite/pol/scripts/start.src index e40e257c8..76f65a1d3 100644 --- a/testsuite/pol/scripts/start.src +++ b/testsuite/pol/scripts/start.src @@ -1,6 +1,6 @@ use os; program start() - print("POL initialization complete."); - start_script("tests"); - start_script("busyloop"); + print( "POL initialization complete." ); + start_script( "tests" ); + start_script( "busyloop" ); endprogram diff --git a/testsuite/pol/scripts/tests.src b/testsuite/pol/scripts/tests.src index 7febbdddc..45c55c449 100644 --- a/testsuite/pol/scripts/tests.src +++ b/testsuite/pol/scripts/tests.src @@ -7,106 +7,110 @@ include "testutil"; program tests() ReloadConfiguration(); // A crude attempt to catch issues with thread-safety and pol config & ssopts. - var test_count:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); + var test_count := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); + // format-off syslog( $"\n{CONSOLE_COLOR_CYAN}##########################\n" + $"{CONSOLE_COLOR_CYAN}# starting testscripts #\n" + $"{CONSOLE_COLOR_CYAN}# Run: "+test_count+" #\n" + $"{CONSOLE_COLOR_CYAN}##########################\n",0,CONSOLE_COLOR_CYAN); - var exitcode:=0; - var testpkgs:={}; + // format-on + var exitcode := 0; + var testpkgs := {}; var restartpkg; foreach pkg in Packages() - if (pkg.dir.find("testpkgs")==1) - if (pkg.name == "testrestart") - restartpkg:={pkg.name,pkg.desc}; + if ( pkg.dir.find( "testpkgs" ) == 1 ) + if ( pkg.name == "testrestart" ) + restartpkg := { pkg.name, pkg.desc }; else - testpkgs.append({pkg.name,pkg.desc}); + testpkgs.append( { pkg.name, pkg.desc } ); endif endif endforeach - testpkgs.sort(1); + testpkgs.sort( 1 ); // to prevent cleanup of other tests, TestRestart always at the end - if (restartpkg) - testpkgs.append(restartpkg); + if ( restartpkg ) + testpkgs.append( restartpkg ); endif - var filter:=GetEnvironmentVariable("POLCORE_TEST_FILTER"); - if (filter) - syslog("## using testfilter \""+filter+"\"\n",0,CONSOLE_COLOR_CYAN); + var filter := GetEnvironmentVariable( "POLCORE_TEST_FILTER" ); + if ( filter ) + syslog( "## using testfilter \"" + filter + "\"\n", 0, CONSOLE_COLOR_CYAN ); endif foreach pkg in testpkgs - if (filter and !pkg[1].find(filter)) + if ( filter and !pkg[1].find( filter ) ) continue; endif - if (test_count==2 and pkg[1]!="testrestart") + if ( test_count == 2 and pkg[1] != "testrestart" ) continue; endif - var pkgstartms:=ReadMillisecondClock(); - syslog(pkg[2],0,CONSOLE_COLOR_MAGENTA); - var scripts:=listdirectory(":{}:".format(pkg[1]),"ecl"); + var pkgstartms := ReadMillisecondClock(); + syslog( pkg[2], 0, CONSOLE_COLOR_MAGENTA ); + var scripts := listdirectory( ":{}:".format( pkg[1] ), "ecl" ); scripts.sort(); - if ("setup.ecl" in scripts) - syslog(" Calling setup.ecl..",0,CONSOLE_COLOR_GREEN); - var startms:=ReadMillisecondClock(); - var res:=run_script(":{}:setup.ecl".format(pkg[1])); - if (res == IGNORE_TEST) + if ( "setup.ecl" in scripts ) + syslog( " Calling setup.ecl..", 0, CONSOLE_COLOR_GREEN ); + var startms := ReadMillisecondClock(); + var res := run_script( ":{}:setup.ecl".format( pkg[1] ) ); + if ( res == IGNORE_TEST ) continue; - elseif (res != 1) - syslog(" failed: "+res.errortext,0,CONSOLE_COLOR_RED); - exitcode:=1; + elseif ( res != 1 ) + syslog( " failed: " + res.errortext, 0, CONSOLE_COLOR_RED ); + exitcode := 1; continue; endif - syslog(" ..{}ms".format(ReadMillisecondClock()-startms),0,CONSOLE_COLOR_GREEN); + syslog( " ..{}ms".format( ReadMillisecondClock() - startms ), 0, CONSOLE_COLOR_GREEN ); endif foreach file in scripts - if (file.find("test") != 1) + if ( file.find( "test" ) != 1 ) continue; endif - var scriptstartms:=ReadMillisecondClock(); - syslog(" Calling {}..".format(file),0,CONSOLE_COLOR_GREEN); - var script:=LoadExportedScript(":{}:{}".format(pkg[1], file)); - if (!script[2]) - syslog(" failed: "+script[2],0,CONSOLE_COLOR_RED); - exitcode:=1; + var scriptstartms := ReadMillisecondClock(); + syslog( " Calling {}..".format( file ), 0, CONSOLE_COLOR_GREEN ); + var script := LoadExportedScript( ":{}:{}".format( pkg[1], file ) ); + if ( !script[2] ) + syslog( " failed: " + script[2], 0, CONSOLE_COLOR_RED ); + exitcode := 1; continue; endif - if (script[2] == IGNORE_TEST) + if ( script[2] == IGNORE_TEST ) continue; endif - foreach func in (script[1].exported_functions) - var startms:=ReadMillisecondClock(); - syslog(" Calling {}..".format(func),0,CONSOLE_COLOR_GREEN); - var res:=script[1].call(func); - if (res != 1) - syslog(" failed: "+res.errortext,0,CONSOLE_COLOR_RED); - exitcode:=1; + foreach func in ( script[1].exported_functions ) + var startms := ReadMillisecondClock(); + syslog( " Calling {}..".format( func ), 0, CONSOLE_COLOR_GREEN ); + var res := script[1].call( func ); + if ( res != 1 ) + syslog( " failed: " + res.errortext, 0, CONSOLE_COLOR_RED ); + exitcode := 1; continue; endif - syslog(" ..{}ms".format(ReadMillisecondClock()-startms),0,CONSOLE_COLOR_GREEN); + syslog( " ..{}ms".format( ReadMillisecondClock() - startms ), 0, CONSOLE_COLOR_GREEN ); endforeach - syslog(" ..{}ms".format(ReadMillisecondClock()-scriptstartms),0,CONSOLE_COLOR_GREEN); + syslog( " ..{}ms".format( ReadMillisecondClock() - scriptstartms ), 0, CONSOLE_COLOR_GREEN ); endforeach - if ("cleanup.ecl" in scripts) - syslog(" Calling cleanup.ecl..",0,CONSOLE_COLOR_GREEN); - var startms:=ReadMillisecondClock(); - run_script(":{}:cleanup.ecl".format(pkg[1])); - syslog(" ..{}ms".format(ReadMillisecondClock()-startms),0,CONSOLE_COLOR_GREEN); + if ( "cleanup.ecl" in scripts ) + syslog( " Calling cleanup.ecl..", 0, CONSOLE_COLOR_GREEN ); + var startms := ReadMillisecondClock(); + run_script( ":{}:cleanup.ecl".format( pkg[1] ) ); + syslog( " ..{}ms".format( ReadMillisecondClock() - startms ), 0, CONSOLE_COLOR_GREEN ); endif - syslog("..{}ms".format(ReadMillisecondClock()-pkgstartms),0,CONSOLE_COLOR_MAGENTA); + syslog( "..{}ms".format( ReadMillisecondClock() - pkgstartms ), 0, CONSOLE_COLOR_MAGENTA ); endforeach - var result:=$"{CONSOLE_COLOR_GREEN}success"; - if (exitcode) - result:=$"{CONSOLE_COLOR_RED}failed "; + var result := $"{CONSOLE_COLOR_GREEN}success"; + if ( exitcode ) + result := $"{CONSOLE_COLOR_RED}failed "; endif + // format-off syslog( $"\n{CONSOLE_COLOR_CYAN}###########################\n" + $"{CONSOLE_COLOR_CYAN}# finished tests: {result} {CONSOLE_COLOR_CYAN}#\n" + $"{CONSOLE_COLOR_CYAN}###########################\n",0,CONSOLE_COLOR_CYAN); - shutdown(exitcode); + // format-on + shutdown( exitcode ); endprogram diff --git a/testsuite/pol/testpkgs/attack/ai_attack.src b/testsuite/pol/testpkgs/attack/ai_attack.src index 8367f5d56..b4fe0c490 100644 --- a/testsuite/pol/testpkgs/attack/ai_attack.src +++ b/testsuite/pol/testpkgs/attack/ai_attack.src @@ -21,10 +21,7 @@ program enteredarea() endif if ( ev.unhide ) - var ev := struct{ - type := "BEFORE_UNHIDE", - gameclock := ReadGameClock() - }; + var ev := struct{ type := "BEFORE_UNHIDE", gameclock := ReadGameClock() }; GetProcess( GetObjProperty( me, "#TestPid" ) ).SendEvent( ev ); me.hidden := 0; endif diff --git a/testsuite/pol/testpkgs/attack/attackhitscript.src b/testsuite/pol/testpkgs/attack/attackhitscript.src index 22c9eb7a7..583fa0507 100644 --- a/testsuite/pol/testpkgs/attack/attackhitscript.src +++ b/testsuite/pol/testpkgs/attack/attackhitscript.src @@ -5,18 +5,16 @@ use polsys; program MainHitScript( attacker, defender, weapon, armor, basedamage, rawdamage ) var pid := GetObjProperty( attacker, "#TestPid" ); if ( pid ) - var ev := struct{ - type := "HIT", - attacker := attacker, - "attacker.name" := attacker.name, - defender := defender, - "defender.name" := defender.name, - weapon := weapon, - armor := armor, - basedamage := basedamage, - rawdamage := rawdamage, - gameclock := ReadGameClock() - }; + var ev := struct{ type := "HIT", + attacker := attacker, + "attacker.name" := attacker.name, + defender := defender, + "defender.name" := defender.name, + weapon := weapon, + armor := armor, + basedamage := basedamage, + rawdamage := rawdamage, + gameclock := ReadGameClock() }; GetProcess( pid ).SendEvent( ev ); endif diff --git a/testsuite/pol/testpkgs/attack/test_npc_attack.src b/testsuite/pol/testpkgs/attack/test_npc_attack.src index c387f0f93..8d1d5c02b 100644 --- a/testsuite/pol/testpkgs/attack/test_npc_attack.src +++ b/testsuite/pol/testpkgs/attack/test_npc_attack.src @@ -44,7 +44,8 @@ exported function attack_on_unhide_attacker() npc1.hidden := 1; // Send an event to npc1 to attack npc2 + unhide. - npc1.process.sendevent( struct{ type := SYSEVENT_ENGAGED, source := npc2, sleep := 2, unhide := true } ); + npc1.process.sendevent( struct{ type := SYSEVENT_ENGAGED, source := npc2, + sleep := 2, unhide := true } ); var initial_evs := collect_events( 1, "No event for NPC BEFORE_UNHIDE" ); if ( !initial_evs ) @@ -54,14 +55,14 @@ exported function attack_on_unhide_attacker() endif // Collect two attack events - if (!(evs := collect_events( 2 ))) + if ( !( evs := collect_events( 2 ) ) ) return evs; endif // The attack should happen when npc1 unhid. t := initial_evs[1].gameclock; - if (!validate_events(err, evs, t)) + if ( !validate_events( err, evs, t ) ) return err; endif @@ -80,24 +81,25 @@ exported function attack_on_unhide_defender() reset_npcs(); // npc1 attacks npc2 - npc1.process.sendevent( struct{ type := SYSEVENT_ENGAGED, source := npc2, sleep := 0, unhide := false } ); + npc1.process.sendevent( struct{ type := SYSEVENT_ENGAGED, source := npc2, + sleep := 0, unhide := false } ); // Collect two attack events - if (!(evs := collect_events( 2 ))) + if ( !( evs := collect_events( 2 ) ) ) return evs; endif // Both attacks should happen at the same time t := evs[1].gameclock; - if (!validate_events(err, evs, t)) + if ( !validate_events( err, evs, t ) ) return err; endif // Hide npc2, clear its opponent, and sleep to reset npc1's swing timer. npc2.hidden := 1; npc2.process.sendevent( struct{ type := SYSEVENT_DISENGAGED } ); - Sleep(2); + Sleep( 2 ); // Unhide npc2. Since npc1 is still attacking, both should get a hit. npc2.hidden := 0; @@ -106,11 +108,11 @@ exported function attack_on_unhide_defender() t := ReadGameClock(); // Collect two attack events - if (!(evs := collect_events( 2 ))) + if ( !( evs := collect_events( 2 ) ) ) return evs; endif - if (!validate_events(err, evs, t)) + if ( !validate_events( err, evs, t ) ) return err; endif @@ -119,7 +121,6 @@ exported function attack_on_unhide_defender() return 1; endfunction - /** * Helper functions */ @@ -132,15 +133,15 @@ function reset_npcs() endfunction // Ensure gameclock and attacker-defender sequence of two events. -function validate_events(byref err, byref evs, t) - var failure := - ( evs[1].gameclock != t ) || // First hit did not happen on unhide. - ( evs[2].gameclock != t ) || // Second hit did not happen on unhide. - ( evs[1].attacker != evs[2].defender ) || // First hit attacker is not second hit defender - ( evs[1].defender != evs[2].attacker ); // First hit defender is not second hit attacker +function validate_events( byref err, byref evs, t ) + var failure := ( evs[1].gameclock != t ) || // First hit did not happen on unhide. + ( evs[2].gameclock != t ) || // Second hit did not happen on unhide. + ( evs[1].attacker != evs[2].defender ) || // First hit attacker is not second hit defender + ( evs[1].defender != evs[2].attacker ); // First hit defender is not second hit attacker if ( failure ) - return err := ret_error( $"Unexpected attacker-defender sequence. Expected both hits at gameclock {t}, attacker[1] == defender[2], defender[1] == attacker[2].\n\nEvents: {PackJSON(evs, true)}" ); + return err := ret_error( $"Unexpected attacker-defender sequence. Expected both hits at gameclock {t}, attacker[1] == defender[2], defender[1] == attacker[2].\n\nEvents: {PackJSON( + evs, true )}" ); endif return 1; diff --git a/testsuite/pol/testpkgs/boat/boat.src b/testsuite/pol/testpkgs/boat/boat.src index 8cfb3cc8f..4b8c40ad4 100644 --- a/testsuite/pol/testpkgs/boat/boat.src +++ b/testsuite/pol/testpkgs/boat/boat.src @@ -1,14 +1,14 @@ use uo; use os; -program boat(boat) - boat.setprop("started",1); +program boat( boat ) + boat.setprop( "started", 1 ); var ev; - while (boat) - if (ev := wait_for_event(10)) - var test_process := GetProcess(boat.getprop("#TestClientBoatPid")); - test_process.sendevent(struct{ source := "control_script", event := ev }); + while ( boat ) + if ( ev := wait_for_event( 10 ) ) + var test_process := GetProcess( boat.getprop( "#TestClientBoatPid" ) ); + test_process.sendevent( struct{ source := "control_script", event := ev } ); endif endwhile endprogram diff --git a/testsuite/pol/testpkgs/boat/cleanup.src b/testsuite/pol/testpkgs/boat/cleanup.src index efebee44e..860a93a84 100644 --- a/testsuite/pol/testpkgs/boat/cleanup.src +++ b/testsuite/pol/testpkgs/boat/cleanup.src @@ -1,5 +1,5 @@ use uo; -foreach multi in (ListMultisInBox(0,0,-200,10000,10000,200)) - DestroyMulti(multi); +foreach multi in ( ListMultisInBox( 0, 0, -200, 10000, 10000, 200 ) ) + DestroyMulti( multi ); endforeach diff --git a/testsuite/pol/testpkgs/boat/method-scripts/itemdesc.src b/testsuite/pol/testpkgs/boat/method-scripts/itemdesc.src index 72d651858..524d6f5da 100644 --- a/testsuite/pol/testpkgs/boat/method-scripts/itemdesc.src +++ b/testsuite/pol/testpkgs/boat/method-scripts/itemdesc.src @@ -1,12 +1,12 @@ program Install() - Print( "Custom ItemDesc Boat Class Methods Installed." ); - return 1; + Print( "Custom ItemDesc Boat Class Methods Installed." ); + return 1; endprogram -exported function IsItemDescBoat(unused boat) - return 1; +exported function IsItemDescBoat( unused boat ) + return 1; endfunction -exported function WhereDefined(unused boat) - return "itemdesc"; +exported function WhereDefined( unused boat ) + return "itemdesc"; endfunction diff --git a/testsuite/pol/testpkgs/boat/method-scripts/syshook.src b/testsuite/pol/testpkgs/boat/method-scripts/syshook.src index c103faa97..772a64167 100644 --- a/testsuite/pol/testpkgs/boat/method-scripts/syshook.src +++ b/testsuite/pol/testpkgs/boat/method-scripts/syshook.src @@ -1,12 +1,12 @@ program Install() - Print( "Custom SysHook Boat Class Methods Installed." ); - return 1; + Print( "Custom SysHook Boat Class Methods Installed." ); + return 1; endprogram -exported function IsSysHookBoat(unused boat) - return 1; +exported function IsSysHookBoat( unused boat ) + return 1; endfunction -exported function WhereDefined(unused boat) - return "syshook"; +exported function WhereDefined( unused boat ) + return "syshook"; endfunction diff --git a/testsuite/pol/testpkgs/boat/test_boat.src b/testsuite/pol/testpkgs/boat/test_boat.src index ead7c8b4a..865aef41d 100644 --- a/testsuite/pol/testpkgs/boat/test_boat.src +++ b/testsuite/pol/testpkgs/boat/test_boat.src @@ -11,98 +11,99 @@ program test_boat() endprogram exported function create() - var res:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!res) - return ret_error("Failed to create boat "+res); + var res := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !res ) + return ret_error( "Failed to create boat " + res ); endif - if (res.x !=10 || res.y != 50 || res.z != -4 || res.graphic !=0x0) - var er:="Wrong pos or graphic: {},{},{} {}".format(res.x, res.y, res.z, res.graphic); - DestroyMulti(res); - return ret_error(er); + if ( res.x != 10 || res.y != 50 || res.z != -4 || res.graphic != 0x0 ) + var er := "Wrong pos or graphic: {},{},{} {}".format( res.x, res.y, res.z, res.graphic ); + DestroyMulti( res ); + return ret_error( er ); endif - if (res.portplank.x != 10 || res.portplank.y != 48 || res.portplank.z != -4) - var er:="Wrong portplank pos: {},{},{}".format(res.portplank.x, res.portplank.y, res.portplank.z); - DestroyMulti(res); - return ret_error(er); + if ( res.portplank.x != 10 || res.portplank.y != 48 || res.portplank.z != -4 ) + var er := "Wrong portplank pos: {},{},{}".format( res.portplank.x, res.portplank.y, + res.portplank.z ); + DestroyMulti( res ); + return ret_error( er ); endif - for i:=1 to 5 - sleepms(10); - if (res.getprop("started")) - DestroyMulti(res); + for i := 1 to 5 + sleepms( 10 ); + if ( res.getprop( "started" ) ) + DestroyMulti( res ); return 1; endif endfor - DestroyMulti(res); - return ret_error("Failed to start boat script"); + DestroyMulti( res ); + return ret_error( "Failed to start boat script" ); endfunction exported function create_fail() - var res:=CreateMultiAtLocation(50,50,-4,0x11000, CRMULTI_FACING_EAST); - if (res) - DestroyMulti(res); - return ret_error("Created boat on ground"); + var res := CreateMultiAtLocation( 50, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( res ) + DestroyMulti( res ); + return ret_error( "Created boat on ground" ); endif return 1; endfunction exported function move() - var res:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!res) - return ret_error("Failed to create boat "+res); + var res := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !res ) + return ret_error( "Failed to create boat " + res ); endif - moveboat(res, 0); - if (res.x !=10 || res.y != 49 || res.z != -4) - var er:="Wrong pos: {},{},{}".format(res.x, res.y, res.z); - DestroyMulti(res); - return ret_error(er); + moveboat( res, 0 ); + if ( res.x != 10 || res.y != 49 || res.z != -4 ) + var er := "Wrong pos: {},{},{}".format( res.x, res.y, res.z ); + DestroyMulti( res ); + return ret_error( er ); endif - DestroyMulti(res); + DestroyMulti( res ); return 1; endfunction exported function test_script_method_syshook() - var res:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!res) - return ret_error("Failed to create boat "+res); + var res := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !res ) + return ret_error( "Failed to create boat " + res ); endif var value := res.IsSysHookBoat(); - if (value != 1) - var er:="Wrong IsSysHookBoat() return value: {}".format(value); - DestroyMulti(res); - return ret_error(er); + if ( value != 1 ) + var er := "Wrong IsSysHookBoat() return value: {}".format( value ); + DestroyMulti( res ); + return ret_error( er ); endif - DestroyMulti(res); + DestroyMulti( res ); return 1; endfunction exported function test_script_method_itemdesc() - var res:=CreateMultiAtLocation(10,50,-4,0x11001, CRMULTI_FACING_EAST); - if (!res) - return ret_error("Failed to create boat "+res); + var res := CreateMultiAtLocation( 10, 50, -4, 0x11001, CRMULTI_FACING_EAST ); + if ( !res ) + return ret_error( "Failed to create boat " + res ); endif var value := res.IsItemDescBoat(); - if (value != 1) - var er:="Wrong IsItemDescBoat() return value: {}".format(value); - DestroyMulti(res); - return ret_error(er); + if ( value != 1 ) + var er := "Wrong IsItemDescBoat() return value: {}".format( value ); + DestroyMulti( res ); + return ret_error( er ); endif - DestroyMulti(res); + DestroyMulti( res ); return 1; endfunction exported function test_script_method_both() - var res:=CreateMultiAtLocation(10,50,-4,0x11001, CRMULTI_FACING_EAST); - if (!res) - return ret_error("Failed to create boat "+res); + var res := CreateMultiAtLocation( 10, 50, -4, 0x11001, CRMULTI_FACING_EAST ); + if ( !res ) + return ret_error( "Failed to create boat " + res ); endif var value := res.WhereDefined(); - if (value != "itemdesc") - var er:="Wrong WhereDefined() return value: {}".format(value); - DestroyMulti(res); - return ret_error(er); + if ( value != "itemdesc" ) + var er := "Wrong WhereDefined() return value: {}".format( value ); + DestroyMulti( res ); + return ret_error( er ); endif - DestroyMulti(res); + DestroyMulti( res ); return 1; endfunction @@ -129,7 +130,8 @@ exported function test_boat_walkon_script() if ( !res ) res := ret_error( "Event not received from walkon script" ); else - if ( res.lastx != lastpos.lastx || res.lasty != lastpos.lasty || res.lastz != lastpos.lastz || res.lastrealm != lastpos.lastrealm ) + if ( res.lastx != lastpos.lastx || res.lasty != lastpos.lasty || res.lastz != lastpos.lastz || + res.lastrealm != lastpos.lastrealm ) res := ret_error( $"Last position of npc {lastpos} != last position from walkon script {res}" ); else res := 1; @@ -164,7 +166,8 @@ exported function test_boat_walkon_script_oncreate() if ( !res ) res := ret_error( "Event not received from walkon script" ); else - if ( res.lastx != lastpos.lastx || res.lasty != lastpos.lasty || res.lastz != lastpos.lastz || res.lastrealm != lastpos.lastrealm ) + if ( res.lastx != lastpos.lastx || res.lasty != lastpos.lasty || res.lastz != lastpos.lastz || + res.lastrealm != lastpos.lastrealm ) res := ret_error( $"Last position of npc {lastpos} != last position from walkon script {res}" ); else res := 1; @@ -252,191 +255,200 @@ function RestoreConfiguration( newConf ) endfunction exported function test_boat_realm_move() - var boat:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!boat) - return ret_error("Failed to create boat "+boat); + var boat := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !boat ) + return ret_error( "Failed to create boat " + boat ); endif - var item:=CreateItemAtLocation(10,51,0,0xf3f); - if (!item) - DestroyMulti(boat); - return ret_error($"Failed to create item {item}"); + var item := CreateItemAtLocation( 10, 51, 0, 0xf3f ); + if ( !item ) + DestroyMulti( boat ); + return ret_error( $"Failed to create item {item}" ); endif var npc := CreateNPCFromTemplate( ":testnpc:probe_npc", 9, 50, 0 ); if ( !npc ) - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return ret_error( $"Failed to create npc: {npc}" ); endif - var result:=1; + var result := 1; do - var res:=MoveObjectToLocation(boat,1580,150,0,"britannia2",MOVEOBJECT_FORCELOCATION); - if (!res || boat.x != 1580 || boat.y != 150 || boat.z != 0 || boat.realm != "britannia2") - result := ret_error($"Failed initial move: {res}:{boat.x},{boat.y},{boat.z},{boat.realm}"); + var res := MoveObjectToLocation( boat, 1580, 150, 0, "britannia2", MOVEOBJECT_FORCELOCATION ); + if ( !res || boat.x != 1580 || boat.y != 150 || boat.z != 0 || boat.realm != "britannia2" ) + result := ret_error( $"Failed initial move: {res}:{boat.x},{boat.y},{boat.z},{boat.realm}" ); break; - elseif ( item.x != 1580 || item.y != 151 || item.z != 4 || item.realm != "britannia2") - result := ret_error($"Initial move failed: item {item.x},{item.y},{item.z},{item.realm}"); + elseif ( item.x != 1580 || item.y != 151 || item.z != 4 || item.realm != "britannia2" ) + result := ret_error( $"Initial move failed: item {item.x},{item.y},{item.z},{item.realm}" ); break; - elseif (npc.x != 1579 || npc.y != 150 || npc.z != 3 || npc.realm != "britannia2") - result := ret_error($"Initial move failed: npc {npc.x},{npc.y},{npc.z},{npc.realm}"); + elseif ( npc.x != 1579 || npc.y != 150 || npc.z != 3 || npc.realm != "britannia2" ) + result := ret_error( $"Initial move failed: npc {npc.x},{npc.y},{npc.z},{npc.realm}" ); break; - elseif (boat.portplank.x != 1580 || boat.portplank.y != 148 || boat.portplank.z != 0 || boat.portplank.realm != "britannia2") - result:=ret_error("Initial move failed: portplank {},{},{},{}".format(boat.portplank.x, boat.portplank.y, boat.portplank.z, boat.portplank.realm)); + elseif ( boat.portplank.x != 1580 || boat.portplank.y != 148 || boat.portplank.z != 0 || + boat.portplank.realm != "britannia2" ) + result := ret_error( "Initial move failed: portplank {},{},{},{}".format( boat.portplank.x, + boat.portplank.y, + boat.portplank.z, + boat.portplank.realm ) ); break; endif - res:=MoveObjectToLocation(boat,10,10,-4,"britannia",MOVEOBJECT_FORCELOCATION); - if (!res || boat.x != 10 || boat.y != 10 || boat.z != -4|| boat.realm != "britannia") - result:=ret_error($"Failed to move: {res}:{boat.x},{boat.y},{boat.z},{boat.realm}"); + res := MoveObjectToLocation( boat, 10, 10, -4, "britannia", MOVEOBJECT_FORCELOCATION ); + if ( !res || boat.x != 10 || boat.y != 10 || boat.z != -4 || boat.realm != "britannia" ) + result := ret_error( $"Failed to move: {res}:{boat.x},{boat.y},{boat.z},{boat.realm}" ); break; - elseif ( item.x != 10 || item.y != 11 || item.z != 0 || item.realm != "britannia") - result := ret_error($"Move failed: item {item.x},{item.y},{item.z},{item.realm}"); + elseif ( item.x != 10 || item.y != 11 || item.z != 0 || item.realm != "britannia" ) + result := ret_error( $"Move failed: item {item.x},{item.y},{item.z},{item.realm}" ); break; - elseif (npc.x != 9 || npc.y != 10 || npc.z != -1 || npc.realm != "britannia") - result := ret_error($"Move failed: npc {npc.x},{npc.y},{npc.z},{npc.realm}"); + elseif ( npc.x != 9 || npc.y != 10 || npc.z != -1 || npc.realm != "britannia" ) + result := ret_error( $"Move failed: npc {npc.x},{npc.y},{npc.z},{npc.realm}" ); break; - elseif (boat.portplank.x != 10 || boat.portplank.y != 8 || boat.portplank.z != -4 || boat.portplank.realm != "britannia") - result:=ret_error("Move failed: portplank {},{},{},{}".format(boat.portplank.x, boat.portplank.y, boat.portplank.z, boat.portplank.realm)); + elseif ( boat.portplank.x != 10 || boat.portplank.y != 8 || boat.portplank.z != -4 || + boat.portplank.realm != "britannia" ) + result := ret_error( "Move failed: portplank {},{},{},{}".format( boat.portplank.x, + boat.portplank.y, + boat.portplank.z, + boat.portplank.realm ) ); break; endif - dowhile(0); + dowhile ( 0 ); MoveObjectToLocation( npc, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return result; endfunction exported function test_boat_turn_travellers() - var boat:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!boat) - return ret_error("Failed to create boat "+boat); + var boat := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !boat ) + return ret_error( "Failed to create boat " + boat ); endif - var item:=CreateItemAtLocation(10,51,0,0xf3f); - if (!item) - DestroyMulti(boat); - return ret_error($"Failed to create item {item}"); + var item := CreateItemAtLocation( 10, 51, 0, 0xf3f ); + if ( !item ) + DestroyMulti( boat ); + return ret_error( $"Failed to create item {item}" ); endif var npc := CreateNPCFromTemplate( ":testnpc:probe_npc", 9, 50, 0 ); if ( !npc ) - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return ret_error( $"Failed to create npc: {npc}" ); endif // The `z` coords of objects should not change. - var checks:={ - {1,4, 9,50,item.z, 10,49,npc.z}, // right - {3,2, 10,51,item.z, 9,50,npc.z}, // left - {2,6, 10,49,item.z, 11,50,npc.z}, // around - {0,6, 10,49,item.z, 11,50,npc.z} // nothing - }; - var result:=1; + var checks := { { 1, 4, 9, 50, item.z, 10, 49, npc.z }, // right + { 3, 2, 10, 51, item.z, 9, 50, npc.z }, // left + { 2, 6, 10, 49, item.z, 11, 50, npc.z }, // around + { 0, 6, 10, 49, item.z, 11, 50, npc.z } // nothing + }; + var result := 1; foreach check in checks - var res:=TurnBoat(boat,check[1]); - if (!res) - result:=ret_error($"Failed to turn {check} {res}"); + var res := TurnBoat( boat, check[1] ); + if ( !res ) + result := ret_error( $"Failed to turn {check} {res}" ); break; endif - if (boat.facing != check[2] || item.x != check[3] || item.y != check[4] || item.z != check[5] || npc.x != check[6] || npc.y != check[7] || npc.z != check[8]) - result := ret_error($"Check failed {check}: facing {boat.facing} item {item.x},{item.y},{item.z} npc {npc.x},{npc.y},{npc.z}"); + if ( boat.facing != check[2] || item.x != check[3] || item.y != check[4] || item.z != check[5] || + npc.x != check[6] || npc.y != check[7] || npc.z != check[8] ) + result := ret_error( $"Check failed {check}: facing {boat.facing} item {item.x},{item.y},{item.z} npc {npc.x},{npc.y},{npc.z}" ); break; endif endforeach MoveObjectToLocation( npc, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return result; endfunction exported function test_boat_move_travellers() - var boat:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!boat) - return ret_error("Failed to create boat "+boat); + var boat := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !boat ) + return ret_error( "Failed to create boat " + boat ); endif - var item:=CreateItemAtLocation(10,51,0,0xf3f); - if (!item) - DestroyMulti(boat); - return ret_error($"Failed to create item {item}"); + var item := CreateItemAtLocation( 10, 51, 0, 0xf3f ); + if ( !item ) + DestroyMulti( boat ); + return ret_error( $"Failed to create item {item}" ); endif var npc := CreateNPCFromTemplate( ":testnpc:probe_npc", 9, 50, 0 ); if ( !npc ) - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return ret_error( $"Failed to create npc: {npc}" ); endif - var result:=1; - var res:=MoveBoat(boat,0); - if (!res) - result:=ret_error($"Failed to move {res}"); + var result := 1; + var res := MoveBoat( boat, 0 ); + if ( !res ) + result := ret_error( $"Failed to move {res}" ); else - if ( item.x != 10 || item.y != 50 || item.z != 0 || - npc.x != 9 || npc.y != 49 || npc.z != -1 ) - result := ret_error($"Move failed: item {item.x},{item.y},{item.z} npc {npc.x},{npc.y},{npc.z}"); - elseif (boat.portplank.x != 10 || boat.portplank.y != 47 || boat.portplank.z != -4) - result:=ret_error("Wrong portplank pos: {},{},{}".format(res.portplank.x, res.portplank.y, res.portplank.z)); + if ( item.x != 10 || item.y != 50 || item.z != 0 || npc.x != 9 || npc.y != 49 || npc.z != -1 ) + result := ret_error( $"Move failed: item {item.x},{item.y},{item.z} npc {npc.x},{npc.y},{npc.z}" ); + elseif ( boat.portplank.x != 10 || boat.portplank.y != 47 || boat.portplank.z != -4 ) + result := ret_error( "Wrong portplank pos: {},{},{}".format( res.portplank.x, res.portplank.y, + res.portplank.z ) ); endif endif MoveObjectToLocation( npc, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return result; endfunction exported function test_boat_moveloc_travellers() - var boat:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!boat) - return ret_error("Failed to create boat "+boat); + var boat := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !boat ) + return ret_error( "Failed to create boat " + boat ); endif - var item:=CreateItemAtLocation(10,51,0,0xf3f); - if (!item) - DestroyMulti(boat); - return ret_error($"Failed to create item {item}"); + var item := CreateItemAtLocation( 10, 51, 0, 0xf3f ); + if ( !item ) + DestroyMulti( boat ); + return ret_error( $"Failed to create item {item}" ); endif var npc := CreateNPCFromTemplate( ":testnpc:probe_npc", 9, 50, 0 ); if ( !npc ) - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return ret_error( $"Failed to create npc: {npc}" ); endif - var result:=1; - var res:=MoveObjectToLocation(boat,180,150,10,flags:=MOVEOBJECT_FORCELOCATION); - if (!res) - result:=ret_error($"Failed to move {res}"); + var result := 1; + var res := MoveObjectToLocation( boat, 180, 150, 10, flags := MOVEOBJECT_FORCELOCATION ); + if ( !res ) + result := ret_error( $"Failed to move {res}" ); else - if ( item.x != 180 || item.y != 151 || item.z != 14 || - npc.x != 179 || npc.y != 150 || npc.z != 13 ) - result := ret_error($"Move failed: item {item.x},{item.y},{item.z} npc {npc.x},{npc.y},{npc.z}"); - elseif (boat.portplank.x != 180 || boat.portplank.y != 148 || boat.portplank.z != 10) - result:=ret_error("Wrong portplank pos: {},{},{}".format(boat.portplank.x, boat.portplank.y, boat.portplank.z)); + if ( item.x != 180 || item.y != 151 || item.z != 14 || npc.x != 179 || npc.y != 150 || + npc.z != 13 ) + result := ret_error( $"Move failed: item {item.x},{item.y},{item.z} npc {npc.x},{npc.y},{npc.z}" ); + elseif ( boat.portplank.x != 180 || boat.portplank.y != 148 || boat.portplank.z != 10 ) + result := ret_error( "Wrong portplank pos: {},{},{}".format( boat.portplank.x, boat.portplank.y, + boat.portplank.z ) ); endif endif MoveObjectToLocation( npc, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - DestroyItem(item); - DestroyMulti(boat); + DestroyItem( item ); + DestroyMulti( boat ); return result; endfunction exported function test_boat_move_outside_realm() - var boat:=CreateMultiAtLocation(180,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!boat) - return ret_error("Failed to create boat "+boat); + var boat := CreateMultiAtLocation( 180, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !boat ) + return ret_error( "Failed to create boat " + boat ); endif - var result:=ret_error("didnt stop moving"); - while (boat.x < 190) - var res:=MoveBoatRelative(boat,0); - if (!res) - if (boat.x == 186) + var result := ret_error( "didnt stop moving" ); + while ( boat.x < 190 ) + var res := MoveBoatRelative( boat, 0 ); + if ( !res ) + if ( boat.x == 186 ) result := 1; break; else - result := ret_error($"moved to far: {boat.x}"); + result := ret_error( $"moved to far: {boat.x}" ); break; endif endif endwhile - DestroyMulti(boat); + DestroyMulti( boat ); return result; endfunction diff --git a/testsuite/pol/testpkgs/boat/walkon.src b/testsuite/pol/testpkgs/boat/walkon.src index 1f200a9a1..cb6ba993c 100644 --- a/testsuite/pol/testpkgs/boat/walkon.src +++ b/testsuite/pol/testpkgs/boat/walkon.src @@ -3,6 +3,7 @@ use uo; program walkon( who, boat, lastx, lasty, lastz, lastrealm ) var test_pid := GetObjProperty( boat, "#TestPid" ); - GetProcess( test_pid ).SendEvent( struct{ lastx := lastx, lasty := lasty, lastz := lastz, lastrealm := lastrealm } ); + GetProcess( test_pid ).SendEvent( struct{ lastx := lastx, lasty := lasty, + lastz := lastz, lastrealm := lastrealm } ); return 1; endprogram diff --git a/testsuite/pol/testpkgs/char/cleanup.src b/testsuite/pol/testpkgs/char/cleanup.src index ece6e11dc..c6aa22b4f 100644 --- a/testsuite/pol/testpkgs/char/cleanup.src +++ b/testsuite/pol/testpkgs/char/cleanup.src @@ -1,6 +1,6 @@ use uo; -var a:=FindAccount("test"); -if (a) - a.deletecharacter(1); +var a := FindAccount( "test" ); +if ( a ) + a.deletecharacter( 1 ); a.delete(); endif diff --git a/testsuite/pol/testpkgs/char/setup.src b/testsuite/pol/testpkgs/char/setup.src index ad271985f..dbbc22e61 100644 --- a/testsuite/pol/testpkgs/char/setup.src +++ b/testsuite/pol/testpkgs/char/setup.src @@ -3,8 +3,8 @@ use uo; include "testutil"; -var char:=createAccountWithChar("test", "pass"); -if (!char) +var char := createAccountWithChar( "test", "pass" ); +if ( !char ) return char; endif diff --git a/testsuite/pol/testpkgs/char/test_aos.src b/testsuite/pol/testpkgs/char/test_aos.src index 3b246efa7..d5a55a761 100644 --- a/testsuite/pol/testpkgs/char/test_aos.src +++ b/testsuite/pol/testpkgs/char/test_aos.src @@ -7,178 +7,176 @@ var char; var backpack; program chartests() - var a:=FindAccount("test"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "test" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - if (char.backpack) - DestroyItem(char.backpack); + if ( char.backpack ) + DestroyItem( char.backpack ); endif - backpack:=CreateItemAtLocation(0,0,0,0xE75); - var res:=EquipItem(char,backpack); - if (!res) - return ret_error("Failed to equip backpack "+backpack+" "+res); + backpack := CreateItemAtLocation( 0, 0, 0, 0xE75 ); + var res := EquipItem( char, backpack ); + if ( !res ) + return ret_error( "Failed to equip backpack " + backpack + " " + res ); endif return 1; endprogram -function reset(aos, cap) +function reset( aos, cap ) foreach mod in aos - char.set_member(mod+"_mod", 0); - if (cap) - char.set_member(mod+"_cap_mod", 20); - backpack.set_member(mod+"_cap_mod", 2); + char.set_member( mod + "_mod", 0 ); + if ( cap ) + char.set_member( mod + "_cap_mod", 20 ); + backpack.set_member( mod + "_cap_mod", 2 ); endif - backpack.set_member(mod+"_mod", 0); + backpack.set_member( mod + "_mod", 0 ); endforeach endfunction -function apply_to_equipped(aos) +function apply_to_equipped( aos ) foreach mod in aos - backpack.set_member(mod+"_mod", 10); - if (char.get_member(mod) != 10) - return ret_error("failed to apply equipped aos prop: {} ({})".format(mod,char.get_member(mod))); + backpack.set_member( mod + "_mod", 10 ); + if ( char.get_member( mod ) != 10 ) + return ret_error( "failed to apply equipped aos prop: {} ({})".format( mod, + char.get_member( mod ) ) ); endif endforeach return 1; endfunction -function apply_to_char(aos, cap) +function apply_to_char( aos, cap ) foreach mod in aos - var new:=20; - if (cap) - char.set_member(mod+"_mod", 15); // cap needs to trigger - new:=22; + var new := 20; + if ( cap ) + char.set_member( mod + "_mod", 15 ); // cap needs to trigger + new := 22; else - char.set_member(mod+"_mod", 10); + char.set_member( mod + "_mod", 10 ); endif - if (char.get_member(mod) != new) - return ret_error("failed to apply aos prop mod: {} ({})".format(mod,char.get_member(mod))); + if ( char.get_member( mod ) != new ) + return ret_error( "failed to apply aos prop mod: {} ({})".format( mod, char.get_member( mod ) ) ); endif endforeach return 1; endfunction -function unequip_aos_item(aos, cap) - var new:=10; - if (cap) - new:=15; +function unequip_aos_item( aos, cap ) + var new := 10; + if ( cap ) + new := 15; endif - MoveObjectToLocation(backpack, char.x, char.y, char.z, char.realm, MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( backpack, char.x, char.y, char.z, char.realm, MOVEOBJECT_FORCELOCATION ); foreach mod in aos - if (char.get_member(mod) != new) - var res:=ret_error("failed to unequip aos prop mod: {} ({})".format(mod,char.get_member(mod))); - EquipItem(char,backpack); + if ( char.get_member( mod ) != new ) + var res := ret_error( "failed to unequip aos prop mod: {} ({})".format( mod, + char.get_member( mod ) ) ); + EquipItem( char, backpack ); return res; endif endforeach return 1; endfunction -function equip_aos_item(aos, cap) - var new:=20; - if (cap) - new:=22; +function equip_aos_item( aos, cap ) + var new := 20; + if ( cap ) + new := 22; endif - EquipItem(char,backpack); + EquipItem( char, backpack ); foreach mod in aos - if (char.get_member(mod) != new) - return ret_error("failed to equip aos prop mod: {} ({})".format(mod,char.get_member(mod))); + if ( char.get_member( mod ) != new ) + return ret_error( "failed to equip aos prop mod: {} ({})".format( mod, char.get_member( mod ) ) ); endif endforeach return 1; endfunction - exported function apply_aos_damage_mod() - var aos:={ - "damage_cold", "damage_energy", "damage_fire", "damage_physical", "damage_poison"}; - reset(aos,0); - var res:= apply_to_equipped(aos); - if (!res) + var aos := { "damage_cold", "damage_energy", "damage_fire", "damage_physical", "damage_poison" }; + reset( aos, 0 ); + var res := apply_to_equipped( aos ); + if ( !res ) return res; endif - res:= apply_to_char(aos, 0); - if (!res) + res := apply_to_char( aos, 0 ); + if ( !res ) return res; endif - res:= unequip_aos_item(aos, 0); - if (!res) + res := unequip_aos_item( aos, 0 ); + if ( !res ) return res; endif - res:= equip_aos_item(aos, 0); - if (!res) + res := equip_aos_item( aos, 0 ); + if ( !res ) return res; endif return 1; -endfunction +endfunction exported function apply_aos_resist_mod() - var aos:={ - "resist_cold", "resist_energy", "resist_fire", "resist_physical", "resist_poison"}; - reset(aos,1); - var res:= apply_to_equipped(aos); - if (!res) + var aos := { "resist_cold", "resist_energy", "resist_fire", "resist_physical", "resist_poison" }; + reset( aos, 1 ); + var res := apply_to_equipped( aos ); + if ( !res ) return res; endif - res:= apply_to_char(aos, 1); - if (!res) + res := apply_to_char( aos, 1 ); + if ( !res ) return res; endif - res:= unequip_aos_item(aos, 1); - if (!res) + res := unequip_aos_item( aos, 1 ); + if ( !res ) return res; endif - res:= equip_aos_item(aos, 1); - if (!res) + res := equip_aos_item( aos, 1 ); + if ( !res ) return res; endif return 1; -endfunction +endfunction exported function apply_aos_misc_mod_cap() - var aos:={ - "defence_increase"}; - reset(aos,1); - var res:= apply_to_equipped(aos); - if (!res) + var aos := { "defence_increase" }; + reset( aos, 1 ); + var res := apply_to_equipped( aos ); + if ( !res ) return res; endif - res:= apply_to_char(aos, 1); - if (!res) + res := apply_to_char( aos, 1 ); + if ( !res ) return res; endif - res:= unequip_aos_item(aos, 1); - if (!res) + res := unequip_aos_item( aos, 1 ); + if ( !res ) return res; endif - res:= equip_aos_item(aos, 1); - if (!res) + res := equip_aos_item( aos, 1 ); + if ( !res ) return res; endif return 1; -endfunction +endfunction exported function apply_aos_misc_mod() - var aos:={ - "faster_cast_recovery", "faster_casting" , "hit_chance", "lower_mana_cost", "lower_reagent_cost", "luck", "spell_damage_increase", "swing_speed_increase"}; - reset(aos,0); - var res:= apply_to_equipped(aos); - if (!res) + var aos := { "faster_cast_recovery", "faster_casting", "hit_chance", "lower_mana_cost", "lower_reagent_cost", + "luck", "spell_damage_increase", "swing_speed_increase" }; + reset( aos, 0 ); + var res := apply_to_equipped( aos ); + if ( !res ) return res; endif - res:= apply_to_char(aos, 0); - if (!res) + res := apply_to_char( aos, 0 ); + if ( !res ) return res; endif - res:= unequip_aos_item(aos, 0); - if (!res) + res := unequip_aos_item( aos, 0 ); + if ( !res ) return res; endif - res:= equip_aos_item(aos, 0); - if (!res) + res := equip_aos_item( aos, 0 ); + if ( !res ) return res; endif return 1; -endfunction +endfunction diff --git a/testsuite/pol/testpkgs/char/test_chr.src b/testsuite/pol/testpkgs/char/test_chr.src index 0b3096aba..c418db74b 100644 --- a/testsuite/pol/testpkgs/char/test_chr.src +++ b/testsuite/pol/testpkgs/char/test_chr.src @@ -7,127 +7,127 @@ var char; var backpack; program chartests() - var a:=FindAccount("test"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "test" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - if (char.backpack) - DestroyItem(char.backpack); + if ( char.backpack ) + DestroyItem( char.backpack ); endif - backpack:=CreateItemAtLocation(0,0,0,0xE75); - var res:=EquipItem(char,backpack); - if (!res) - return ret_error("Failed to equip backpack "+backpack+" "+res); + backpack := CreateItemAtLocation( 0, 0, 0, 0xE75 ); + var res := EquipItem( char, backpack ); + if ( !res ) + return ret_error( "Failed to equip backpack " + backpack + " " + res ); endif return 1; endprogram function clean_backpack() - var items:=EnumerateItemsInContainer(char.backpack, ENUMERATE_ROOT_ONLY); + var items := EnumerateItemsInContainer( char.backpack, ENUMERATE_ROOT_ONLY ); foreach item in items - DestroyItem(item); + DestroyItem( item ); endforeach endfunction exported function set_name() - setname(char, "test"); - if(char.name != "test") - return ret_error("failed to rename char: "+char.name); + setname( char, "test" ); + if ( char.name != "test" ) + return ret_error( "failed to rename char: " + char.name ); endif return 1; endfunction exported function place_item_backpack() clean_backpack(); - var item:=CreateItemAtLocation(char.x,char.y,char.z, 0x3e3f, 1, char.realm); - item.movable:=1; - var res:=MoveItemToContainer(item, char.backpack); - if (!res) - return ret_error("failed to move item: "+res); + var item := CreateItemAtLocation( char.x, char.y, char.z, 0x3e3f, 1, char.realm ); + item.movable := 1; + var res := MoveItemToContainer( item, char.backpack ); + if ( !res ) + return ret_error( "failed to move item: " + res ); endif - if (item.realm != char.realm) - return ret_error("item realm is not the same as char realm: "+item.realm); + if ( item.realm != char.realm ) + return ret_error( "item realm is not the same as char realm: " + item.realm ); endif return 1; endfunction exported function create_in_backpack() clean_backpack(); - var old_weight:=char.weight; - var item:=CreateItemInContainer(char.backpack, 0xf3f, 1); - var item_weight:=item.weight; - if (!item) - return ret_error("failed to create item: "+item); + var old_weight := char.weight; + var item := CreateItemInContainer( char.backpack, 0xf3f, 1 ); + var item_weight := item.weight; + if ( !item ) + return ret_error( "failed to create item: " + item ); endif - var item2:=CreateItemInContainer(char.backpack, 0xf3f, 1); - if (!item2) - return ret_error("failed to create item2: "+item2); + var item2 := CreateItemInContainer( char.backpack, 0xf3f, 1 ); + if ( !item2 ) + return ret_error( "failed to create item2: " + item2 ); endif - if (item.serial != item2.serial) - return ret_error("items did not stack"); + if ( item.serial != item2.serial ) + return ret_error( "items did not stack" ); endif - if (item.amount != 2) - return ret_error("item amount not 2: "+item.amount); - endif - var exp_weight:=item_weight*2+ old_weight; - if (char.weight != exp_weight) - return ret_error("char weight {} != {}".format(char.weight, exp_weight)); + if ( item.amount != 2 ) + return ret_error( "item amount not 2: " + item.amount ); + endif + var exp_weight := item_weight * 2 + old_weight; + if ( char.weight != exp_weight ) + return ret_error( "char weight {} != {}".format( char.weight, exp_weight ) ); endif return 1; endfunction exported function create_in_backpack_loc() clean_backpack(); - var item := CreateItemInBackpack(char, 0xf3f, 1, 80, 90); - if (!item) - return ret_error($"Could not create item: {item}"); - elseif (item.x != 80 || item.y != 90) + var item := CreateItemInBackpack( char, 0xf3f, 1, 80, 90 ); + if ( !item ) + return ret_error( $"Could not create item: {item}" ); + elseif ( item.x != 80 || item.y != 90 ) var msg := $"Item not in expected location: item.x ({item.x}) != 80 or item.y ({item.y}) != 90"; - DestroyItem(item); - return ret_error(msg); + DestroyItem( item ); + return ret_error( msg ); endif return 1; endfunction exported function test_buffs() var err; - err := char.addBuff(1029, 30, 1075814, 1075815, "1234 5678"); - if (err == error) - return ret_error($"Could not add buff: {err}"); + err := char.addBuff( 1029, 30, 1075814, 1075815, "1234 5678" ); + if ( err == error ) + return ret_error( $"Could not add buff: {err}" ); endif - if (char.buffs.size() != 1 || !char.buffs.exists(1029)) - return ret_error($"Active buff not listed: {char.buffs}"); + if ( char.buffs.size() != 1 || !char.buffs.exists( 1029 ) ) + return ret_error( $"Active buff not listed: {char.buffs}" ); endif - - err := char.delBuff(1029); - if (err == error) - return ret_error($"Could not delete buff: {err}"); + + err := char.delBuff( 1029 ); + if ( err == error ) + return ret_error( $"Could not delete buff: {err}" ); endif - if (char.buffs.size() != 0) - return ret_error($"Active buffs not empty: {char.buffs}"); + if ( char.buffs.size() != 0 ) + return ret_error( $"Active buffs not empty: {char.buffs}" ); endif - - //Try clearing buffs - err := char.addBuff(1029, 30, 1075814, 1075815, "1234 5678"); - if (err == error) - return ret_error($"Could not add buff: {err}"); + + // Try clearing buffs + err := char.addBuff( 1029, 30, 1075814, 1075815, "1234 5678" ); + if ( err == error ) + return ret_error( $"Could not add buff: {err}" ); endif err := char.clearBuffs(); - if (err == error) - return ret_error($"Could not clear buffs: {err}"); + if ( err == error ) + return ret_error( $"Could not clear buffs: {err}" ); endif - - //Try deleting an inexistent buff, should fail - err := char.delBuff(1029); - if (err != error) - return ret_error($"Deleting an inexistent buff didn't cause an error: {err}"); + + // Try deleting an inexistent buff, should fail + err := char.delBuff( 1029 ); + if ( err != error ) + return ret_error( $"Deleting an inexistent buff didn't cause an error: {err}" ); endif - - //Try clearing buffs when there are none + + // Try clearing buffs when there are none err := char.clearBuffs(); - if (err == error) - return ret_error($"Could not clear buffs: {err}"); + if ( err == error ) + return ret_error( $"Could not clear buffs: {err}" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/client/cleanup.src b/testsuite/pol/testpkgs/client/cleanup.src index 5023d50b3..9dd708764 100644 --- a/testsuite/pol/testpkgs/client/cleanup.src +++ b/testsuite/pol/testpkgs/client/cleanup.src @@ -3,29 +3,29 @@ use os; include "testutil"; include "communication"; -foreach multi in (ListMultisInBox(0,0,-200,10000,10000,200)) - DestroyMulti(multi); +foreach multi in ( ListMultisInBox( 0, 0, -200, 10000, 10000, 200 ) ) + DestroyMulti( multi ); endforeach var clientcon := getClientConnection(); -if (clientcon) - clientcon.sendevent(struct{todo:="exit"}); - WaitForClient(0,{EVT_EXIT},2); +if ( clientcon ) + clientcon.sendevent( struct{ todo := "exit" } ); + WaitForClient( 0, { EVT_EXIT }, 2 ); endif -var a:=FindAccount("testclient0"); -if (a) - a.deletecharacter(1); +var a := FindAccount( "testclient0" ); +if ( a ) + a.deletecharacter( 1 ); a.delete(); endif -a:=FindAccount("testclient1"); -if (a) - a.deletecharacter(1); +a := FindAccount( "testclient1" ); +if ( a ) + a.deletecharacter( 1 ); a.delete(); endif -var res := GetGlobalProperty("#SnoopingNpc"); -if (res) - var mob := SystemFindObjectBySerial(res); - MoveObjectToLocation(mob, 0, 0, 0, flags := MOVEOBJECT_FORCELOCATION); +var res := GetGlobalProperty( "#SnoopingNpc" ); +if ( res ) + var mob := SystemFindObjectBySerial( res ); + MoveObjectToLocation( mob, 0, 0, 0, flags := MOVEOBJECT_FORCELOCATION ); mob.Kill(); endif diff --git a/testsuite/pol/testpkgs/client/clientconnection.src b/testsuite/pol/testpkgs/client/clientconnection.src index 93814965d..066202fc4 100644 --- a/testsuite/pol/testpkgs/client/clientconnection.src +++ b/testsuite/pol/testpkgs/client/clientconnection.src @@ -1,26 +1,26 @@ use os; use uo; -program clientconn(con, testscript) - SetGlobalProperty("#clientcon", getpid()); - while (1) - var ev:=Wait_For_Event(10); - if (!ev) +program clientconn( con, testscript ) + SetGlobalProperty( "#clientcon", getpid() ); + while ( 1 ) + var ev := Wait_For_Event( 10 ); + if ( !ev ) continue; endif - if (ev.?todo) - var json:=PackJson(ev); - syslog(" to client: "+json,0); - con.transmit(json); - if (ev.todo=="exit") + if ( ev.?todo ) + var json := PackJson( ev ); + syslog( " to client: " + json, 0 ); + con.transmit( json ); + if ( ev.todo == "exit" ) break; endif - elseif (ev.?ownership) - testscript:=ev.ownership; + elseif ( ev.?ownership ) + testscript := ev.ownership; else - syslog(" from client: "+ev,0); - var e:=UnpackJson(ev.value); - testscript.sendevent(e); + syslog( " from client: " + ev, 0 ); + var e := UnpackJson( ev.value ); + testscript.sendevent( e ); endif endwhile endprogram diff --git a/testsuite/pol/testpkgs/client/communication.inc b/testsuite/pol/testpkgs/client/communication.inc index cf388f36e..ad56d3809 100644 --- a/testsuite/pol/testpkgs/client/communication.inc +++ b/testsuite/pol/testpkgs/client/communication.inc @@ -2,7 +2,7 @@ use os; use attributes; use vitals; -//see pyuo/brain.py method typestr() +// see pyuo/brain.py method typestr() const EVT_INIT := "init"; const EVT_EXIT := "exit"; const EVT_HP_CHANGED := "hp_changed"; @@ -31,8 +31,8 @@ const EVT_OWNCREATE := "owncreate"; const EVT_GUMP := "gump"; function clientTestActive() - var testclient:=GetEnvironmentVariable("POLCORE_TESTCLIENT")=="TRUE"; - if (!testclient) + var testclient := GetEnvironmentVariable( "POLCORE_TESTCLIENT" ) == "TRUE"; + if ( !testclient ) return 0; endif return 1; @@ -40,34 +40,34 @@ endfunction // get client connection auxiliary scriptref and transfers ownership, meaning client events get send to the calling script function getClientConnection() - var res:=GetGlobalProperty("#clientcon"); - var proc := GetProcess(res); - proc.sendevent(struct{ownership:=GetProcess()}); + var res := GetGlobalProperty( "#clientcon" ); + var proc := GetProcess( res ); + proc.sendevent( struct{ ownership := GetProcess() } ); return proc; endfunction // wait for events of given types and of given client id -function waitForClient(id, types, timeout := 10) - while (1) - var ev:=Wait_For_Event(timeout); - if (!ev) - return ret_error("no signal received"); +function waitForClient( id, types, timeout := 10 ) + while ( 1 ) + var ev := Wait_For_Event( timeout ); + if ( !ev ) + return ret_error( "no signal received" ); endif - if (ev.id != id || !(ev.type in types)) + if ( ev.id != id || !( ev.type in types ) ) continue; endif return ev; endwhile endfunction -function waitForClients(types) +function waitForClients( types ) // wait for events of given types of any client - while (1) - var ev:=Wait_For_Event(10); - if (!ev) - return ret_error("no signal received"); + while ( 1 ) + var ev := Wait_For_Event( 10 ); + if ( !ev ) + return ret_error( "no signal received" ); endif - if (!(ev.type in types)) + if ( !( ev.type in types ) ) continue; endif return ev; diff --git a/testsuite/pol/testpkgs/client/onSnoop.src b/testsuite/pol/testpkgs/client/onSnoop.src index 2abb25c43..df019a7ad 100644 --- a/testsuite/pol/testpkgs/client/onSnoop.src +++ b/testsuite/pol/testpkgs/client/onSnoop.src @@ -1,5 +1,5 @@ use uo; -program onSnoop(who, item) - SendViewContainer(who, item); +program onSnoop( who, item ) + SendViewContainer( who, item ); endprogram diff --git a/testsuite/pol/testpkgs/client/packethook.src b/testsuite/pol/testpkgs/client/packethook.src index e6f3f87b2..65658f598 100644 --- a/testsuite/pol/testpkgs/client/packethook.src +++ b/testsuite/pol/testpkgs/client/packethook.src @@ -3,4 +3,3 @@ use uo; program packethook() return 1; endprogram - diff --git a/testsuite/pol/testpkgs/client/setup.src b/testsuite/pol/testpkgs/client/setup.src index 6b6f53737..8dd65fe1b 100644 --- a/testsuite/pol/testpkgs/client/setup.src +++ b/testsuite/pol/testpkgs/client/setup.src @@ -5,113 +5,123 @@ include "testutil"; include "communication"; program setup() - if (!clientTestActive()) - syslog("NO CLIENT TESTS",0); + if ( !clientTestActive() ) + syslog( "NO CLIENT TESTS", 0 ); return IGNORE_TEST; endif // create two accounts with one char - var char:=createAccountWithChar("testclient0", "pass"); - var char2:=createAccountWithChar("testclient1", "pass"); - if (!char || !char2) + var char := createAccountWithChar( "testclient0", "pass" ); + var char2 := createAccountWithChar( "testclient1", "pass" ); + if ( !char || !char2 ) return !char ? char : char2; endif - var res:=setup_char(0,char); - if (!res) + var res := setup_char( 0, char ); + if ( !res ) return res; endif - res := setup_char(1,char2); - if (!res) + res := setup_char( 1, char2 ); + if ( !res ) return res; endif // start auxiliary script for client communication - var i:=1; - while (1) - var res := OpenConnection("127.0.0.1",50000,"clientconnection",GetProcess(),1,1); - if (res) + var i := 1; + while ( 1 ) + var res := OpenConnection( "127.0.0.1", 50000, "clientconnection", GetProcess(), 1, 1 ); + if ( res ) break; endif - sleep(1); + sleep( 1 ); ++i; - if (i>10) - return ret_error("Failed to connect to testclient"); + if ( i > 10 ) + return ret_error( "Failed to connect to testclient" ); endif endwhile var clientcon; - while (1) - var res:=GetGlobalProperty("#clientcon"); - if (res) - clientcon:=GetProcess(res); + while ( 1 ) + var res := GetGlobalProperty( "#clientcon" ); + if ( res ) + clientcon := GetProcess( res ); break; endif - sleepms(5); + sleepms( 5 ); endwhile // let both clients connect - clientcon.sendevent(struct{todo:="connect",account:="testclient0", psw:="pass", chrindex:=0, name:="Client1", id:=0}); - clientcon.sendevent(struct{todo:="connect",account:="testclient1", psw:="pass", chrindex:=0, name:="Client2", id:=1}); - var init0:=0,init1:=0; - while (1) - var ev:=WaitForClients({EVT_INIT}); - if (!ev) - return ret_error("Failed to connect"); + clientcon.sendevent( struct{ todo := "connect", + account := "testclient0", + psw := "pass", + chrindex := 0, + name := "Client1", + id := 0 } ); + clientcon.sendevent( struct{ todo := "connect", + account := "testclient1", + psw := "pass", + chrindex := 0, + name := "Client2", + id := 1 } ); + var init0 := 0, init1 := 0; + while ( 1 ) + var ev := WaitForClients( { EVT_INIT } ); + if ( !ev ) + return ret_error( "Failed to connect" ); endif - if (ev.id==0) - init0:=1; - elseif (ev.id==1) - init1:=1; + if ( ev.id == 0 ) + init0 := 1; + elseif ( ev.id == 1 ) + init1 := 1; endif - if (init0 && init1 && char.client && char2.client) + if ( init0 && init1 && char.client && char2.client ) break; endif endwhile - update_vitals(char); - update_vitals(char2); - MoveObjectToLocation(char, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - MoveObjectToLocation(char2, 200,1,1,flags:=MOVEOBJECT_FORCELOCATION); + update_vitals( char ); + update_vitals( char2 ); + MoveObjectToLocation( char, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + MoveObjectToLocation( char2, 200, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); // wait for initinal vital signals - var vital0:={},vital1:={}; - while (1) - var ev:=WaitForClients({EVT_HP_CHANGED,EVT_MANA_CHANGED,EVT_STAM_CHANGED}); - if (!ev) - return ret_error("Failed to wait for vital update"); + var vital0 := {}, vital1 := {}; + while ( 1 ) + var ev := WaitForClients( { EVT_HP_CHANGED, EVT_MANA_CHANGED, EVT_STAM_CHANGED } ); + if ( !ev ) + return ret_error( "Failed to wait for vital update" ); endif - if (ev.id==0 && ev.serial==char.serial) - if (!(ev.type in vital0)) - vital0.append(ev.type); + if ( ev.id == 0 && ev.serial == char.serial ) + if ( !( ev.type in vital0 ) ) + vital0.append( ev.type ); endif - elseif (ev.id==1 && ev.serial==char2.serial) - if (!(ev.type in vital1)) - vital1.append(ev.type); + elseif ( ev.id == 1 && ev.serial == char2.serial ) + if ( !( ev.type in vital1 ) ) + vital1.append( ev.type ); endif endif - if (len(vital0)==3 && len(vital1)==3) + if ( len( vital0 ) == 3 && len( vital1 ) == 3 ) break; endif endwhile return 1; endprogram -function setup_char(id, char) - setname(char,"Client"+id); - if (char.backpack) - DestroyItem(char.backpack); +function setup_char( id, char ) + setname( char, "Client" + id ); + if ( char.backpack ) + DestroyItem( char.backpack ); endif - var backpack:=CreateItemAtLocation(0,0,0,0xE75); - var res:=EquipItem(char,backpack); - if (!res) - return ret_error("Failed to equip backpack "+backpack+" "+res); + var backpack := CreateItemAtLocation( 0, 0, 0, 0xE75 ); + var res := EquipItem( char, backpack ); + if ( !res ) + return ret_error( "Failed to equip backpack " + backpack + " " + res ); endif - setAttributeBaseValue(char,"STR",1000); - setAttributeBaseValue(char,"INT",1000); - setAttributeBaseValue(char,"DEX",1000); + setAttributeBaseValue( char, "STR", 1000 ); + setAttributeBaseValue( char, "INT", 1000 ); + setAttributeBaseValue( char, "DEX", 1000 ); return 1; endfunction -function update_vitals(char) - recalcVitals(char); - setVital(char, "Hits", getVitalMaximumValue(char,"Hits")); - setVital(char, "Mana", getVitalMaximumValue(char,"Mana")); - setVital(char, "Stamina", getVitalMaximumValue(char,"Stamina")); +function update_vitals( char ) + recalcVitals( char ); + setVital( char, "Hits", getVitalMaximumValue( char, "Hits" ) ); + setVital( char, "Mana", getVitalMaximumValue( char, "Mana" ) ); + setVital( char, "Stamina", getVitalMaximumValue( char, "Stamina" ) ); endfunction diff --git a/testsuite/pol/testpkgs/client/test_client.src b/testsuite/pol/testpkgs/client/test_client.src index 0bd564b14..d2548c532 100644 --- a/testsuite/pol/testpkgs/client/test_client.src +++ b/testsuite/pol/testpkgs/client/test_client.src @@ -10,44 +10,44 @@ var char2; var clientcon := getClientConnection(); program chartests() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - a:=FindAccount("testclient1"); - char2:=a.getcharacter(1); - if (!char2) - return ret_error("Could not find char2 at slot 1"); + a := FindAccount( "testclient1" ); + char2 := a.getcharacter( 1 ); + if ( !char2 ) + return ret_error( "Could not find char2 at slot 1" ); endif endprogram exported function test_client_properties() - if (char.client.acctname != "testclient0") - return ret_error("Incorrect account name on char 1, expected 'testclient0"); - elseif (char.client.acct.name != "testclient0") - return ret_error("Incorrect account reference returned on char.client.acct, expected account with name 'testclient0'"); - elseif (char2.client.acct.name != "testclient1") - return ret_error("Incorrect account reference returned on char2.client.acct, expected account with name 'testclient1'"); - elseif (char2.client.acctname != "testclient1") - return ret_error("Incorrect account name on char 2, expected 'testclient1"); - elseif (char.client.multi != uninit) // testing knownObjMember: acct is a known member but not implemented on client - return ret_error("Expected char.client.multi to be uninit object, got " + char.client.multi); - elseif (char.client.unknownprop != uninit) // testing of objmember that is not known - return ret_error("Expected char.client.unknownprop to be uninit object, got " + char.client.unknownprop); + if ( char.client.acctname != "testclient0" ) + return ret_error( "Incorrect account name on char 1, expected 'testclient0" ); + elseif ( char.client.acct.name != "testclient0" ) + return ret_error( "Incorrect account reference returned on char.client.acct, expected account with name 'testclient0'" ); + elseif ( char2.client.acct.name != "testclient1" ) + return ret_error( "Incorrect account reference returned on char2.client.acct, expected account with name 'testclient1'" ); + elseif ( char2.client.acctname != "testclient1" ) + return ret_error( "Incorrect account name on char 2, expected 'testclient1" ); + elseif ( char.client.multi != uninit ) // testing knownObjMember: acct is a known member but not implemented on client + return ret_error( "Expected char.client.multi to be uninit object, got " + char.client.multi ); + elseif ( char.client.unknownprop != uninit ) // testing of objmember that is not known + return ret_error( "Expected char.client.unknownprop to be uninit object, got " + char.client.unknownprop ); endif return 1; endfunction exported function say_something() Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="speech", arg:="Hello Test", id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_SPEECH}); - if (!ev) + clientcon.sendevent( struct{ todo := "speech", arg := "Hello Test", id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_SPEECH } ); + if ( !ev ) return ev; endif - if (ev.msg=="Hello Test") + if ( ev.msg == "Hello Test" ) break; endif endwhile @@ -55,122 +55,111 @@ exported function say_something() endfunction exported function say_something_with_tokens() - var arg := struct{ - text := "Hello Test", - tokens:= {60, 255} - }; + var arg := struct{ text := "Hello Test", tokens := { 60, 255 } }; // This needs to match what gets echo'ed from test_speech's NPC script ai_speech.src var expected_message := $"source=[npc] text=[{arg.text}] tokens=[{arg.tokens}]"; - var npc := CreateNpcFromTemplate(":testnpc:test_speech", char.x + 1, char.y + 1, char.z, realm := char.realm, forcelocation := 1); - if (!npc) - return ret_error($"Could not create npc: {npc.errortext}"); + var npc := CreateNpcFromTemplate( ":testnpc:test_speech", char.x + 1, char.y + 1, char.z, + realm := char.realm, forcelocation := 1 ); + if ( !npc ) + return ret_error( $"Could not create npc: {npc.errortext}" ); endif Clear_Event_Queue(); - clientcon.sendevent(struct{ - todo := "speech", - arg := arg, - id := 0 - }); + clientcon.sendevent( struct{ todo := "speech", arg := arg, id := 0 } ); - while (1) - var ev:=waitForClient(0, {EVT_SPEECH}); - if (!ev) - MoveObjectToLocation(npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION); + while ( 1 ) + var ev := waitForClient( 0, { EVT_SPEECH } ); + if ( !ev ) + MoveObjectToLocation( npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); return ev; endif - if (ev.msg == expected_message) + if ( ev.msg == expected_message ) break; endif endwhile - MoveObjectToLocation(npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); return 1; endfunction exported function test_speechtoken_crash() - var arg := struct{ - text := "Hello Test", - tokens:= {60, 255} - }; + var arg := struct{ text := "Hello Test", tokens := { 60, 255 } }; // This needs to match what gets echo'ed from EchoItem's control script control_echo.src var expected_message := $"source=[item] text=[{arg.text}] tokens=[{arg.tokens}]"; - var npc := CreateNpcFromTemplate(":testnpc:test_speech", char.x + 1, char.y + 1, char.z, override_properties := struct{ CProps := dictionary{ "EventSize" -> 0 } }, realm := char.realm, forcelocation := 1); - if (!npc) - return ret_error($"Could not create npc: {npc.errortext}"); + var npc := CreateNpcFromTemplate( ":testnpc:test_speech", char.x + 1, char.y + 1, char.z, override_properties := struct{ + CProps := dictionary{ "EventSize" -> 0 } + }, realm := char.realm, forcelocation := 1 ); + if ( !npc ) + return ret_error( $"Could not create npc: {npc.errortext}" ); endif - var item := CreateItemAtLocation( char.x+2, char.y+2, char.z, "EchoItem", realm := char.realm ); - if (!item) - MoveObjectToLocation(npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION); + var item := CreateItemAtLocation( char.x + 2, char.y + 2, char.z, "EchoItem", realm := char.realm ); + if ( !item ) + MoveObjectToLocation( npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - return ret_error($"Could not create item: {item.errortext}"); + return ret_error( $"Could not create item: {item.errortext}" ); endif Clear_Event_Queue(); - clientcon.sendevent(struct{ - todo := "speech", - arg := arg, - id := 0 - }); + clientcon.sendevent( struct{ todo := "speech", arg := arg, id := 0 } ); - while (1) - var ev:=waitForClient(0, {EVT_SPEECH}); - if (!ev) - MoveObjectToLocation(npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION); + while ( 1 ) + var ev := waitForClient( 0, { EVT_SPEECH } ); + if ( !ev ) + MoveObjectToLocation( npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - DestroyItem(item); + DestroyItem( item ); return ev; endif // NPC handles events first, then items. - if (ev.msg == expected_message) + if ( ev.msg == expected_message ) break; endif endwhile - MoveObjectToLocation(npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( npc, 80, 80, 0, flags := MOVEOBJECT_FORCELOCATION ); npc.kill(); - DestroyItem(item); + DestroyItem( item ); return 1; endfunction exported function move_turn_water() - MoveObjectToLocation(char, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - char.facing:=1; + MoveObjectToLocation( char, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + char.facing := 1; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="move",arg:=6,id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_MOVED}); - if (!ev) + clientcon.sendevent( struct{ todo := "move", arg := 6, id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_MOVED } ); + if ( !ev ) return ev; endif - if (!ev.ack) - return ret_error("failed to turn"); + if ( !ev.ack ) + return ret_error( "failed to turn" ); endif - if (ev.pos != {1,1,1,6}) - return ret_error("wrong pos"); + if ( ev.pos != { 1, 1, 1, 6 } ) + return ret_error( "wrong pos" ); endif break; endwhile - clientcon.sendevent(struct{todo:="move",arg:=6,id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_MOVED}); - if (!ev) + clientcon.sendevent( struct{ todo := "move", arg := 6, id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_MOVED } ); + if ( !ev ) return ev; endif - if (ev.ack) - return ret_error("move in water succeeded"); + if ( ev.ack ) + return ret_error( "move in water succeeded" ); endif - if (ev.pos != {1,1,1,6}) - return ret_error("wrong pos"); + if ( ev.pos != { 1, 1, 1, 6 } ) + return ret_error( "wrong pos" ); endif break; endwhile @@ -178,20 +167,20 @@ exported function move_turn_water() endfunction exported function move_ground() - MoveObjectToLocation(char, 100,100,1,flags:=MOVEOBJECT_FORCELOCATION); - char.facing:=1; + MoveObjectToLocation( char, 100, 100, 1, flags := MOVEOBJECT_FORCELOCATION ); + char.facing := 1; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="move",arg:=1,id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_MOVED}); - if (!ev) + clientcon.sendevent( struct{ todo := "move", arg := 1, id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_MOVED } ); + if ( !ev ) return ev; endif - if (!ev.ack) - return ret_error("failed to move"); + if ( !ev.ack ) + return ret_error( "failed to move" ); endif - if (ev.pos != {101,99,1,1}) - return ret_error("wrong pos"); + if ( ev.pos != { 101, 99, 1, 1 } ) + return ret_error( "wrong pos" ); endif break; endwhile @@ -199,24 +188,24 @@ exported function move_ground() endfunction exported function move_realm() - MoveObjectToLocation(char, 100,100,1,flags:=MOVEOBJECT_FORCELOCATION); - while (1) - var ev:=waitForClient(0, {EVT_OWNCREATE}); - if (!ev) + MoveObjectToLocation( char, 100, 100, 1, flags := MOVEOBJECT_FORCELOCATION ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_OWNCREATE } ); + if ( !ev ) return ev; endif break; endwhile Clear_Event_Queue(); - MoveObjectToLocation(char, 100,100,1,"britannia2",MOVEOBJECT_FORCELOCATION); - while (1) - var ev:=waitForClient(0, {EVT_NEW_SUBSERVER}); - if (!ev) + MoveObjectToLocation( char, 100, 100, 1, "britannia2", MOVEOBJECT_FORCELOCATION ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_NEW_SUBSERVER } ); + if ( !ev ) return ev; endif break; endwhile - MoveObjectToLocation(char, 100,100,1,flags:=MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( char, 100, 100, 1, flags := MOVEOBJECT_FORCELOCATION ); Clear_Event_Queue(); return 1; endfunction @@ -225,19 +214,19 @@ endfunction Test that with WarmodeInhibitsRegen=3 (NPCs Only), a _PC_ in war mode _will_ regenerate health. */ exported function client_warmodeinhibitsregen() - char.setwarmode(1); - SetVital( char, "Life", GetVital( char, "Life" ) / 2); + char.setwarmode( 1 ); + SetVital( char, "Life", GetVital( char, "Life" ) / 2 ); var damaged_health := GetVital( char, "Life" ); var waited_health; for i := 1 to 10 waited_health := GetVital( char, "Life" ); - if (damaged_health != waited_health) - char.setwarmode(0); + if ( damaged_health != waited_health ) + char.setwarmode( 0 ); return 1; endif - Sleep(1); + Sleep( 1 ); endfor - char.setwarmode(0); - return ret_error($"PC health did not change between sleeping: {damaged_health} -> {waited_health}"); + char.setwarmode( 0 ); + return ret_error( $"PC health did not change between sleeping: {damaged_health} -> {waited_health}" ); endfunction diff --git a/testsuite/pol/testpkgs/client/test_client_boat.src b/testsuite/pol/testpkgs/client/test_client_boat.src index 87ef2f978..d5d8b85d4 100644 --- a/testsuite/pol/testpkgs/client/test_client_boat.src +++ b/testsuite/pol/testpkgs/client/test_client_boat.src @@ -11,87 +11,87 @@ var char; var char2; var boat; -const LAYER_MOUNT := 0x19; // 25. Mount (horse, ostard etc.). +const LAYER_MOUNT := 0x19; // 25. Mount (horse, ostard etc.). var clientcon := getClientConnection(); program chartests() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - a:=FindAccount("testclient1"); - char2:=a.getcharacter(1); - if (!char2) - return ret_error("Could not find char2 at slot 1"); + a := FindAccount( "testclient1" ); + char2 := a.getcharacter( 1 ); + if ( !char2 ) + return ret_error( "Could not find char2 at slot 1" ); endif - boat:=CreateMultiAtLocation(10,50,-4,0x11000, CRMULTI_FACING_EAST); - if (!boat) - return ret_error("Failed to create boat "+boat); + boat := CreateMultiAtLocation( 10, 50, -4, 0x11000, CRMULTI_FACING_EAST ); + if ( !boat ) + return ret_error( "Failed to create boat " + boat ); endif endprogram exported function move_boat() - MoveBoatXY(boat,10,50); - var h:=getstandingheight(11,50, boat.z, boat.realm); - MoveObjectToLocation(char, 11,50,h.z); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveBoatXY( boat, 10, 50 ); + var h := getstandingheight( 11, 50, boat.z, boat.realm ); + MoveObjectToLocation( char, 11, 50, h.z ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - var res:=boat.mobiles.size()==1; + var res := boat.mobiles.size() == 1; Clear_Event_Queue(); - var item:=CreateItemAtLocation(11,50,h.z, 0x3e3f, 1, boat.realm); - var moveres := MoveBoat(boat,0); - var clientmoveres:=ret_error("no boat pos"); - while (1) - var ev:=waitForClient(0, {EVT_BOAT_MOVED}); - if (!ev) + var item := CreateItemAtLocation( 11, 50, h.z, 0x3e3f, 1, boat.realm ); + var moveres := MoveBoat( boat, 0 ); + var clientmoveres := ret_error( "no boat pos" ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_BOAT_MOVED } ); + if ( !ev ) continue; endif - if (ev.pos[1]!=10 || ev.pos[2]!=49 || ev.pos[3]!=-4) - clientmoveres:=ret_error("wrong boat pos {} != {},{},{}".format(ev.pos,10,49,-4)); + if ( ev.pos[1] != 10 || ev.pos[2] != 49 || ev.pos[3] != -4 ) + clientmoveres := ret_error( "wrong boat pos {} != {},{},{}".format( ev.pos, 10, 49, -4 ) ); else - clientmoveres:=1; + clientmoveres := 1; endif break; endwhile - clientcon.sendevent(struct{todo:="list_objects", id:=0}); - var itemres:=ret_error("item not found {}".format(item.serial)); - while (1) - var ev:=waitForClient(0, {EVT_LIST_OBJS}); - if (!ev) + clientcon.sendevent( struct{ todo := "list_objects", id := 0 } ); + var itemres := ret_error( "item not found {}".format( item.serial ) ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_LIST_OBJS } ); + if ( !ev ) return ev; endif - foreach it in (ev["objs"]) - if (it["serial"] == item.serial) - var p:=it["pos"]; - if (p[1]!=11 || p[2]!=49 || p[3]!=-1) - itemres:=ret_error("wrong item pos {} != {},{},{}".format(p,11,49,-1)); + foreach it in ( ev["objs"] ) + if ( it["serial"] == item.serial ) + var p := it["pos"]; + if ( p[1] != 11 || p[2] != 49 || p[3] != -1 ) + itemres := ret_error( "wrong item pos {} != {},{},{}".format( p, 11, 49, -1 ) ); else - itemres:=1; + itemres := 1; endif endif endforeach break; endwhile - foreach item in (boat.items) - DestroyItem(item); + foreach item in ( boat.items ) + DestroyItem( item ); endforeach - MoveObjectToLocation(char, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveObjectToLocation( char, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile Clear_Event_Queue(); - if (!res) - return ret_error("Char not on ship"); + if ( !res ) + return ret_error( "Char not on ship" ); endif - if (!moveres) - return ret_error("Failed to move ship {}".format(moveres)); + if ( !moveres ) + return ret_error( "Failed to move ship {}".format( moveres ) ); endif - if (clientmoveres!=1) + if ( clientmoveres != 1 ) return clientmoveres; endif - if (itemres!=1) + if ( itemres != 1 ) return itemres; endif return 1; @@ -99,39 +99,39 @@ endfunction // move a boat with to many items on it (smooth boat pkt overflows) exported function move_boat_overflow() - MoveBoatXY(boat,10,50); - var h:=getstandingheight(11,50, boat.z, boat.realm); - MoveObjectToLocation(char, 11,50,h.z); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveBoatXY( boat, 10, 50 ); + var h := getstandingheight( 11, 50, boat.z, boat.realm ); + MoveObjectToLocation( char, 11, 50, h.z ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - var res:=boat.mobiles.size()==1; + var res := boat.mobiles.size() == 1; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:=EVT_DISABLE_ITEM_LOGGING, arg:=1, id:=0}); - while (!waitForClient(0, {EVT_DISABLE_ITEM_LOGGING})) + clientcon.sendevent( struct{ todo := EVT_DISABLE_ITEM_LOGGING, arg := 1, id := 0 } ); + while ( !waitForClient( 0, { EVT_DISABLE_ITEM_LOGGING } ) ) endwhile - for i:=1 to 8000 - CreateItemAtLocation(11,50,h.z, 0x3e3f, 1, boat.realm); + for i := 1 to 8000 + CreateItemAtLocation( 11, 50, h.z, 0x3e3f, 1, boat.realm ); endfor var itemres := boat.items.size() > 7000; - var moveres := MoveBoat(boat,0); - foreach item in (boat.items) - DestroyItem(item); + var moveres := MoveBoat( boat, 0 ); + foreach item in ( boat.items ) + DestroyItem( item ); endforeach - MoveObjectToLocation(char, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveObjectToLocation( char, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - clientcon.sendevent(struct{todo:=EVT_DISABLE_ITEM_LOGGING, arg:=0, id:=0}); - while (!waitForClient(0, {EVT_DISABLE_ITEM_LOGGING})) + clientcon.sendevent( struct{ todo := EVT_DISABLE_ITEM_LOGGING, arg := 0, id := 0 } ); + while ( !waitForClient( 0, { EVT_DISABLE_ITEM_LOGGING } ) ) endwhile Clear_Event_Queue(); - if (!res) - return ret_error("Char not on ship"); + if ( !res ) + return ret_error( "Char not on ship" ); endif - if (!itemres) - return ret_error("Not enough items"); + if ( !itemres ) + return ret_error( "Not enough items" ); endif - if (!moveres) - return ret_error("Failed to move ship {}".format(moveres)); + if ( !moveres ) + return ret_error( "Failed to move ship {}".format( moveres ) ); endif return 1; endfunction @@ -139,107 +139,105 @@ endfunction // Tests handling of pilot via boatref.set_pilot() method and boatref.pilot member // Also checks for mount piece functionality on both client and server. exported function boat_pilot_mbr_mth() - MoveBoatXY(boat,10,50); - var h:=getstandingheight(11,50, boat.z, boat.realm); - boat.set_pilot(0); - MoveObjectToLocation(char, 11,50,h.z); + MoveBoatXY( boat, 10, 50 ); + var h := getstandingheight( 11, 50, boat.z, boat.realm ); + boat.set_pilot( 0 ); + MoveObjectToLocation( char, 11, 50, h.z ); var res; - res := boat.set_pilot(char); - if (!res) + res := boat.set_pilot( char ); + if ( !res ) return res; - elseif (!boat.pilot) - return ret_error("Boat pilot not defined after setting."); - elseif (boat.pilot != char) - return ret_error($"New boat pilot ({boat.pilot.name}) does not equal the set pilot ({char.name})"); + elseif ( !boat.pilot ) + return ret_error( "Boat pilot not defined after setting." ); + elseif ( boat.pilot != char ) + return ret_error( $"New boat pilot ({boat.pilot.name}) does not equal the set pilot ({char.name})" ); endif - res := boat.set_pilot(char); - if (res != error) - return ret_error($"Unexpected success when setting pilot of an already-pilotted boat: {res}"); + res := boat.set_pilot( char ); + if ( res != error ) + return ret_error( $"Unexpected success when setting pilot of an already-pilotted boat: {res}" ); endif - clientcon.sendevent(struct{todo:="list_equipped_items", arg:=char.serial, id:=0}); - var ev:=waitForClient(0, {EVT_LIST_EQUIPPED_ITEMS}); - if (!ev) + clientcon.sendevent( struct{ todo := "list_equipped_items", arg := char.serial, id := 0 } ); + var ev := waitForClient( 0, { EVT_LIST_EQUIPPED_ITEMS } ); + if ( !ev ) return ev; endif - var mountpiece := GetEquipmentByLayer(char, LAYER_MOUNT); + var mountpiece := GetEquipmentByLayer( char, LAYER_MOUNT ); - if (!mountpiece) - return ret_error("Character does not have an equipped mount piece."); + if ( !mountpiece ) + return ret_error( "Character does not have an equipped mount piece." ); endif var mountpiece_found := 0; - foreach item in (ev.objs) - if (item.serial == mountpiece.serial && item.layer == LAYER_MOUNT) + foreach item in ( ev.objs ) + if ( item.serial == mountpiece.serial && item.layer == LAYER_MOUNT ) mountpiece_found := 1; break; endif endforeach - if (!mountpiece_found) - return ret_error("Character mount piece not found on list of equipped items from client."); + if ( !mountpiece_found ) + return ret_error( "Character mount piece not found on list of equipped items from client." ); endif - res := boat.set_pilot(0); - if (!res) - return ret_error($"Unable to clear pilot: {res}"); - elseif (boat.pilot) - return ret_error("Boat pilot is not empty (boat.pilot.name) after clearing."); + res := boat.set_pilot( 0 ); + if ( !res ) + return ret_error( $"Unable to clear pilot: {res}" ); + elseif ( boat.pilot ) + return ret_error( "Boat pilot is not empty (boat.pilot.name) after clearing." ); endif - mountpiece := GetEquipmentByLayer(char, LAYER_MOUNT); + mountpiece := GetEquipmentByLayer( char, LAYER_MOUNT ); - if (mountpiece) - return ret_error("Character erroneously has an equipped mount piece."); + if ( mountpiece ) + return ret_error( "Character erroneously has an equipped mount piece." ); endif Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="list_equipped_items", arg:=char.serial, id:=0}); - ev:=waitForClient(0, {EVT_LIST_EQUIPPED_ITEMS}); - if (!ev) + clientcon.sendevent( struct{ todo := "list_equipped_items", arg := char.serial, id := 0 } ); + ev := waitForClient( 0, { EVT_LIST_EQUIPPED_ITEMS } ); + if ( !ev ) return ev; endif mountpiece_found := 0; - foreach item in (ev.objs) - if (item.layer == LAYER_MOUNT) + foreach item in ( ev.objs ) + if ( item.layer == LAYER_MOUNT ) mountpiece_found := 1; break; endif endforeach - if (mountpiece_found) - return ret_error("Character erroneously has a mount piece found on list of equipped items from client."); + if ( mountpiece_found ) + return ret_error( "Character erroneously has a mount piece found on list of equipped items from client." ); endif return 1; endfunction exported function boat_pilot_packets() - MoveBoatXY(boat,10,50); - var h:=getstandingheight(11,50, boat.z, boat.realm); - boat.set_pilot(0); - MoveObjectToLocation(char, 11,50,h.z); + MoveBoatXY( boat, 10, 50 ); + var h := getstandingheight( 11, 50, boat.z, boat.realm ); + boat.set_pilot( 0 ); + MoveObjectToLocation( char, 11, 50, h.z ); var res; - res := boat.set_pilot(char); - if (!res) - return ret_error($"Failed to set pilot: {res}"); + res := boat.set_pilot( char ); + if ( !res ) + return ret_error( $"Failed to set pilot: {res}" ); endif - boat.setprop("#TestClientBoatPid", GetPid()); + boat.setprop( "#TestClientBoatPid", GetPid() ); - var expected := array{ - struct{ direction := 1, speed := 1 }, - struct{ direction := 2, speed := 2 }, - struct{ direction := 3, speed := 0 } - }; + var expected := array{ struct{ direction := 1, speed := 1 }, + struct{ direction := 2, speed := 2 }, + struct{ direction := 3, speed := 0 } }; foreach boat_move_details in expected var direction := boat_move_details.direction, speed := boat_move_details.speed; @@ -251,34 +249,37 @@ exported function boat_pilot_packets() var client_boat_move_event; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="boat_move", arg:=struct{ serial := char.serial, direction := direction, speed := speed }, id:=0}); - res := get_boat_move_events(control_script_event, client_boat_move_event); - if (!res) - boat.set_pilot(0); + clientcon.sendevent( struct{ todo := "boat_move", + arg := struct{ serial := char.serial, direction := direction, + speed := speed }, + id := 0 } ); + res := get_boat_move_events( control_script_event, client_boat_move_event ); + if ( !res ) + boat.set_pilot( 0 ); return res; endif - if (control_script_event.direction != direction) - boat.set_pilot(0); - return ret_error($"control_script_event.direction ({control_script_event.direction}) != direction ({direction})"); - elseif (client_boat_move_event.direction != direction) - boat.set_pilot(0); - return ret_error($"client_boat_move_event.direction ({client_boat_move_event.direction}) != direction ({direction})"); - elseif (control_script_event.speed != speed) - boat.set_pilot(0); - return ret_error($"control_script_event.speed ({control_script_event.speed}) != speed ({speed})"); - elseif (control_script_event.type != SYSEVENT_BOAT_MOVEMENT) - boat.set_pilot(0); - return ret_error($"control_script_event.type ({control_script_event.type}) != SYSEVENT_BOAT_MOVEMENT ({SYSEVENT_BOAT_MOVEMENT})"); - elseif (client_boat_move_event.speed != speed) - boat.set_pilot(0); - return ret_error($"client_boat_move_event.speed ({client_boat_move_event.speed}) != speed ({speed})"); + if ( control_script_event.direction != direction ) + boat.set_pilot( 0 ); + return ret_error( $"control_script_event.direction ({control_script_event.direction}) != direction ({direction})" ); + elseif ( client_boat_move_event.direction != direction ) + boat.set_pilot( 0 ); + return ret_error( $"client_boat_move_event.direction ({client_boat_move_event.direction}) != direction ({direction})" ); + elseif ( control_script_event.speed != speed ) + boat.set_pilot( 0 ); + return ret_error( $"control_script_event.speed ({control_script_event.speed}) != speed ({speed})" ); + elseif ( control_script_event.type != SYSEVENT_BOAT_MOVEMENT ) + boat.set_pilot( 0 ); + return ret_error( $"control_script_event.type ({control_script_event.type}) != SYSEVENT_BOAT_MOVEMENT ({SYSEVENT_BOAT_MOVEMENT})" ); + elseif ( client_boat_move_event.speed != speed ) + boat.set_pilot( 0 ); + return ret_error( $"client_boat_move_event.speed ({client_boat_move_event.speed}) != speed ({speed})" ); endif endforeach - res := boat.set_pilot(0); - if (!res) - return ret_error($"Failed to clear pilot: {res}"); + res := boat.set_pilot( 0 ); + if ( !res ) + return ret_error( $"Failed to clear pilot: {res}" ); endif return 1; @@ -286,26 +287,27 @@ endfunction // Gets an event from both the boat control script as well as the client. // Returns error if both events cannot be fulfilled within `timeout` seconds. -function get_boat_move_events(byref control_script_event, byref client_boat_move_event, timeout := 10) +function get_boat_move_events( byref control_script_event, byref client_boat_move_event, + timeout := 10 ) control_script_event := 0; client_boat_move_event := 0; - while (1) - var ev:=Wait_For_Event(timeout); - if (!ev) - return ret_error($"no signal received for one of control_script_event={control_script_event}, client_boat_move_event={client_boat_move_event}"); + while ( 1 ) + var ev := Wait_For_Event( timeout ); + if ( !ev ) + return ret_error( $"no signal received for one of control_script_event={control_script_event}, client_boat_move_event={client_boat_move_event}" ); endif - if (ev.source == "control_script") + if ( ev.source == "control_script" ) control_script_event := ev.event; - if (client_boat_move_event && control_script_event) + if ( client_boat_move_event && control_script_event ) break; else continue; endif - elseif (client_boat_move_event || (ev.id != 0 || !(ev.type in {EVT_BOAT_MOVE}))) + elseif ( client_boat_move_event || ( ev.id != 0 || !( ev.type in { EVT_BOAT_MOVE } ) ) ) continue; endif client_boat_move_event := ev; - if (client_boat_move_event && control_script_event) + if ( client_boat_move_event && control_script_event ) break; endif endwhile @@ -315,101 +317,103 @@ endfunction // Tests handling of pilot via boatref.set_pilot() method and boatref.pilot member // Also checks for mount piece functionality on both client and server. exported function boat_pilot_blocks_movement() - MoveBoatXY(boat,10,50); - var h:=getstandingheight(11,50, boat.z, boat.realm); - boat.set_pilot(0); - MoveObjectToLocation(char, 11,50,h.z); + MoveBoatXY( boat, 10, 50 ); + var h := getstandingheight( 11, 50, boat.z, boat.realm ); + boat.set_pilot( 0 ); + MoveObjectToLocation( char, 11, 50, h.z ); var res; - res := boat.set_pilot(char); - if (!res) + res := boat.set_pilot( char ); + if ( !res ) return res; endif Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="move",arg:=1,id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_MOVED}); - if (!ev) - boat.set_pilot(0); + clientcon.sendevent( struct{ todo := "move", arg := 1, id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_MOVED } ); + if ( !ev ) + boat.set_pilot( 0 ); return ev; - elseif (ev.ack) - boat.set_pilot(0); - return ret_error("Character unexpectedly successfully moved via client movement."); + elseif ( ev.ack ) + boat.set_pilot( 0 ); + return ret_error( "Character unexpectedly successfully moved via client movement." ); endif break; endwhile - res := MoveObjectToLocation(char, char.x, char.y, char.z); - if (res) - boat.set_pilot(0); - return ret_error("Character unexpectedly successfully moved via MoveObjectToLocation."); + res := MoveObjectToLocation( char, char.x, char.y, char.z ); + if ( res ) + boat.set_pilot( 0 ); + return ret_error( "Character unexpectedly successfully moved via MoveObjectToLocation." ); endif - boat.set_pilot(0); + boat.set_pilot( 0 ); return 1; endfunction /* move boat in direction of char and check at which distance the boat is visible and then back out of sight */ exported function boat_update_range() - MoveBoatXY(boat,10,50); + MoveBoatXY( boat, 10, 50 ); Clear_Event_Queue(); - //move char out of range - MoveObjectToLocation(char, boat.x+30,boat.y,1,realm:="britannia2", flags:=MOVEOBJECT_FORCELOCATION); - while (!waitForClient(0, {EVT_OWNCREATE})) + // move char out of range + MoveObjectToLocation( char, boat.x + 30, boat.y, 1, realm := "britannia2", + flags := MOVEOBJECT_FORCELOCATION ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - MoveObjectToLocation(char, boat.x+30,boat.y,1,realm:="britannia", flags:=MOVEOBJECT_FORCELOCATION); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveObjectToLocation( char, boat.x + 30, boat.y, 1, realm := "britannia", + flags := MOVEOBJECT_FORCELOCATION ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - clientcon.sendevent(struct{todo:="list_objects", id:=0}); - var ev:=waitForClient(0, {EVT_LIST_OBJS}); - if (!ev) + clientcon.sendevent( struct{ todo := "list_objects", id := 0 } ); + var ev := waitForClient( 0, { EVT_LIST_OBJS } ); + if ( !ev ) return ev; endif - foreach it in (ev["objs"]) - if (it["serial"]==boat.serial) - return ret_error("boat still in range"); + foreach it in ( ev["objs"] ) + if ( it["serial"] == boat.serial ) + return ret_error( "boat still in range" ); endif endforeach // now move boat to char - var i:=10; - while (--i>0) - MoveBoat(boat,2); - sleepms(10); + var i := 10; + while ( --i > 0 ) + MoveBoat( boat, 2 ); + sleepms( 10 ); endwhile - while (1) - ev:=waitForClient(0, {EVT_NEW_ITEM}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_NEW_ITEM } ); + if ( !ev ) return ev; endif - if (ev["serial"] == boat.serial) - var x:=char.x-ev["pos"][1]; - var y:=char.y-ev["pos"][2]; - if (x!=23 ||y!=0) // (18 visual range +5 footprint/2) - return ret_error($"update distance failed: {x}, {y}"); + if ( ev["serial"] == boat.serial ) + var x := char.x - ev["pos"][1]; + var y := char.y - ev["pos"][2]; + if ( x != 23 || y != 0 ) // (18 visual range +5 footprint/2) + return ret_error( $"update distance failed: {x}, {y}" ); endif break; endif endwhile // move boat again out of range - i:=10; - while (--i>0) - MoveBoat(boat,6); - sleepms(10); + i := 10; + while ( --i > 0 ) + MoveBoat( boat, 6 ); + sleepms( 10 ); endwhile - while (1) - ev:=waitForClient(0, {EVT_REMOVED_OBJ}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_REMOVED_OBJ } ); + if ( !ev ) return ev; endif - if (ev["serial"] == boat.serial) - var x:=char.x-ev["oldpos"][1]; - var y:=char.y-ev["oldpos"][2]; - if (x!=23 ||y!=0) // (18 visual range +5 footprint/2) - return ret_error($"remove update distance failed: {x}, {y}"); + if ( ev["serial"] == boat.serial ) + var x := char.x - ev["oldpos"][1]; + var y := char.y - ev["oldpos"][2]; + if ( x != 23 || y != 0 ) // (18 visual range +5 footprint/2) + return ret_error( $"remove update distance failed: {x}, {y}" ); endif break; endif @@ -418,128 +422,128 @@ exported function boat_update_range() endfunction exported function boat_nondefault_control_script() - var boat2:=CreateMultiAtLocation(20,30,-4,0x11002, CRMULTI_FACING_EAST); - if (!boat2) - return ret_error($"Failed to create boat: {boat2}"); + var boat2 := CreateMultiAtLocation( 20, 30, -4, 0x11002, CRMULTI_FACING_EAST ); + if ( !boat2 ) + return ret_error( $"Failed to create boat: {boat2}" ); endif var expected := "testpkgs/boat/boat.ecl"; var actual := boat2.process.name; - if (actual != expected) - DestroyMulti(boat2); - return ret_error($"Boat 0x11002 control script mismatch, expected '{expected}' != actual '{actual}'"); + if ( actual != expected ) + DestroyMulti( boat2 ); + return ret_error( $"Boat 0x11002 control script mismatch, expected '{expected}' != actual '{actual}'" ); endif - DestroyMulti(boat2); + DestroyMulti( boat2 ); return 1; endfunction exported function boat_bad_control_script_no_crash() - var boat2:=CreateMultiAtLocation(20,30,-4,0x11003, CRMULTI_FACING_EAST); - if (!boat2) - return ret_error($"Failed to create boat: {boat2}"); - elseif (boat2.process) - DestroyMulti(boat2); - return ret_error($"Boat has an unexpected control script: {boat.process.name}"); + var boat2 := CreateMultiAtLocation( 20, 30, -4, 0x11003, CRMULTI_FACING_EAST ); + if ( !boat2 ) + return ret_error( $"Failed to create boat: {boat2}" ); + elseif ( boat2.process ) + DestroyMulti( boat2 ); + return ret_error( $"Boat has an unexpected control script: {boat.process.name}" ); endif - DestroyMulti(boat2); + DestroyMulti( boat2 ); return 1; endfunction exported function boat_alternate_multiid() - MoveBoatXY(boat,10,50); - var h:=getstandingheight(11,50, boat.z, boat.realm); - MoveObjectToLocation(char, 11,50,h.z); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveBoatXY( boat, 10, 50 ); + var h := getstandingheight( 11, 50, boat.z, boat.realm ); + MoveObjectToLocation( char, 11, 50, h.z ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile var res; do - res := ensure_multiid(1, "Unexpected initial boat.multiid"); + res := ensure_multiid( 1, "Unexpected initial boat.multiid" ); - if (!res) + if ( !res ) break; endif - res := boat.set_alternate_multiid(1); + res := boat.set_alternate_multiid( 1 ); - if (!res) - res := ret_error($"Unable to set_alternate_multiid(1): {res}"); + if ( !res ) + res := ret_error( $"Unable to set_alternate_multiid(1): {res}" ); break; endif - res := ensure_multiid(5, "Unexpected first alternate boat.multiid"); + res := ensure_multiid( 5, "Unexpected first alternate boat.multiid" ); - if (!res) + if ( !res ) break; endif - res := boat.set_alternate_multiid(2); + res := boat.set_alternate_multiid( 2 ); - if (!res) - res := ret_error($"Unable to set_alternate_multiid(2): {res}"); + if ( !res ) + res := ret_error( $"Unable to set_alternate_multiid(2): {res}" ); break; endif - res := ensure_multiid(9, "Unexpected second alternate boat.multiid"); + res := ensure_multiid( 9, "Unexpected second alternate boat.multiid" ); - if (!res) + if ( !res ) break; endif - res := boat.set_alternate_multiid(3); + res := boat.set_alternate_multiid( 3 ); - if (res != error) - res := ret_error($"Unexpected success for set_alternate_multiid(3): {res}"); + if ( res != error ) + res := ret_error( $"Unexpected success for set_alternate_multiid(3): {res}" ); break; endif - res := ensure_multiid(9, "Unexpected change in boat.multiid after invalid boat.set_alternate_multiid(3)"); + res := ensure_multiid( 9, "Unexpected change in boat.multiid after invalid boat.set_alternate_multiid(3)" ); - if (!res) + if ( !res ) break; endif - res := boat.set_alternate_multiid(0); + res := boat.set_alternate_multiid( 0 ); - if (!res) - res := ret_error($"Unable to set_alternate_multiid(0): {res.errortext}"); + if ( !res ) + res := ret_error( $"Unable to set_alternate_multiid(0): {res.errortext}" ); break; endif - res := ensure_multiid(1, "Unexpected base boat.multiid"); + res := ensure_multiid( 1, "Unexpected base boat.multiid" ); - if (!res) + if ( !res ) break; endif res := 1; - dowhile (0); + dowhile ( 0 ); return res; endfunction -function ensure_multiid(multiid, errormsg) - if (boat.multiid != multiid) - return ret_error($"{errormsg}, expected {multiid} != actual {boat.multiid}"); +function ensure_multiid( multiid, errormsg ) + if ( boat.multiid != multiid ) + return ret_error( $"{errormsg}, expected {multiid} != actual {boat.multiid}" ); endif Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="list_objects", id:=0}); - while (1) - var res:=waitForClient(0, {EVT_LIST_OBJS}); - if (!res) + clientcon.sendevent( struct{ todo := "list_objects", id := 0 } ); + while ( 1 ) + var res := waitForClient( 0, { EVT_LIST_OBJS } ); + if ( !res ) return res; endif - foreach obj in (res.objs) - if (obj.serial == boat.serial) - if (obj.graphic != multiid) - return ret_error("client boat.graphic mismatch, expected {multiid} != actual {obj.graphic}"); + foreach obj in ( res.objs ) + if ( obj.serial == boat.serial ) + if ( obj.graphic != multiid ) + return ret_error( "client boat.graphic mismatch, expected {multiid} != actual {obj.graphic}" ); else return 1; endif @@ -547,14 +551,14 @@ function ensure_multiid(multiid, errormsg) endforeach break; endwhile - return ret_error("client object list does not contain boat"); + return ret_error( "client object list does not contain boat" ); endfunction exported function boat_alternate_multiid_itemdesc() - var actual := GetItemDescriptor(0x11000).AlternateMultiID; - var expected := array{4, 8}; - if (actual != expected) - return ret_error($"Expected AlternateMultiID to be {expected}, got {actual}"); + var actual := GetItemDescriptor( 0x11000 ).AlternateMultiID; + var expected := array{ 4, 8 }; + if ( actual != expected ) + return ret_error( $"Expected AlternateMultiID to be {expected}, got {actual}" ); endif return 1; diff --git a/testsuite/pol/testpkgs/client/test_client_container_events.src b/testsuite/pol/testpkgs/client/test_client_container_events.src index ee6ee6956..176c8a30a 100644 --- a/testsuite/pol/testpkgs/client/test_client_container_events.src +++ b/testsuite/pol/testpkgs/client/test_client_container_events.src @@ -16,13 +16,13 @@ program test_item_move() var a := FindAccount( "testclient0" ); char := a.getcharacter( 1 ); if ( !char ) - return ret_error( "Could not find char at slot 1" ); + return ret_error( "Could not find char at slot 1" ); endif // Move character somewhere nice. var res := MoveObjectToLocation( char, charX, charY, 0 ); if ( !res ) - return ret_error( $"Could not move character: ${res}" ); + return ret_error( $"Could not move character: ${res}" ); endif return 1; @@ -31,7 +31,8 @@ endprogram exported function test_container_events() var ret, container, item, remaining_item; do - var evs, expected_caninsert_args, expected_oninsert_args, expected_canremove_args, expected_onremove_args; + var evs, expected_caninsert_args, expected_oninsert_args, expected_canremove_args, + expected_onremove_args; container := CreateItemAtLocation( char.x, char.y, char.z, "container_events" ); if ( !container ) @@ -57,31 +58,42 @@ exported function test_container_events() break; endif - if ( !( evs := drop_item( ret, item.serial, 0xFF, 0xFF, 0, container.serial, { "container_caninsert", "container_oninsert" }, { EVT_DROP_ITEM } ) ) ) + if ( !( evs := drop_item( ret, item.serial, 0xFF, 0xFF, 0, container.serial, { "container_caninsert", + "container_oninsert" }, + { EVT_DROP_ITEM } ) ) ) break; endif - expected_caninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_ADD_ITEM, item /* adding_item */, uninit /* existing_stack */, uninit /* amount_to_add */ }; - expected_oninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_ADD_ITEM, item /* adding_item */, item /* existing_stack */, 500 }; + expected_caninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_ADD_ITEM, item /* adding_item */, + uninit /* existing_stack */, uninit /* amount_to_add */ }; + expected_oninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_ADD_ITEM, item /* adding_item */, + item /* existing_stack */, 500 }; - if ( !( ret := ret_error_not_equal( evs.container_caninsert.args, expected_caninsert_args, $"evs.container_caninsert.args {evs.container_caninsert.args} != expected_caninsert_args {expected_caninsert_args}" ) ) ) + if ( !( ret := ret_error_not_equal( evs.container_caninsert.args, expected_caninsert_args, + $"evs.container_caninsert.args {evs.container_caninsert.args} != expected_caninsert_args {expected_caninsert_args}" + ) ) ) break; endif - if ( !( ret := ret_error_not_equal( evs.container_oninsert.args, expected_oninsert_args, $"evs.container_oninsert.args {evs.container_oninsert.args} != expected_oninsert_args {expected_oninsert_args}" ) ) ) + if ( !( ret := ret_error_not_equal( evs.container_oninsert.args, expected_oninsert_args, + $"evs.container_oninsert.args {evs.container_oninsert.args} != expected_oninsert_args {expected_oninsert_args}" + ) ) ) break; endif // ---------- // Fail to lift 250 coins from the container, as cannot remove odd-amount items from the container because of the CanRemove script // ---------- - if ( !( evs := lift_item( ret, item.serial, 251, { "container_canremove", EVT_MOVE_ITEM_REJECTED }, {} ) ) ) + if ( !( evs := lift_item( ret, item.serial, 251, { "container_canremove", + EVT_MOVE_ITEM_REJECTED }, {} ) ) ) break; endif expected_canremove_args := { char, container, item, MOVETYPE_PLAYER, 251 }; - if ( !( ret := ret_error_not_equal( evs.container_canremove.args, expected_canremove_args, $"evs.container_canremove.args {evs.container_canremove.args} != expected_canremove_args {expected_canremove_args}" ) ) ) + if ( !( ret := ret_error_not_equal( evs.container_canremove.args, expected_canremove_args, + $"evs.container_canremove.args {evs.container_canremove.args} != expected_canremove_args {expected_canremove_args}" + ) ) ) break; endif @@ -99,12 +111,17 @@ exported function test_container_events() break; endif - if ( !( evs := drop_item( ret, remaining_item.serial, 0xFF, 0xFF, 0, item.serial, { "container_caninsert", "container_oninsert" }, { EVT_DROP_ITEM } ) ) ) + if ( !( evs := drop_item( ret, remaining_item.serial, 0xFF, 0xFF, 0, item.serial, { "container_caninsert", + "container_oninsert" }, + { EVT_DROP_ITEM } ) ) ) break; endif - expected_caninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_INCREASE_STACK, remaining_item, item, 250 }; - if ( !( ret := ret_error_not_equal( evs.container_caninsert.args, expected_caninsert_args, $"evs.container_caninsert.args {evs.container_caninsert.args} != expected_caninsert_args {expected_caninsert_args}" ) ) ) + expected_caninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_INCREASE_STACK, + remaining_item, item, 250 }; + if ( !( ret := ret_error_not_equal( evs.container_caninsert.args, expected_caninsert_args, + $"evs.container_caninsert.args {evs.container_caninsert.args} != expected_caninsert_args {expected_caninsert_args}" + ) ) ) break; endif @@ -112,8 +129,11 @@ exported function test_container_events() // and OnInsert, and is therefore stacked _into_ the existing stack in // the container (ie. `item.amount == 750`). We still have the `250` as // the `amount_to_add` parameter. - expected_oninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_INCREASE_STACK, uninit /* adding_item */, item, 250 }; - if ( !( ret := ret_error_not_equal( evs.container_oninsert.args, expected_oninsert_args, $"evs.container_oninsert.args {evs.container_oninsert.args} != expected_oninsert_args {expected_oninsert_args}" ) ) ) + expected_oninsert_args := { char, container, MOVETYPE_PLAYER, INSERT_INCREASE_STACK, + uninit /* adding_item */, item, 250 }; + if ( !( ret := ret_error_not_equal( evs.container_oninsert.args, expected_oninsert_args, + $"evs.container_oninsert.args {evs.container_oninsert.args} != expected_oninsert_args {expected_oninsert_args}" + ) ) ) break; endif @@ -124,12 +144,16 @@ exported function test_container_events() // ---------- // Lift 250 coins from the container and drop into container (as a new item) // ---------- - if ( !( evs := lift_item( ret, item.serial, 250, { "container_canremove", "container_onremove" }, { EVT_LIFT_ITEM } ) ) ) + if ( !( evs := lift_item( ret, item.serial, 250, { "container_canremove", + "container_onremove" }, + { EVT_LIFT_ITEM } ) ) ) break; endif expected_canremove_args := { char, container, item, MOVETYPE_PLAYER, 250 }; - if ( !( ret := ret_error_not_equal( evs.container_canremove.args, expected_canremove_args, $"evs.container_canremove.args {evs.container_canremove.args} != expected_canremove_args {expected_canremove_args}" ) ) ) + if ( !( ret := ret_error_not_equal( evs.container_canremove.args, expected_canremove_args, + $"evs.container_canremove.args {evs.container_canremove.args} != expected_canremove_args {expected_canremove_args}" + ) ) ) break; endif @@ -139,8 +163,11 @@ exported function test_container_events() break; endif - expected_onremove_args := { char, container, item, 250, MOVETYPE_PLAYER, remaining_item /* split_from */ }; - if ( !( ret := ret_error_not_equal( evs.container_onremove.args, expected_onremove_args, $"evs.container_onremove.args {evs.container_onremove.args} != expected_onremove_args {expected_onremove_args}" ) ) ) + expected_onremove_args := { char, container, item, 250, MOVETYPE_PLAYER, + remaining_item /* split_from */ }; + if ( !( ret := ret_error_not_equal( evs.container_onremove.args, expected_onremove_args, + $"evs.container_onremove.args {evs.container_onremove.args} != expected_onremove_args {expected_onremove_args}" + ) ) ) break; endif @@ -177,8 +204,13 @@ function get_container_events( byref err, sequential_events, other_events ) var other_event_index := 1; while ( evs.size() < sequential_events.size() + other_events.size() ) - var events := ( sequential_event_index <= sequential_events.size() ? array{ sequential_events[sequential_event_index] } : array{} ) + - ( other_event_index <= other_events.size() ? array{ other_events[other_event_index] } : array{} ); + var events := ( sequential_event_index <= sequential_events.size() ? array{ sequential_events[sequential_event_index] } + : array{} + ) + + ( + other_event_index <= other_events.size() + ? array{ other_events[other_event_index] } + : array{} ); var ev; while ( 1 ) @@ -202,14 +234,19 @@ endfunction function drop_item( byref err, serial, x, y, z, dropped_on_serial, sequential_events, other_events ) Clear_Event_Queue(); - clientcon.sendevent( struct{ todo := "drop_item", arg := struct{ serial := serial, x := x, y := y, z := z, dropped_on_serial := dropped_on_serial }, id := 0 } ); + clientcon.sendevent( struct{ todo := "drop_item", + arg := struct{ serial := serial, x := x, y := y, + z := z, dropped_on_serial := dropped_on_serial }, + id := 0 } ); return get_container_events( err, sequential_events, other_events ); endfunction function lift_item( byref err, serial, amount, sequential_events, other_events ) Clear_Event_Queue(); - clientcon.sendevent( struct{ todo := "lift_item", arg := struct{ serial := serial, amount := amount }, id := 0 } ); + clientcon.sendevent( struct{ todo := "lift_item", + arg := struct{ serial := serial, amount := amount }, + id := 0 } ); return get_container_events( err, sequential_events, other_events ); endfunction diff --git a/testsuite/pol/testpkgs/client/test_client_demo.src b/testsuite/pol/testpkgs/client/test_client_demo.src index 3465f7edd..80136ed25 100644 --- a/testsuite/pol/testpkgs/client/test_client_demo.src +++ b/testsuite/pol/testpkgs/client/test_client_demo.src @@ -13,26 +13,25 @@ var char2; var clientcon := getClientConnection(); program chartests() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - a:=FindAccount("testclient1"); - char2:=a.getcharacter(1); - if (!char2) - return ret_error("Could not find char2 at slot 1"); + a := FindAccount( "testclient1" ); + char2 := a.getcharacter( 1 ); + if ( !char2 ) + return ret_error( "Could not find char2 at slot 1" ); endif endprogram - exported function get_char1_objs() // TODO: just for demonstration Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="list_objects", id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_LIST_OBJS}); - if (!ev) + clientcon.sendevent( struct{ todo := "list_objects", id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_LIST_OBJS } ); + if ( !ev ) return ev; endif break; @@ -43,12 +42,12 @@ endfunction exported function open_backpack() // TODO: just for demonstration // empty backpack would lead to an timeout in the client, no secure way to check if the correct pkts got send - var item:=CreateItemInContainer(char.backpack, 0xf3f, 1); + var item := CreateItemInContainer( char.backpack, 0xf3f, 1 ); Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="open_backpack", id:=0}); - while (1) - var ev:=waitForClient(0, {EVT_OPEN_BACKPACK}); - if (!ev) + clientcon.sendevent( struct{ todo := "open_backpack", id := 0 } ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_OPEN_BACKPACK } ); + if ( !ev ) return ev; endif break; @@ -59,20 +58,21 @@ endfunction exported function target_loc() // TODO: just for demonstration Clear_Event_Queue(); - var loc:=GetMapInfo(char.x,char.y); - clientcon.sendevent(struct{todo:="target", - arg:=struct{x:=char.x,y:=char.y,z:=loc.z,graphic:=loc.landtile}, - id:=0}); + var loc := GetMapInfo( char.x, char.y ); + clientcon.sendevent( struct{ todo := "target", + arg := struct{ x := char.x, y := char.y, z := loc.z, + graphic := loc.landtile }, + id := 0 } ); // this needs to be moved to a separated script, since its a blocking call - // client would timeout after 5s - var tar:=TargetCoordinates(char); - while (1) - var ev:=waitForClient(0, {EVT_TARGET}); - if (!ev) + // client would timeout after 5s + var tar := TargetCoordinates( char ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_TARGET } ); + if ( !ev ) return ev; endif - if (!ev.res || ev.targettype != 0) - return ret_error($"Target failed, no cursor or wrong type {ev.targettype}"); + if ( !ev.res || ev.targettype != 0 ) + return ret_error( $"Target failed, no cursor or wrong type {ev.targettype}" ); endif break; endwhile @@ -82,25 +82,22 @@ endfunction exported function target_char() // TODO: just for demonstration Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="target", - arg:=struct{serial:=char.serial}, - id:=0}); + clientcon.sendevent( struct{ todo := "target", arg := struct{ serial := char.serial }, id := 0 } ); // this needs to be moved to a separated script, since its a blocking call - // client would timeout after 5s - var tar:=Target(char,TGTOPT_HARMFUL); - while (1) - var ev:=waitForClient(0, {EVT_TARGET}); - if (!ev) + // client would timeout after 5s + var tar := Target( char, TGTOPT_HARMFUL ); + while ( 1 ) + var ev := waitForClient( 0, { EVT_TARGET } ); + if ( !ev ) return ev; endif - if (!ev.res || ev.targettype != 1) - return ret_error($"Target failed, no cursor or wrong type {ev.targettype}"); + if ( !ev.res || ev.targettype != 1 ) + return ret_error( $"Target failed, no cursor or wrong type {ev.targettype}" ); endif break; endwhile - if (tar.serial != char.serial) - return ret_error($"Target failed, wrong serial {tar.serial}"); + if ( tar.serial != char.serial ) + return ret_error( $"Target failed, wrong serial {tar.serial}" ); endif return 1; endfunction - diff --git a/testsuite/pol/testpkgs/client/test_client_gump.src b/testsuite/pol/testpkgs/client/test_client_gump.src index 493f04ae1..c16eeeb50 100644 --- a/testsuite/pol/testpkgs/client/test_client_gump.src +++ b/testsuite/pol/testpkgs/client/test_client_gump.src @@ -9,27 +9,27 @@ var char; var clientcon := getClientConnection(); program chartests() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif endprogram exported function show_gump_simple() Clear_Event_Queue(); - var cmds:={"hello","world"}; - var texts:={"more","text"}; - SendDialogGump(char,cmds,texts); - var ev:=waitForClient(0, {EVT_GUMP}); - if (!ev) + var cmds := { "hello", "world" }; + var texts := { "more", "text" }; + SendDialogGump( char, cmds, texts ); + var ev := waitForClient( 0, { EVT_GUMP } ); + if ( !ev ) return ev; endif - if (ev.commands!=cmds) - return ret_error($"wrong gump cmdstring: {ev}"); + if ( ev.commands != cmds ) + return ret_error( $"wrong gump cmdstring: {ev}" ); endif - if (ev.texts!=texts) - return ret_error($"wrong gump textstring: {ev}"); + if ( ev.texts != texts ) + return ret_error( $"wrong gump textstring: {ev}" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/client/test_client_item_move.src b/testsuite/pol/testpkgs/client/test_client_item_move.src index a58d71176..a306ec7e7 100644 --- a/testsuite/pol/testpkgs/client/test_client_item_move.src +++ b/testsuite/pol/testpkgs/client/test_client_item_move.src @@ -7,23 +7,22 @@ use boat; use file; use polsys; - var char; var charX := 100; var charY := 50; var clientcon := getClientConnection(); program test_item_move() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif // Move character somewhere nice. - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - return ret_error($"Could not move character: ${res}"); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + return ret_error( $"Could not move character: ${res}" ); endif return 1; @@ -39,78 +38,78 @@ endprogram // 1. Move item from ground into backpack exported function lift_ground_drop_backpack() - var item := CreateItemAtLocation(char.x, char.y, char.z, 0x1F03); - if (!item) - return ret_error($"Could not create item: {item}"); + var item := CreateItemAtLocation( char.x, char.y, char.z, 0x1F03 ); + if ( !item ) + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; var err; - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(item); + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( item ); return err; endif - if (!drop_item_succeeded(err, item.serial, 0xFF, 0xFF, 0, char.backpack.serial)) - DestroyItem(item); + if ( !drop_item_succeeded( err, item.serial, 0xFF, 0xFF, 0, char.backpack.serial ) ) + DestroyItem( item ); return err; endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction // 2. Move item from backpack to into backpack exported function lift_backpack_drop_backpack() - var item := CreateItemInBackpack(char, 0x1F03); + var item := CreateItemInBackpack( char, 0x1F03 ); - if (!item) - return ret_error($"Could not create item: {item}"); + if ( !item ) + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; var err; - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(item); + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( item ); return err; endif - if (!drop_item_succeeded(err, item.serial, 0xFF, 0xFF, 0, char.backpack.serial)) - DestroyItem(item); + if ( !drop_item_succeeded( err, item.serial, 0xFF, 0xFF, 0, char.backpack.serial ) ) + DestroyItem( item ); return err; endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction // 3. From item from backpack onto ground exported function lift_backpack_drop_ground() - var item := CreateItemInBackpack(char, 0x1F03); + var item := CreateItemInBackpack( char, 0x1F03 ); - if (!item) - return ret_error($"Could not create item: {item}"); + if ( !item ) + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; var err; - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(item); + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( item ); return err; endif - if (!drop_item_succeeded(err, item.serial, char.x, char.y, char.z)) - DestroyItem(item); + if ( !drop_item_succeeded( err, item.serial, char.x, char.y, char.z ) ) + DestroyItem( item ); return err; endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction @@ -119,15 +118,15 @@ endfunction // backpack exported function fail_lift_nodrop_drop_backpack() - var nodrop_container := CreateItemAtLocation(char.x, char.y, char.z, 0xE75); - if (!nodrop_container) - return ret_error($"Could not create nodrop_item: {nodrop_container}"); + var nodrop_container := CreateItemAtLocation( char.x, char.y, char.z, 0xE75 ); + if ( !nodrop_container ) + return ret_error( $"Could not create nodrop_item: {nodrop_container}" ); endif - var nodrop_item := CreateItemInContainer(nodrop_container, 0x1F03); // robe - if (!nodrop_item) - DestroyItem(nodrop_container); - return ret_error($"Could not create nodrop_item: {nodrop_item}"); + var nodrop_item := CreateItemInContainer( nodrop_container, 0x1F03 ); // robe + if ( !nodrop_item ) + DestroyItem( nodrop_container ); + return ret_error( $"Could not create nodrop_item: {nodrop_item}" ); endif nodrop_item.no_drop := 1; @@ -138,76 +137,75 @@ exported function fail_lift_nodrop_drop_backpack() var err; - if (!lift_item_succeeded(err, nodrop_item.serial)) - DestroyItem(nodrop_container); + if ( !lift_item_succeeded( err, nodrop_item.serial ) ) + DestroyItem( nodrop_container ); return err; endif - if (!drop_item_failed(err, nodrop_item.serial, 0xFF, 0xFF, 0, char.backpack.serial)) - DestroyItem(nodrop_container); + if ( !drop_item_failed( err, nodrop_item.serial, 0xFF, 0xFF, 0, char.backpack.serial ) ) + DestroyItem( nodrop_container ); return err; endif - if (nodrop_item.container != nodrop_container) - return ret_error($"Incorrect container for nodrop_item, got {nodrop_item.container.serial:x} expected {nodrop_container.serial:x}"); + if ( nodrop_item.container != nodrop_container ) + return ret_error( $"Incorrect container for nodrop_item, got {nodrop_item.container.serial:x} expected {nodrop_container.serial:x}" ); endif - if (nodrop_item.x != x_before || nodrop_item.y != y_before) - return ret_error($"Position for nodrop_item inside nodrop_container changed, got {nodrop_item.x},{nodrop_item.y} expected {x_before.y_before}"); + if ( nodrop_item.x != x_before || nodrop_item.y != y_before ) + return ret_error( $"Position for nodrop_item inside nodrop_container changed, got {nodrop_item.x},{nodrop_item.y} expected {x_before.y_before}" ); endif - DestroyItem(nodrop_container); + DestroyItem( nodrop_container ); return 1; endfunction - // 5. Take item from ground and try to put to container that is too far away. // Item should be returned to the place where it has been taken. exported function undo_drop_here_0_range_check_0() var err; - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - return ret_error($"Could not move character: ${res}"); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + return ret_error( $"Could not move character: ${res}" ); endif - //create container into which we are going to drop - var container := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!container) - return ret_error($"Could not create container: ${container}"); + // create container into which we are going to drop + var container := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !container ) + return ret_error( $"Could not create container: ${container}" ); endif - //create item near character - var item := CreateItemAtLocation(char.x + 1, char.y, char.z, 0x0F3F); - if(!item) - DestroyItem(container); - return ret_error($"Could not create item: {item}"); + // create item near character + var item := CreateItemAtLocation( char.x + 1, char.y, char.z, 0x0F3F ); + if ( !item ) + DestroyItem( container ); + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; var prevItemX := item.x; var prevItemY := item.y; - //lift item - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(container); - DestroyItem(item); + // lift item + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( container ); + DestroyItem( item ); return err; endif - //drop to container - if (!drop_item_failed(err, item.serial, 0xFF, 0xFF, 0, container.serial)) - DestroyItem(container); - DestroyItem(item); + // drop to container + if ( !drop_item_failed( err, item.serial, 0xFF, 0xFF, 0, container.serial ) ) + DestroyItem( container ); + DestroyItem( item ); return err; endif - //container is too far item must be at previous location - if(item.x != prevItemX || item.y != prevItemY) - DestroyItem(container); - DestroyItem(item); - return ret_error($"Item should be returned to place where have taken it."); + // container is too far item must be at previous location + if ( item.x != prevItemX || item.y != prevItemY ) + DestroyItem( container ); + DestroyItem( item ); + return ret_error( $"Item should be returned to place where have taken it." ); endif - DestroyItem(container); - DestroyItem(item); + DestroyItem( container ); + DestroyItem( item ); return 1; endfunction @@ -216,60 +214,60 @@ endfunction // Item should be placed at character backpack. exported function undo_drop_0_range_0_container() var err; - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - return ret_error($"Could not move character: ${res}"); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + return ret_error( $"Could not move character: ${res}" ); endif - //create container into which we are going to drop - var container := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!container) - return ret_error($"Could not create container: ${container}"); + // create container into which we are going to drop + var container := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !container ) + return ret_error( $"Could not create container: ${container}" ); endif - SendViewContainer(char, container); + SendViewContainer( char, container ); - //create item in container - var item := CreateItemInContainer(container, 0x0F3F); - if(!item) - DestroyItem(container); - return ret_error($"Could not create item: {item}"); + // create item in container + var item := CreateItemInContainer( container, 0x0F3F ); + if ( !item ) + DestroyItem( container ); + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; - //move character to accessible range - res := MoveObjectToLocation(char, container.x, container.y, 0); - if (!res) - DestroyItem(container); - DestroyItem(item); - return ret_error($"Could not move character: ${res}"); + // move character to accessible range + res := MoveObjectToLocation( char, container.x, container.y, 0 ); + if ( !res ) + DestroyItem( container ); + DestroyItem( item ); + return ret_error( $"Could not move character: ${res}" ); endif - //lift item - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(container); - DestroyItem(item); + // lift item + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( container ); + DestroyItem( item ); return err; endif - //move character out of accessible range - res := MoveObjectToLocation(char, charX, charY + 4, 0); - if (!res) - DestroyItem(container); - DestroyItem(item); - return ret_error($"Could not move character: ${res}"); + // move character out of accessible range + res := MoveObjectToLocation( char, charX, charY + 4, 0 ); + if ( !res ) + DestroyItem( container ); + DestroyItem( item ); + return ret_error( $"Could not move character: ${res}" ); endif - //drop item - if (!drop_item_failed(err, item.serial, 0xFF, 0xFF, 0, container.serial)) - DestroyItem(container); - DestroyItem(item); + // drop item + if ( !drop_item_failed( err, item.serial, 0xFF, 0xFF, 0, container.serial ) ) + DestroyItem( container ); + DestroyItem( item ); return err; endif - //container is too far, item must be at character backpack - if (!item.container || item.container.serial != char.backpack.serial) - DestroyItem(container); - DestroyItem(item); - return ret_error($"Item should be placed in character backpack."); + // container is too far, item must be at character backpack + if ( !item.container || item.container.serial != char.backpack.serial ) + DestroyItem( container ); + DestroyItem( item ); + return ret_error( $"Item should be placed in character backpack." ); endif - DestroyItem(container); - DestroyItem(item); + DestroyItem( container ); + DestroyItem( item ); return 1; endfunction @@ -278,75 +276,75 @@ endfunction // Item is no_drop, so it should be placed original container. exported function undo_drop_0_range_0_cont_ndrop() var err; - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - return ret_error($"Could not move character: ${res}"); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + return ret_error( $"Could not move character: ${res}" ); endif - //create container into which we are going to drop item - var containerTo := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!containerTo) - return ret_error($"Could not create container to: ${containerTo}"); + // create container into which we are going to drop item + var containerTo := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !containerTo ) + return ret_error( $"Could not create container to: ${containerTo}" ); endif - //create container from which we are going to take item - var containerFrom := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!containerFrom) - DestroyItem(containerTo); - return ret_error($"Could not create container from: ${containerFrom}"); + // create container from which we are going to take item + var containerFrom := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !containerFrom ) + DestroyItem( containerTo ); + return ret_error( $"Could not create container from: ${containerFrom}" ); endif - SendViewContainer(char, containerFrom); + SendViewContainer( char, containerFrom ); - //create item in containerFrom - var item := CreateItemInContainer(containerFrom, 0x0F3F); - if(!item) - DestroyItem(containerTo); - DestroyItem(containerFrom); - return ret_error($"Could not create item: {item}"); + // create item in containerFrom + var item := CreateItemInContainer( containerFrom, 0x0F3F ); + if ( !item ) + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; item.no_drop := 1; - //move character to accessible range - res := MoveObjectToLocation(char, containerFrom.x, containerFrom.y, 0); - if (!res) - DestroyItem(containerTo); - DestroyItem(containerFrom); - DestroyItem(item); - return ret_error($"Could not move character: ${res}"); + // move character to accessible range + res := MoveObjectToLocation( char, containerFrom.x, containerFrom.y, 0 ); + if ( !res ) + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + DestroyItem( item ); + return ret_error( $"Could not move character: ${res}" ); endif - //lift item - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(containerTo); - DestroyItem(containerFrom); - DestroyItem(item); + // lift item + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + DestroyItem( item ); return err; endif - //move character out of accessible range - res := MoveObjectToLocation(char, charX, charY + 4, 0); - if (!res) - DestroyItem(containerTo); - DestroyItem(containerFrom); - DestroyItem(item); - return ret_error($"Could not move character: ${res}"); + // move character out of accessible range + res := MoveObjectToLocation( char, charX, charY + 4, 0 ); + if ( !res ) + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + DestroyItem( item ); + return ret_error( $"Could not move character: ${res}" ); endif - //drop item - if (!drop_item_failed(err, item.serial, 0xFF, 0xFF, 0, containerTo.serial)) - DestroyItem(containerTo); - DestroyItem(containerFrom); - DestroyItem(item); + // drop item + if ( !drop_item_failed( err, item.serial, 0xFF, 0xFF, 0, containerTo.serial ) ) + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + DestroyItem( item ); return err; endif - //item is no_drop, item must be at character backpack - if (!item.container || item.container.serial != containerFrom.serial) - DestroyItem(containerTo); - DestroyItem(containerFrom); - DestroyItem(item); - return ret_error($"Item should be returned in origin container."); + // item is no_drop, item must be at character backpack + if ( !item.container || item.container.serial != containerFrom.serial ) + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + DestroyItem( item ); + return ret_error( $"Item should be returned in origin container." ); endif - DestroyItem(containerTo); - DestroyItem(containerFrom); - DestroyItem(item); + DestroyItem( containerTo ); + DestroyItem( containerFrom ); + DestroyItem( item ); return 1; endfunction @@ -356,91 +354,91 @@ endfunction exported function undo_range_check_1() var err; - var originalConf := ReadFile("::config/servspecopt.cfg"); - if(originalConf == error) - return ret_error($"Could not read config/servspecopt.cfg file: ${originalConf}"); + var originalConf := ReadFile( "::config/servspecopt.cfg" ); + if ( originalConf == error ) + return ret_error( $"Could not read config/servspecopt.cfg file: ${originalConf}" ); endif var newConf := array; foreach line in originalConf - if(Find(line, "UndoGetItemEnableRangeCheck", 1)) + if ( Find( line, "UndoGetItemEnableRangeCheck", 1 ) ) continue; endif - if(Find(line, "DefaultAccessibleRange", 1)) + if ( Find( line, "DefaultAccessibleRange", 1 ) ) continue; endif - newConf.append(line); + newConf.append( line ); endforeach - newConf.append("DefaultAccessibleRange=2"); - newConf.append("UndoGetItemEnableRangeCheck=1"); + newConf.append( "DefaultAccessibleRange=2" ); + newConf.append( "UndoGetItemEnableRangeCheck=1" ); - var writeResult := WriteFile("::config/servspecopt.cfg", newConf); - if(writeResult == error) - return ret_error($"Could not write config/servspecopt.cfg file: ${writeResult}"); + var writeResult := WriteFile( "::config/servspecopt.cfg", newConf ); + if ( writeResult == error ) + return ret_error( $"Could not write config/servspecopt.cfg file: ${writeResult}" ); endif ReloadConfiguration(); - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - WriteFile("::config/servspecopt.cfg", originalConf); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not move character: ${res}"); + return ret_error( $"Could not move character: ${res}" ); endif - //create container into which we are going to drop - var container := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!container) - WriteFile("::config/servspecopt.cfg", originalConf); + // create container into which we are going to drop + var container := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !container ) + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create container: ${container}"); + return ret_error( $"Could not create container: ${container}" ); endif - //create item near the character - var item := CreateItemAtLocation(char.x + 1, char.y, char.z, 0x0F3F); - if(!item) - DestroyItem(container); - WriteFile("::config/servspecopt.cfg", originalConf); + // create item near the character + var item := CreateItemAtLocation( char.x + 1, char.y, char.z, 0x0F3F ); + if ( !item ) + DestroyItem( container ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create item: {item}"); + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; - //lift item - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + // lift item + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return err; endif - //move character to not accessible range - res := MoveObjectToLocation(char, charX - 2, charY, 0); - if (!res) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + // move character to not accessible range + res := MoveObjectToLocation( char, charX - 2, charY, 0 ); + if ( !res ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not move character: ${res}"); + return ret_error( $"Could not move character: ${res}" ); endif - //drop item - if (!drop_item_failed(err, item.serial, 0xFF, 0xFF, 0, container.serial)) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + // drop item + if ( !drop_item_failed( err, item.serial, 0xFF, 0xFF, 0, container.serial ) ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return err; endif - if(item.x != char.x || item.y != char.y) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + if ( item.x != char.x || item.y != char.y ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Item should be placed at character feet."); + return ret_error( $"Item should be placed at character feet." ); endif - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return 1; @@ -451,82 +449,82 @@ endfunction exported function undo_drop_here_1() var err; - var originalConf := ReadFile("::config/servspecopt.cfg"); - if(originalConf == error) - return ret_error($"Could not read config/servspecopt.cfg file: ${originalConf}"); + var originalConf := ReadFile( "::config/servspecopt.cfg" ); + if ( originalConf == error ) + return ret_error( $"Could not read config/servspecopt.cfg file: ${originalConf}" ); endif var newConf := array; foreach line in originalConf - if(Find(line, "UndoGetItemDropHere", 1)) + if ( Find( line, "UndoGetItemDropHere", 1 ) ) continue; endif - if(Find(line, "DefaultAccessibleRange", 1)) + if ( Find( line, "DefaultAccessibleRange", 1 ) ) continue; endif - newConf.append(line); + newConf.append( line ); endforeach - newConf.append("DefaultAccessibleRange=2"); - newConf.append("UndoGetItemDropHere=1"); + newConf.append( "DefaultAccessibleRange=2" ); + newConf.append( "UndoGetItemDropHere=1" ); - var writeResult := WriteFile("::config/servspecopt.cfg", newConf); - if(writeResult == error) - return ret_error($"Could not write config/servspecopt.cfg file: ${writeResult}"); + var writeResult := WriteFile( "::config/servspecopt.cfg", newConf ); + if ( writeResult == error ) + return ret_error( $"Could not write config/servspecopt.cfg file: ${writeResult}" ); endif ReloadConfiguration(); - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - WriteFile("::config/servspecopt.cfg", originalConf); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not move character: ${res}"); + return ret_error( $"Could not move character: ${res}" ); endif - //create container into which we are going to drop - var container := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!container) - WriteFile("::config/servspecopt.cfg", originalConf); + // create container into which we are going to drop + var container := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !container ) + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create container: ${container}"); + return ret_error( $"Could not create container: ${container}" ); endif - //create item near the character - var item := CreateItemAtLocation(char.x + 1, char.y, char.z, 0x0F3F); - if(!item) - DestroyItem(container); - WriteFile("::config/servspecopt.cfg", originalConf); + // create item near the character + var item := CreateItemAtLocation( char.x + 1, char.y, char.z, 0x0F3F ); + if ( !item ) + DestroyItem( container ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create item: {item}"); + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; - //lift item - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + // lift item + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return err; endif - //drop item - if (!drop_item_failed(err, item.serial, 0xFF, 0xFF, 0, container.serial)) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + // drop item + if ( !drop_item_failed( err, item.serial, 0xFF, 0xFF, 0, container.serial ) ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return err; endif - if(item.x != char.x || item.y != char.y) - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + if ( item.x != char.x || item.y != char.y ) + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Item should be placed at character feet."); + return ret_error( $"Item should be placed at character feet." ); endif - DestroyItem(container); - DestroyItem(item); - WriteFile("::config/servspecopt.cfg", originalConf); + DestroyItem( container ); + DestroyItem( item ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return 1; @@ -537,117 +535,117 @@ endfunction exported function undo_range_check_1_ret_nested() var err; - var originalConf := ReadFile("::config/servspecopt.cfg"); - if(originalConf == error) - return ret_error($"Could not read config/servspecopt.cfg file: ${originalConf}"); + var originalConf := ReadFile( "::config/servspecopt.cfg" ); + if ( originalConf == error ) + return ret_error( $"Could not read config/servspecopt.cfg file: ${originalConf}" ); endif var newConf := array; foreach line in originalConf - if(Find(line, "UndoGetItemEnableRangeCheck", 1)) + if ( Find( line, "UndoGetItemEnableRangeCheck", 1 ) ) continue; endif - if(Find(line, "DefaultAccessibleRange", 1)) + if ( Find( line, "DefaultAccessibleRange", 1 ) ) continue; endif - newConf.append(line); + newConf.append( line ); endforeach - newConf.append("DefaultAccessibleRange=2"); - newConf.append("UndoGetItemEnableRangeCheck=1"); + newConf.append( "DefaultAccessibleRange=2" ); + newConf.append( "UndoGetItemEnableRangeCheck=1" ); - var writeResult := WriteFile("::config/servspecopt.cfg", newConf); - if(writeResult == error) - return ret_error($"Could not write config/servspecopt.cfg file: ${writeResult}"); + var writeResult := WriteFile( "::config/servspecopt.cfg", newConf ); + if ( writeResult == error ) + return ret_error( $"Could not write config/servspecopt.cfg file: ${writeResult}" ); endif ReloadConfiguration(); - var res := MoveObjectToLocation(char, charX, charY, 0); - if (!res) - WriteFile("::config/servspecopt.cfg", originalConf); + var res := MoveObjectToLocation( char, charX, charY, 0 ); + if ( !res ) + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not move character: ${res}"); + return ret_error( $"Could not move character: ${res}" ); endif - //create root container - var rootContainer := CreateItemAtLocation(char.x, char.y, char.z, 0xE75); - if (!rootContainer) - WriteFile("::config/servspecopt.cfg", originalConf); + // create root container + var rootContainer := CreateItemAtLocation( char.x, char.y, char.z, 0xE75 ); + if ( !rootContainer ) + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create root container: ${rootContainer}"); + return ret_error( $"Could not create root container: ${rootContainer}" ); endif - SendViewContainer(char, rootContainer); + SendViewContainer( char, rootContainer ); - //create container in root container from which we are going to take item - var nestedContainer := CreateItemInContainer(rootContainer, 0xE75); - if (!nestedContainer) - DestroyItem(rootContainer); - WriteFile("::config/servspecopt.cfg", originalConf); + // create container in root container from which we are going to take item + var nestedContainer := CreateItemInContainer( rootContainer, 0xE75 ); + if ( !nestedContainer ) + DestroyItem( rootContainer ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create nested container: ${nestedContainer}"); + return ret_error( $"Could not create nested container: ${nestedContainer}" ); endif - SendViewContainer(char, nestedContainer); + SendViewContainer( char, nestedContainer ); - //create item in nested container - var item := CreateItemInContainer(nestedContainer, 0x201f03); - if(!item) - DestroyItem(rootContainer); - WriteFile("::config/servspecopt.cfg", originalConf); + // create item in nested container + var item := CreateItemInContainer( nestedContainer, 0x201f03 ); + if ( !item ) + DestroyItem( rootContainer ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create item: {item}"); + return ret_error( $"Could not create item: {item}" ); endif item.movable := 1; - var containerTo := CreateItemAtLocation(char.x + 4, char.y, char.z, 0xE75); - if (!containerTo) - DestroyItem(rootContainer); - WriteFile("::config/servspecopt.cfg", originalConf); + var containerTo := CreateItemAtLocation( char.x + 4, char.y, char.z, 0xE75 ); + if ( !containerTo ) + DestroyItem( rootContainer ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create to container: ${containerTo}"); + return ret_error( $"Could not create to container: ${containerTo}" ); endif - //create heavy item in backpack to make container full - var backpackItem := CreateItemInContainer(char.backpack, 0x201f03); - if(!backpackItem) - DestroyItem(rootContainer); - DestroyItem(containerTo); - WriteFile("::config/servspecopt.cfg", originalConf); + // create heavy item in backpack to make container full + var backpackItem := CreateItemInContainer( char.backpack, 0x201f03 ); + if ( !backpackItem ) + DestroyItem( rootContainer ); + DestroyItem( containerTo ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Could not create backpack item: {backpackItem}"); + return ret_error( $"Could not create backpack item: {backpackItem}" ); endif - //lift item - if (!lift_item_succeeded(err, item.serial)) - DestroyItem(rootContainer); - DestroyItem(containerTo); - DestroyItem(backpackItem); - WriteFile("::config/servspecopt.cfg", originalConf); + // lift item + if ( !lift_item_succeeded( err, item.serial ) ) + DestroyItem( rootContainer ); + DestroyItem( containerTo ); + DestroyItem( backpackItem ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return err; endif - //drop item - if (!drop_item_failed(err, item.serial, 0xFF, 0xFF, 0, containerTo.serial)) - DestroyItem(rootContainer); - DestroyItem(containerTo); - DestroyItem(backpackItem); - WriteFile("::config/servspecopt.cfg", originalConf); + // drop item + if ( !drop_item_failed( err, item.serial, 0xFF, 0xFF, 0, containerTo.serial ) ) + DestroyItem( rootContainer ); + DestroyItem( containerTo ); + DestroyItem( backpackItem ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return err; endif - if (!item.container || item.container.serial != nestedContainer.serial) - DestroyItem(rootContainer); - DestroyItem(containerTo); - DestroyItem(backpackItem); - WriteFile("::config/servspecopt.cfg", originalConf); + if ( !item.container || item.container.serial != nestedContainer.serial ) + DestroyItem( rootContainer ); + DestroyItem( containerTo ); + DestroyItem( backpackItem ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); - return ret_error($"Item should be returned in original container."); + return ret_error( $"Item should be returned in original container." ); endif - DestroyItem(rootContainer); - DestroyItem(containerTo); - DestroyItem(backpackItem); - WriteFile("::config/servspecopt.cfg", originalConf); + DestroyItem( rootContainer ); + DestroyItem( containerTo ); + DestroyItem( backpackItem ); + WriteFile( "::config/servspecopt.cfg", originalConf ); ReloadConfiguration(); return 1; @@ -657,21 +655,24 @@ endfunction * Helper functions */ -function drop_item_failed(byref err, serial, x, y, z, dropped_on_serial := 0xFFFFFFFF) +function drop_item_failed( byref err, serial, x, y, z, dropped_on_serial := 0xFFFFFFFF ) Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="drop_item", arg:=struct{serial := serial, x := x, y := y, z := z, dropped_on_serial := dropped_on_serial}, id:=0}); + clientcon.sendevent( struct{ todo := "drop_item", + arg := struct{ serial := serial, x := x, y := y, + z := z, dropped_on_serial := dropped_on_serial }, + id := 0 } ); var ev; - while (1) - ev:=waitForClient(0, {EVT_DROP_ITEM}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_DROP_ITEM } ); + if ( !ev ) return err := ev; endif break; endwhile - while (1) - ev:=waitForClient(0, {EVT_MOVE_ITEM_REJECTED}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_MOVE_ITEM_REJECTED } ); + if ( !ev ) return err := ev; endif break; @@ -679,21 +680,24 @@ function drop_item_failed(byref err, serial, x, y, z, dropped_on_serial := 0xFFF return 1; endfunction -function drop_item_succeeded(byref err, serial, x, y, z, dropped_on_serial := 0xFFFFFFFF) +function drop_item_succeeded( byref err, serial, x, y, z, dropped_on_serial := 0xFFFFFFFF ) Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="drop_item", arg:=struct{serial := serial, x := x, y := y, z := z, dropped_on_serial := dropped_on_serial}, id:=0}); + clientcon.sendevent( struct{ todo := "drop_item", + arg := struct{ serial := serial, x := x, y := y, + z := z, dropped_on_serial := dropped_on_serial }, + id := 0 } ); var ev; - while (1) - ev:=waitForClient(0, {EVT_DROP_ITEM}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_DROP_ITEM } ); + if ( !ev ) return err := ev; endif break; endwhile - while (1) - ev:=waitForClient(0, {EVT_DROP_APPROVED}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_DROP_APPROVED } ); + if ( !ev ) return err := ev; endif break; @@ -701,22 +705,22 @@ function drop_item_succeeded(byref err, serial, x, y, z, dropped_on_serial := 0x return 1; endfunction -function lift_item_succeeded(byref err, serial) +function lift_item_succeeded( byref err, serial ) Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="lift_item", arg:=serial, id:=0}); + clientcon.sendevent( struct{ todo := "lift_item", arg := serial, id := 0 } ); var ev; - while (1) - ev:=waitForClient(0, {EVT_LIFT_ITEM}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_LIFT_ITEM } ); + if ( !ev ) return err := ev; endif break; endwhile // TODO: see top - ev:=waitForClient(0, {EVT_MOVE_ITEM_REJECTED}, 1); - if (ev) - return err := ret_error($"Got unexpected move (lift) item rejected: reason = {ev.reason}");; + ev := waitForClient( 0, { EVT_MOVE_ITEM_REJECTED }, 1 ); + if ( ev ) + return err := ret_error( $"Got unexpected move (lift) item rejected: reason = {ev.reason}" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/client/test_client_range.src b/testsuite/pol/testpkgs/client/test_client_range.src index b57e01327..5be3322a1 100644 --- a/testsuite/pol/testpkgs/client/test_client_range.src +++ b/testsuite/pol/testpkgs/client/test_client_range.src @@ -11,90 +11,89 @@ var char2; var clientcon := getClientConnection(); program chartests() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - a:=FindAccount("testclient1"); - char2:=a.getcharacter(1); - if (!char2) - return ret_error("Could not find char2 at slot 1"); + a := FindAccount( "testclient1" ); + char2 := a.getcharacter( 1 ); + if ( !char2 ) + return ret_error( "Could not find char2 at slot 1" ); endif endprogram - /* move one char out of range of other char and back into it Note: moving char does not receive deleteobj pkt */ exported function chr_update_range() - MoveObjectToLocation(char2, 100,100,0,flags:=MOVEOBJECT_FORCELOCATION); - MoveObjectToLocation(char, 115,100,0, flags:=MOVEOBJECT_FORCELOCATION); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveObjectToLocation( char2, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); + MoveObjectToLocation( char, 115, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - char.facing:=1; + char.facing := 1; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="move",arg:=2,id:=0}); - var i:=10; - while (--i>0) - var ev:=waitForClients({EVT_MOVED, EVT_REMOVED_OBJ}); - if (!ev) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); + clientcon.sendevent( struct{ todo := "move", arg := 2, id := 0 } ); + var i := 10; + while ( --i > 0 ) + var ev := waitForClients( { EVT_MOVED, EVT_REMOVED_OBJ } ); + if ( !ev ) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); return ev; endif - if (ev.type == EVT_MOVED) - if (!ev.ack) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - return ret_error("failed to move"); + if ( ev.type == EVT_MOVED ) + if ( !ev.ack ) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + return ret_error( "failed to move" ); endif - clientcon.sendevent(struct{todo:="move",arg:=2,id:=0}); + clientcon.sendevent( struct{ todo := "move", arg := 2, id := 0 } ); continue; endif - if (ev["id"]==1 && ev["serial"] == char.serial) - var x:=ev["oldpos"][1]-char2.x; - if (x!=18) // (18 visual range) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - return ret_error($"remove update distance failed: {x}"); + if ( ev["id"] == 1 && ev["serial"] == char.serial ) + var x := ev["oldpos"][1] - char2.x; + if ( x != 18 ) // (18 visual range) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + return ret_error( $"remove update distance failed: {x}" ); endif break; endif endwhile - if (i==0) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - return ret_error("char was never removed"); + if ( i == 0 ) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + return ret_error( "char was never removed" ); endif // move char again into range - clientcon.sendevent(struct{todo:="move",arg:=6,id:=0}); - i:=10; - while (--i>0) - var ev:=waitForClients({EVT_MOVED, EVT_NEW_MOBILE}); - if (!ev) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); + clientcon.sendevent( struct{ todo := "move", arg := 6, id := 0 } ); + i := 10; + while ( --i > 0 ) + var ev := waitForClients( { EVT_MOVED, EVT_NEW_MOBILE } ); + if ( !ev ) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); return ev; endif - if (ev.type == EVT_MOVED) - if (!ev.ack) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - return ret_error("failed to move"); + if ( ev.type == EVT_MOVED ) + if ( !ev.ack ) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + return ret_error( "failed to move" ); endif - clientcon.sendevent(struct{todo:="move",arg:=6,id:=0}); + clientcon.sendevent( struct{ todo := "move", arg := 6, id := 0 } ); continue; endif - if (ev["id"] == 1 && ev["serial"] == char.serial) - var x:=ev["pos"][1]-char2.x; - if (x!=18) // (18 visual range) - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - return ret_error($"update distance failed: {x}"); + if ( ev["id"] == 1 && ev["serial"] == char.serial ) + var x := ev["pos"][1] - char2.x; + if ( x != 18 ) // (18 visual range) + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + return ret_error( $"update distance failed: {x}" ); endif break; endif endwhile - while (waitForClient(0, {},1)) + while ( waitForClient( 0, {}, 1 ) ) endwhile - MoveObjectToLocation(char2, 1,1,1,flags:=MOVEOBJECT_FORCELOCATION); - if (i==0) - return ret_error("char was never readded"); + MoveObjectToLocation( char2, 1, 1, 1, flags := MOVEOBJECT_FORCELOCATION ); + if ( i == 0 ) + return ret_error( "char was never readded" ); endif return 1; endfunction @@ -102,42 +101,42 @@ endfunction /* move char into range of item */ exported function item_update_range() - MoveObjectToLocation(char, 100,100,0, flags:=MOVEOBJECT_FORCELOCATION); - var item:=CreateItemAtLocation(char.x+20, char.y,char.z, 0xf3f); - while (!waitForClient(0, {EVT_OWNCREATE})) + MoveObjectToLocation( char, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); + var item := CreateItemAtLocation( char.x + 20, char.y, char.z, 0xf3f ); + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - char.facing:=1; + char.facing := 1; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="move",arg:=2,id:=0}); - var i:=10; - while (--i>0) - var ev:=waitForClient(0,{EVT_MOVED, EVT_NEW_ITEM}); - if (!ev) - DestroyItem(item); + clientcon.sendevent( struct{ todo := "move", arg := 2, id := 0 } ); + var i := 10; + while ( --i > 0 ) + var ev := waitForClient( 0, { EVT_MOVED, EVT_NEW_ITEM } ); + if ( !ev ) + DestroyItem( item ); return ev; endif - if (ev.type == EVT_MOVED) - if (!ev.ack) - DestroyItem(item); - return ret_error("failed to move"); + if ( ev.type == EVT_MOVED ) + if ( !ev.ack ) + DestroyItem( item ); + return ret_error( "failed to move" ); endif - clientcon.sendevent(struct{todo:="move",arg:=2,id:=0}); + clientcon.sendevent( struct{ todo := "move", arg := 2, id := 0 } ); continue; endif - if (ev["serial"] == item.serial) - var x:=ev["pos"][1]-char.x; - if (x!=18) // (18 visual range) - DestroyItem(item); - return ret_error($"update distance failed: {x}"); + if ( ev["serial"] == item.serial ) + var x := ev["pos"][1] - char.x; + if ( x != 18 ) // (18 visual range) + DestroyItem( item ); + return ret_error( $"update distance failed: {x}" ); endif break; endif endwhile - DestroyItem(item); - while (waitForClient(0, {},1)) + DestroyItem( item ); + while ( waitForClient( 0, {}, 1 ) ) endwhile - if (i==0) - return ret_error("item was never visible"); + if ( i == 0 ) + return ret_error( "item was never visible" ); endif return 1; endfunction @@ -145,45 +144,45 @@ endfunction /* move char into range of multi */ exported function multi_update_range() - MoveObjectToLocation(char, 100,100,0, flags:=MOVEOBJECT_FORCELOCATION); - var multi:=CreateMultiAtLocation(char.x+24,char.y,char.z,0x12000); - if (!multi) - return ret_error("Failed to create multi "+multi); + MoveObjectToLocation( char, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ); + var multi := CreateMultiAtLocation( char.x + 24, char.y, char.z, 0x12000 ); + if ( !multi ) + return ret_error( "Failed to create multi " + multi ); endif - while (!waitForClient(0, {EVT_OWNCREATE})) + while ( !waitForClient( 0, { EVT_OWNCREATE } ) ) endwhile - char.facing:=1; + char.facing := 1; Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="move",arg:=2,id:=0}); - var i:=10; - while (--i>0) - var ev:=waitForClient(0,{EVT_MOVED, EVT_NEW_ITEM}); - if (!ev) - DestroyMulti(multi); + clientcon.sendevent( struct{ todo := "move", arg := 2, id := 0 } ); + var i := 10; + while ( --i > 0 ) + var ev := waitForClient( 0, { EVT_MOVED, EVT_NEW_ITEM } ); + if ( !ev ) + DestroyMulti( multi ); return ev; endif - if (ev.type == EVT_MOVED) - if (!ev.ack) - DestroyMulti(multi); - return ret_error("failed to move"); + if ( ev.type == EVT_MOVED ) + if ( !ev.ack ) + DestroyMulti( multi ); + return ret_error( "failed to move" ); endif - clientcon.sendevent(struct{todo:="move",arg:=2,id:=0}); + clientcon.sendevent( struct{ todo := "move", arg := 2, id := 0 } ); continue; endif - if (ev["serial"] == multi.serial) - var x:=ev["pos"][1]-char.x; - if ( x!=22 ) // (18 visual range + 4) - DestroyMulti(multi); - return ret_error($"update distance failed: {x}"); + if ( ev["serial"] == multi.serial ) + var x := ev["pos"][1] - char.x; + if ( x != 22 ) // (18 visual range + 4) + DestroyMulti( multi ); + return ret_error( $"update distance failed: {x}" ); endif break; endif endwhile - while (waitForClient(0, {},1)) + while ( waitForClient( 0, {}, 1 ) ) endwhile - DestroyMulti(multi); - if (i==0) - return ret_error("multi was never visible"); + DestroyMulti( multi ); + if ( i == 0 ) + return ret_error( "multi was never visible" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/client/test_client_snoop.src b/testsuite/pol/testpkgs/client/test_client_snoop.src index 2491939e3..341477f76 100644 --- a/testsuite/pol/testpkgs/client/test_client_snoop.src +++ b/testsuite/pol/testpkgs/client/test_client_snoop.src @@ -12,177 +12,175 @@ var backpackItem; var clientcon := getClientConnection(); program chartests() - var a:=FindAccount("testclient0"); - char:=a.getcharacter(1); - if (!char) - return ret_error("Could not find char at slot 1"); + var a := FindAccount( "testclient0" ); + char := a.getcharacter( 1 ); + if ( !char ) + return ret_error( "Could not find char at slot 1" ); endif - npc:=CreateNpcFromTemplate(":TestClient:test_snooping", 100, 100, 0, forcelocation := 1); - if (!npc) - return ret_error("Failed to create NPC: "+npc); + npc := CreateNpcFromTemplate( ":TestClient:test_snooping", 100, 100, 0, forcelocation := 1 ); + if ( !npc ) + return ret_error( "Failed to create NPC: " + npc ); endif - var backpack := CreateItemAtLocation( 100, 100, 0, "SnoopableBackPack"); - if (!backpack) - return ret_error("Failed to create backpack item: "+npc); + var backpack := CreateItemAtLocation( 100, 100, 0, "SnoopableBackPack" ); + if ( !backpack ) + return ret_error( "Failed to create backpack item: " + npc ); endif - backpackItem := CreateItemInContainer(backpack, "SnoopableBackPack"); - if (!backpackItem) - return ret_error("Failed to create item in backpack: "+backpackItem); + backpackItem := CreateItemInContainer( backpack, "SnoopableBackPack" ); + if ( !backpackItem ) + return ret_error( "Failed to create item in backpack: " + backpackItem ); endif - EquipItem(npc, backpack); - if (!npc.backpack) - return ret_error("NPC has no backpack: "+npc.backpack); + EquipItem( npc, backpack ); + if ( !npc.backpack ) + return ret_error( "NPC has no backpack: " + npc.backpack ); endif - print($"npc {npc.serial} backpack {npc.backpack.serial} backpackItem {backpackItem.serial}"); + print( $"npc {npc.serial} backpack {npc.backpack.serial} backpackItem {backpackItem.serial}" ); - SetGlobalProperty("#SnoopingNpc", npc.serial); + SetGlobalProperty( "#SnoopingNpc", npc.serial ); endprogram exported function use_backpack_out_of_range() - MoveObjectToLocation(npc, char.x+20, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( npc, char.x + 20, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION ); Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="double_click", arg:=npc.backpack.serial, id:=0}); + clientcon.sendevent( struct{ todo := "double_click", arg := npc.backpack.serial, id := 0 } ); var ev; - while (1) - ev:=waitForClient(0, {EVT_SPEECH}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_SPEECH } ); + if ( !ev ) return ev; endif - if (!ev.msg) - return ret_error("No msg property on EVT_SPEECH event"); + if ( !ev.msg ) + return ret_error( "No msg property on EVT_SPEECH event" ); endif break; endwhile var expected := "That is too far away."; - if (ev.msg == expected) + if ( ev.msg == expected ) return 1; endif - return ret_error($"Unexpected double-click message: '{ev.msg}' != '{expected}'"); + return ret_error( $"Unexpected double-click message: '{ev.msg}' != '{expected}'" ); endfunction - exported function use_backpack_in_range() - MoveObjectToLocation(npc, char.x, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( npc, char.x, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION ); Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="double_click", arg:=npc.backpack.serial, id:=0}); + clientcon.sendevent( struct{ todo := "double_click", arg := npc.backpack.serial, id := 0 } ); var ev; - while (1) - ev:=waitForClient(0, {EVT_DOUBLE_CLICK}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_DOUBLE_CLICK } ); + if ( !ev ) return ev; endif break; endwhile Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="list_objects", id:=0}); - while (1) - ev:=waitForClient(0, {EVT_LIST_OBJS}); - if (!ev) + clientcon.sendevent( struct{ todo := "list_objects", id := 0 } ); + while ( 1 ) + ev := waitForClient( 0, { EVT_LIST_OBJS } ); + if ( !ev ) return ev; endif break; endwhile - foreach item in (ev.objs) - if (item.serial == backpackItem.serial) - if (item.parent == npc.backpack.serial) + foreach item in ( ev.objs ) + if ( item.serial == backpackItem.serial ) + if ( item.parent == npc.backpack.serial ) return 1; else - return ret_error($"Found backpack item {item.serial}, but parent {item.parent} is not npc backpack {npc.backpack.serial}."); + return ret_error( $"Found backpack item {item.serial}, but parent {item.parent} is not npc backpack {npc.backpack.serial}." ); endif endif endforeach - return ret_error("Could not find backpack item in client's list of objects."); + return ret_error( "Could not find backpack item in client's list of objects." ); endfunction - exported function target_nonlocal_checklos() - MoveObjectToLocation(npc, char.x + 2, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( npc, char.x + 2, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION ); - var wall := CreateItemAtLocation(char.x + 1, char.y, char.z, 0x06); // wooden wall - if (!wall) - return ret_error($"Could not create wall: {wall}"); + var wall := CreateItemAtLocation( char.x + 1, char.y, char.z, 0x06 ); // wooden wall + if ( !wall ) + return ret_error( $"Could not create wall: {wall}" ); endif - SendViewContainer(char, npc.backpack); + SendViewContainer( char, npc.backpack ); Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="target", - arg:=struct{serial:=backpackItem.serial}, - id:=0}); + clientcon.sendevent( struct{ todo := "target", arg := struct{ + serial := backpackItem.serial }, id := 0 } ); - var tar:=Target(char,TGTOPT_ALLOW_NONLOCAL | TGTOPT_CHECK_LOS); + var tar := Target( char, TGTOPT_ALLOW_NONLOCAL | TGTOPT_CHECK_LOS ); - DestroyItem(wall); + DestroyItem( wall ); - if (tar) - return ret_error($"Unexpected successful target: {tar.serial} {tar.desc} los check {CheckLosAt(char, npc.x, npc.y, npc.z)}"); + if ( tar ) + return ret_error( $"Unexpected successful target: {tar.serial} {tar.desc} los check {CheckLosAt( char, + npc.x, + npc.y, + npc.z )}" ); endif - + var ev; var expected := "That is not within your line of sight."; - while (1) - ev:=waitForClient(0, {EVT_SPEECH}); - if (!ev) + while ( 1 ) + ev := waitForClient( 0, { EVT_SPEECH } ); + if ( !ev ) return ev; endif - if (!ev.msg) - return ret_error("No msg property on EVT_SPEECH event"); + if ( !ev.msg ) + return ret_error( "No msg property on EVT_SPEECH event" ); endif - if (ev.msg == expected) + if ( ev.msg == expected ) return 1; endif endwhile - return ret_error($"Unexpected target message message: '{ev.msg}' != '{expected}'"); + return ret_error( $"Unexpected target message message: '{ev.msg}' != '{expected}'" ); endfunction - exported function target_nonlocal_nochecklos() - MoveObjectToLocation(npc, char.x + 2, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION); + MoveObjectToLocation( npc, char.x + 2, char.y, char.z, flags := MOVEOBJECT_FORCELOCATION ); - SendViewContainer(char, npc.backpack); + SendViewContainer( char, npc.backpack ); - var wall := CreateItemAtLocation(char.x + 1, char.y, char.z, 0x06); // wooden wall - if (!wall) - return ret_error($"Could not create wall: {wall}"); + var wall := CreateItemAtLocation( char.x + 1, char.y, char.z, 0x06 ); // wooden wall + if ( !wall ) + return ret_error( $"Could not create wall: {wall}" ); endif Clear_Event_Queue(); - clientcon.sendevent(struct{todo:="target", - arg:=struct{serial:=backpackItem.serial}, - id:=0}); + clientcon.sendevent( struct{ todo := "target", arg := struct{ + serial := backpackItem.serial }, id := 0 } ); - var tar:=Target(char,TGTOPT_ALLOW_NONLOCAL | TGTOPT_NOCHECK_LOS); + var tar := Target( char, TGTOPT_ALLOW_NONLOCAL | TGTOPT_NOCHECK_LOS ); - DestroyItem(wall); + DestroyItem( wall ); - while (1) - var ev:=waitForClient(0, {EVT_TARGET}); - if (!ev) + while ( 1 ) + var ev := waitForClient( 0, { EVT_TARGET } ); + if ( !ev ) return ev; endif - if (!ev.res || ev.targettype != 0) - return ret_error($"Target failed, no cursor or wrong type {ev.targettype}"); + if ( !ev.res || ev.targettype != 0 ) + return ret_error( $"Target failed, no cursor or wrong type {ev.targettype}" ); endif break; endwhile - if (tar.serial != backpackItem.serial) - return ret_error($"Target failed, wrong serial {tar.serial}"); + if ( tar.serial != backpackItem.serial ) + return ret_error( $"Target failed, wrong serial {tar.serial}" ); endif return 1; diff --git a/testsuite/pol/testpkgs/debugger/debuggee.src b/testsuite/pol/testpkgs/debugger/debuggee.src index 593ba3d45..d7660fd6b 100644 --- a/testsuite/pol/testpkgs/debugger/debuggee.src +++ b/testsuite/pol/testpkgs/debugger/debuggee.src @@ -5,58 +5,60 @@ var global_string := "global_string"; var global_long := 1; var global_float := 3.14; var global_array := array{ "global_array[1]", "global_array[2]", "global_array[3]" }; -var global_struct := struct{ "key1" := "global_struct.key1", "key2" := "global_struct.key2", "key3" := "global_struct.key3" }; -var global_dict := dictionary{ 1 -> "global_dict[1]", 2 -> "global_dict[2]", "three" -> "global_dict[\"three\"]" }; +var global_struct := struct{ "key1" := "global_struct.key1", "key2" := "global_struct.key2", + "key3" := "global_struct.key3" }; +var global_dict := dictionary{ 1 -> "global_dict[1]", 2 -> "global_dict[2]", + "three" -> "global_dict[\"three\"]" }; var shadowed_variable := "shadowed_variable:global"; -program main(running) - do - Debugger(); - var func1_result := func1("func1:param1", global_string, global_long); - var func2_result := func2("func2:param1", global_float, global_array); - var shadowed_result := funcShadowed("funcShadowed:param1"); - Sleepms(1); - dowhile (running && running != "stop"); +program main( running ) + do + Debugger(); + var func1_result := func1( "func1:param1", global_string, global_long ); + var func2_result := func2( "func2:param1", global_float, global_array ); + var shadowed_result := funcShadowed( "funcShadowed:param1" ); + Sleepms( 1 ); + dowhile ( running && running != "stop" ); - // This only prints in the "launch" test, as the "attach" test never finishes the loop. - // - // [NB: The "launch" test kills this script once the test finishes, whereas the "launch" - // script waits for this script to exit.] + // This only prints in the "launch" test, as the "attach" test never finishes the loop. + // + // [NB: The "launch" test kills this script once the test finishes, whereas the "launch" + // script waits for this script to exit.] - print( "Loop finished!" ); /*print*/ + print( "Loop finished!" ); /* print */ endprogram function func1( func1_param1, func1_param2, func1_param3 ) - func1_param1; - func1_param2; - func1_param3; - return "func1:return"; + func1_param1; + func1_param2; + func1_param3; + return "func1:return"; endfunction function func2( func2_param1, func2_param2, func2_param3 ) - func2_param1; - func2_param2; - func2_param3; - var funct3_result := func3("func3:param1", global_struct, global_dict); /*set_bp*/ - return "func2:return"; + func2_param1; + func2_param2; + func2_param3; + var funct3_result := func3( "func3:param1", global_struct, global_dict ); /* set_bp */ + return "func2:return"; endfunction function func3( func3_param1, func3_param2, func3_param3 ) - func3_param1; - func3_param2; - func3_param3; - return "func3:return"; + func3_param1; + func3_param2; + func3_param3; + return "func3:return"; endfunction -function funcShadowed(shadowed_variable) - shadowed_variable; /*set_bp*/ - var was_paused := 0; // Set by debugger - for i := 1 to 10 - if (was_paused) - break; - endif - Sleepms(100); // Used for `pause` - endfor - return was_paused; +function funcShadowed( shadowed_variable ) + shadowed_variable; /* set_bp */ + var was_paused := 0; // Set by debugger + for i := 1 to 10 + if ( was_paused ) + break; + endif + Sleepms( 100 ); // Used for `pause` + endfor + return was_paused; endfunction diff --git a/testsuite/pol/testpkgs/debugger/debugger_client.src b/testsuite/pol/testpkgs/debugger/debugger_client.src index 764cd7299..aefee38ac 100644 --- a/testsuite/pol/testpkgs/debugger/debugger_client.src +++ b/testsuite/pol/testpkgs/debugger/debugger_client.src @@ -27,600 +27,622 @@ var connection; var nextSequence := 1; var recvBuffer := ""; -program auxservice(conn, params) - connection := conn; +program auxservice( conn, params ) + connection := conn; - var result; - var test_script_pid := params.test_script_pid; - var test_type := params.test_type; + var result; + var test_script_pid := params.test_script_pid; + var test_type := params.test_type; - if (test_type == "attach") - result := run_attach_test(params.debuggee_pid); - elseif (test_type == "launch") - result := run_launch_test(); - else - result := ret_error($"Unknown debugger test type '{test_type}'"); - endif - GetProcess(test_script_pid).SendEvent(struct{ result := result }); - connection := 0; + if ( test_type == "attach" ) + result := run_attach_test( params.debuggee_pid ); + elseif ( test_type == "launch" ) + result := run_launch_test(); + else + result := ret_error( $"Unknown debugger test type '{test_type}'" ); + endif + GetProcess( test_script_pid ).SendEvent( struct{ result := result } ); + connection := 0; endprogram function run_launch_test() - // Get script source - var source := ReadFile( "debuggee.src" ); - if (!source) - return ret_error(source); + // Get script source + var source := ReadFile( "debuggee.src" ); + if ( !source ) + return ret_error( source ); + endif + + var print_linenum; + foreach line in source + if ( line.find( "/* print */" ) ) + print_linenum := _line_iter; endif + endforeach - var print_linenum; - foreach line in source - if (line.find("/*print*/")) - print_linenum := _line_iter; - endif - endforeach + var err; - var err; + // Send request: initialize + if ( !request_succeeded( err, "initialize", struct{ adapterID := "pol", password := "debugme" } ) ) + return err; + endif - // Send request: initialize - if (!request_succeeded(err, "initialize", struct{ adapterID := "pol", password := "debugme" })) - return err; - endif + // Wait for event: initialized + if ( !event_received( err, "initialized" ) ) + return err; + endif - // Wait for event: initialized - if (!event_received(err, "initialized")) - return err; - endif + // Send request: launch + // Note: Sets the program's parameter as "stop" + if ( !request_succeeded( err, "launch", struct{ "script" := ":testdebugger:debuggee", + arg := "S4:stop" /* packed */ } + ) ) + return err; + endif - // Send request: launch - // Note: Sets the program's parameter as "stop" - if (!request_succeeded(err, "launch", struct{ "script" := ":testdebugger:debuggee", arg := "S4:stop" /* packed */ })); - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: threads + // Note: Since we only have one thread that never changes, test sends this message only once. + var threads; + if ( !( threads := request_succeeded( err, "threads" ) ) ) + return err; + endif + var threadId := threads.threads[1].id; - // Send request: threads - // Note: Since we only have one thread that never changes, test sends this message only once. - var threads; - if (!(threads := request_succeeded(err, "threads"))) - return err; - endif - var threadId := threads.threads[1].id; + // Send request: stackTrace + var stackTrace; + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - var stackTrace; - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + // Send request: scopes + var scopes; + if ( !( scopes := request_succeeded( err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id } + ) ) ) + return err; + endif - // Send request: scopes - var scopes; - if (!(scopes := request_succeeded(err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id }))) - return err; - endif + var evaluate; + if ( !( evaluate := request_succeeded( err, "evaluate", struct{ expression := "running", + frameId := scopes.scopes[1].variablesReference } + ) ) ) + return err; + endif - var evaluate; - if (!(evaluate := request_succeeded(err, "evaluate", struct{ expression := "running", frameId := scopes.scopes[1].variablesReference }))) - return err; - endif + if ( evaluate.result != "\"stop\"" ) + return ret_error( $"Program argument from launch request `running` does not equal '\"stop\"': '{evaluate.result}' != '\"stop\"'" ); + endif - if (evaluate.result != "\"stop\"") - return ret_error($"Program argument from launch request `running` does not equal '\"stop\"': '{evaluate.result}' != '\"stop\"'"); - endif + // Send request: continue + if ( !request_succeeded( err, "continue", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: continue - if (!request_succeeded(err, "continue", struct{ threadId := threadId })) - return err; - endif + // Wait for event: output + var output; + if ( !( output := event_received( err, "output" ) ) ) + return err; + endif - // Wait for event: output - var output; - if ( !( output := event_received( err, "output" ) ) ) - return err; - endif + var expected := struct{ category := "stdout", + output := "Loop finished!\n", + line := print_linenum, + source := struct{ path := stackTrace.stackFrames[1].source.path } }; - var expected := struct{ - category := "stdout", - output := "Loop finished!\n", - line := print_linenum, - source := struct{ - path := stackTrace.stackFrames[1].source.path - } - }; + if ( output.category != expected.category || output.output != expected.output || + output.line != expected.line || output.source.path != expected.source.path ) + return ret_error( $"Incorrect output event. Expected: {expected}, actual {output}" ); + endif - if ( output.category != expected.category || - output.output != expected.output || - output.line != expected.line || - output.source.path != expected.source.path ) - return ret_error( $"Incorrect output event. Expected: {expected}, actual {output}" ); - endif + // Wait for event: exited + if ( !event_received( err, "exited" ) ) + return err; + endif - // Wait for event: exited - if (!event_received(err, "exited")) - return err; - endif - - return 1; + return 1; endfunction -function run_attach_test(debuggee_pid) - var err; +function run_attach_test( debuggee_pid ) + var err; - // Send request: initialize - if (!request_succeeded(err, "initialize", struct{ adapterID := "pol", password := "debugme" })) + // Send request: initialize + if ( !request_succeeded( err, "initialize", struct{ adapterID := "pol", password := "debugme" } ) ) + return err; + endif + + // Wait for event: initialized + if ( !event_received( err, "initialized" ) ) + return err; + endif + + // Send request: processes + var processes; + if ( !( processes := request_succeeded( err, "processes", struct{ filter := "debuggee" } ) ) ) + return err; + endif + + if ( processes.processes[1].id != debuggee_pid ) + return ret_error( $"Process id does not match! Expected {processes.processes[1].id} == {debuggee_pid}" ); + endif + + // Send request: attach + if ( !request_succeeded( err, "attach", struct{ pid := debuggee_pid } ) ) + return err; + endif + + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif + + // Send request: threads + // Note: Since we only have one thread that never changes, test sends this message only once. + var threads; + if ( !( threads := request_succeeded( err, "threads" ) ) ) + return err; + endif + var threadId := threads.threads[1].id; + + // Send request: stackTrace + var stackTrace; + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif + + // Send request: scopes + var scopes; + if ( !( scopes := request_succeeded( err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id } + ) ) ) + return err; + endif + + var scope_varibles := array{}; + foreach scope in ( scopes.scopes ) + var variables; + if ( !( variables := request_succeeded( err, "variables", struct{ variablesReference := scope.variablesReference } + ) ) ) + return err; + endif + + foreach variable in ( variables.variables ) + var evaluate; + if ( !( evaluate := request_succeeded( err, "evaluate", struct{ expression := variable.name, + frameId := scope.variablesReference } + ) ) ) return err; - endif + endif - // Wait for event: initialized - if (!event_received(err, "initialized")) - return err; - endif + if ( variable.value != evaluate.result ) + return ret_error( $"Variables value does not match evaluate result: '{variable.value}' != '{evaluate.result}'" ); + endif - // Send request: processes - var processes; - if (!(processes := request_succeeded(err, "processes", struct{ filter := "debuggee" }))) - return err; - endif - - if (processes.processes[1].id != debuggee_pid) - return ret_error($"Process id does not match! Expected {processes.processes[1].id} == {debuggee_pid}"); - endif - - // Send request: attach - if (!request_succeeded(err, "attach", struct{ pid := debuggee_pid })) - return err; - endif - - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif - - // Send request: threads - // Note: Since we only have one thread that never changes, test sends this message only once. - var threads; - if (!(threads := request_succeeded(err, "threads"))) - return err; - endif - var threadId := threads.threads[1].id; - - // Send request: stackTrace - var stackTrace; - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif - - // Send request: scopes - var scopes; - if (!(scopes := request_succeeded(err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id }))) - return err; - endif - - var scope_varibles := array{}; - foreach scope in (scopes.scopes) - var variables; - if (!(variables := request_succeeded(err, "variables", struct{ variablesReference := scope.variablesReference }))) - return err; + if ( variable.variablesReference ) + var inner_variables; + if ( !( inner_variables := request_succeeded( err, "variables", struct{ variablesReference := variable.variablesReference } + ) ) ) + return err; endif - - foreach variable in (variables.variables) - var evaluate; - if (!(evaluate := request_succeeded(err, "evaluate", struct{ expression := variable.name, frameId := scope.variablesReference }))) - return err; - endif - - if (variable.value != evaluate.result) - return ret_error($"Variables value does not match evaluate result: '{variable.value}' != '{evaluate.result}'"); - endif - - if (variable.variablesReference) - var inner_variables; - if (!(inner_variables := request_succeeded(err, "variables", struct{ variablesReference := variable.variablesReference }))) - return err; - endif - endif - endforeach + endif endforeach + endforeach - // Get script source - var source := ReadFile( "debuggee.src" ); - if (!source) - return ret_error(source); + // Get script source + var source := ReadFile( "debuggee.src" ); + if ( !source ) + return ret_error( source ); + endif + + var setting_breakpoints := array{}; + foreach line in source + if ( line.find( "/* set_bp */" ) ) + setting_breakpoints.append( struct{ line := _line_iter } ); endif + endforeach - var setting_breakpoints := array{}; - foreach line in source - if (line.find("/*set_bp*/")) - setting_breakpoints.append(struct{ line := _line_iter }); - endif - endforeach + // Send request: setBreakpoints + if ( !request_succeeded( err, "setBreakpoints", struct{ source := struct{ + path := stackTrace.stackFrames[1].source.path }, + breakpoints := setting_breakpoints } + ) ) + return err; + endif - // Send request: setBreakpoints - if (!request_succeeded(err, "setBreakpoints", struct{ source := struct{ path := stackTrace.stackFrames[1].source.path }, breakpoints := setting_breakpoints })) - return err; - endif + // Send request: continue + if ( !request_succeeded( err, "continue", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: continue - if (!request_succeeded(err, "continue", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].name != "func2" ) + return ret_error( $"Expected to be in `func2` after first continue: '{stackTrace.stackFrames[1].name}' != 'func2'" ); + endif - if (stackTrace.stackFrames[1].name != "func2") - return ret_error($"Expected to be in `func2` after first continue: '{stackTrace.stackFrames[1].name}' != 'func2'"); - endif + // Send request: stepIn + if ( !request_succeeded( err, "stepIn", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: stepIn - if (!request_succeeded(err, "stepIn", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].name != "func3" ) + return ret_error( $"Expected to be in `func3` after first stepIn: '{stackTrace.stackFrames[1].name}' != 'func3'" ); + endif - if (stackTrace.stackFrames[1].name != "func3") - return ret_error($"Expected to be in `func3` after first stepIn: '{stackTrace.stackFrames[1].name}' != 'func3'"); - endif + if ( stackTrace.stackFrames[2].name != "func2" ) + return ret_error( $"Expected previous frame to be in `func2` after first stepIn: '{stackTrace.stackFrames[2].name}' != 'func2'" ); + endif - if (stackTrace.stackFrames[2].name != "func2") - return ret_error($"Expected previous frame to be in `func2` after first stepIn: '{stackTrace.stackFrames[2].name}' != 'func2'"); - endif + // Send request: continue + if ( !request_succeeded( err, "continue", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: continue - if (!request_succeeded(err, "continue", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].name != "funcShadowed" ) + return ret_error( $"Expected to be in `funcShadowed` after second continue: '{stackTrace.stackFrames[1].name}' != 'funcShadowed'" ); + endif - if (stackTrace.stackFrames[1].name != "funcShadowed") - return ret_error($"Expected to be in `funcShadowed` after second continue: '{stackTrace.stackFrames[1].name}' != 'funcShadowed'"); - endif + var expectedNextLine := stackTrace.stackFrames[1].line + 1; - var expectedNextLine := stackTrace.stackFrames[1].line + 1; + // Send request: evaluate + var evaluate; + if ( !( evaluate := request_succeeded( err, "evaluate", struct{ expression := "shadowed_variable", + frameId := stackTrace.stackFrames[1].id } + ) ) ) + return err; + endif - // Send request: evaluate - var evaluate; - if (!(evaluate := request_succeeded(err, "evaluate", struct{ expression := "shadowed_variable", frameId := stackTrace.stackFrames[1].id }))) - return err; - endif + if ( evaluate.result != "\"funcShadowed:param1\"" ) + return ret_error( $"Expected value of `shadowed_variable` to be '\"funcShadowed:param1\"': '{evaluate.result}' != '\"funcShadowed:param1\"'" ); + endif - if (evaluate.result != "\"funcShadowed:param1\"") - return ret_error($"Expected value of `shadowed_variable` to be '\"funcShadowed:param1\"': '{evaluate.result}' != '\"funcShadowed:param1\"'"); - endif + // Send request: next + if ( !request_succeeded( err, "next", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: next - if (!request_succeeded(err, "next", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].line != expectedNextLine ) + return ret_error( $"Expected to be on line {expectedNextLine} after next: {stackTrace.stackFrames[1].line} != ${expectedNextLine}" ); + endif - if (stackTrace.stackFrames[1].line != expectedNextLine) - return ret_error($"Expected to be on line {expectedNextLine} after next: {stackTrace.stackFrames[1].line} != ${expectedNextLine}"); - endif + // Send request: continue + if ( !request_succeeded( err, "continue", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: continue - if (!request_succeeded(err, "continue", struct{ threadId := threadId })) - return err; - endif + // Send request: pause + if ( !request_succeeded( err, "pause", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: pause - if (!request_succeeded(err, "pause", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].name != "funcShadowed" ) + return ret_error( $"Expected to be in `funcShadowed` after third continue: '{stackTrace.stackFrames[1].name}' != 'funcShadowed'" ); + endif - if (stackTrace.stackFrames[1].name != "funcShadowed") - return ret_error($"Expected to be in `funcShadowed` after third continue: '{stackTrace.stackFrames[1].name}' != 'funcShadowed'"); - endif + // Send request: scopes + if ( !( scopes := request_succeeded( err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id } + ) ) ) + return err; + endif - // Send request: scopes - if (!(scopes := request_succeeded(err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id }))) - return err; - endif + // Send request: setVariable [local] + var setVariable; + if ( !( setVariable := request_succeeded( err, "setVariable", struct{ name := "was_paused", + value := "1", + variablesReference := scopes.scopes[1].variablesReference + } + ) ) ) + return err; + endif - // Send request: setVariable [local] - var setVariable; - if (!(setVariable := request_succeeded(err, "setVariable", struct{ name := "was_paused", value := "1", variablesReference := scopes.scopes[1].variablesReference }))) - return err; - endif + if ( setVariable.type != "number" || setVariable.value != "1" ) + return ret_error( $"Expected setVariable for `was_paused` to be type = number, value = '1': {setVariable.type} != 'number' || {setVariable.value} != '1'" ); + endif - if (setVariable.type != "number" || setVariable.value != "1") - return ret_error($"Expected setVariable for `was_paused` to be type = number, value = '1': {setVariable.type} != 'number' || {setVariable.value} != '1'"); - endif + // Send request: stepOut + if ( !request_succeeded( err, "stepOut", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: stepOut - if (!request_succeeded(err, "stepOut", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].name != "(program)" ) + return ret_error( $"Expected to be in `(program)` after stepOut: '{stackTrace.stackFrames[1].name}' != '(program)'" ); + endif - if (stackTrace.stackFrames[1].name != "(program)") - return ret_error($"Expected to be in `(program)` after stepOut: '{stackTrace.stackFrames[1].name}' != '(program)'"); - endif + // Send request: next + if ( !request_succeeded( err, "next", struct{ threadId := threadId } ) ) + return err; + endif - // Send request: next - if (!request_succeeded(err, "next", struct{ threadId := threadId })) - return err; - endif + // Wait for event: stopped + if ( !event_received( err, "stopped" ) ) + return err; + endif - // Wait for event: stopped - if (!event_received(err, "stopped")) - return err; - endif + // Send request: stackTrace + if ( !( stackTrace := request_succeeded( err, "stackTrace", struct{ threadId := threadId } ) ) ) + return err; + endif - // Send request: stackTrace - if (!(stackTrace := request_succeeded(err, "stackTrace", struct{ threadId := threadId }))) - return err; - endif + if ( stackTrace.stackFrames[1].name != "(program)" ) + return ret_error( $"Expected to be in `(program)` after stepOut: '{stackTrace.stackFrames[1].name}' != '(program)'" ); + endif - if (stackTrace.stackFrames[1].name != "(program)") - return ret_error($"Expected to be in `(program)` after stepOut: '{stackTrace.stackFrames[1].name}' != '(program)'"); - endif + // Send request: evaluate + if ( !( evaluate := request_succeeded( err, "evaluate", struct{ expression := "shadowed_result", + frameId := stackTrace.stackFrames[1].id } + ) ) ) + return err; + endif - // Send request: evaluate - if (!(evaluate := request_succeeded(err, "evaluate", struct{ expression := "shadowed_result", frameId := stackTrace.stackFrames[1].id }))) - return err; - endif + if ( evaluate.result != "1" ) + return ret_error( $"Expected value of `shadowed_result` to be '1': '{evaluate.result}' != '1'" ); + endif - if (evaluate.result != "1") - return ret_error($"Expected value of `shadowed_result` to be '1': '{evaluate.result}' != '1'"); - endif + // Send request: scopes + if ( !( scopes := request_succeeded( err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id } + ) ) ) + return err; + endif - // Send request: scopes - if (!(scopes := request_succeeded(err, "scopes", struct{ frameId := stackTrace.stackFrames[1].id }))) - return err; - endif + // Send request: setVariable [global] + if ( !( setVariable := request_succeeded( err, "setVariable", struct{ name := "global_float", + value := "1.5", + variablesReference := scopes.scopes[Len( + scopes.scopes )].variablesReference + } + ) ) ) + return err; + endif - // Send request: setVariable [global] - if (!(setVariable := request_succeeded(err, "setVariable", struct{ name := "global_float", value := "1.5", variablesReference := scopes.scopes[Len(scopes.scopes)].variablesReference }))) - return err; - endif + // Send request: evaluate + if ( !( evaluate := request_succeeded( err, "evaluate", struct{ expression := "global_float", + frameId := stackTrace.stackFrames[Len( + stackTrace.stackFrames )].id } + ) ) ) + return err; + endif - // Send request: evaluate - if (!(evaluate := request_succeeded(err, "evaluate", struct{ expression := "global_float", frameId := stackTrace.stackFrames[Len(stackTrace.stackFrames)].id }))) - return err; - endif + if ( evaluate.result != "1.5" ) + return ret_error( $"Expected value of `global_float` to be '1.5': '{evaluate.result}' != '1.5'" ); + endif - if (evaluate.result != "1.5") - return ret_error($"Expected value of `global_float` to be '1.5': '{evaluate.result}' != '1.5'"); - endif - - return 1; + return 1; endfunction // Test helper methods -function fill_buffers(timeout, request_seq := -1, event := "") - var ev; - var found := 0; - outer: - while (ev := wait_for_event(timeout)) - if (!ev && timeout > 0) - return error{ errortext := "Error filling buffer" }; +function fill_buffers( timeout, request_seq := -1, event := "" ) + var ev; + var found := 0; + outer: while ( ev := wait_for_event( timeout ) ) + if ( !ev && timeout > 0 ) + return error{ errortext := "Error filling buffer" }; + endif + recvBuffer += ev.value; + if ( recvBuffer.length() < CONTENT_LENGTH_HEADER_KEY_LENGTH ) + continue outer; + elseif ( recvBuffer[1, CONTENT_LENGTH_HEADER_KEY_LENGTH] != CONTENT_LENGTH_HEADER_KEY ) + return error{ errortext := "Invalid header in buffer" }; + else + var previousBufferLength := recvBuffer.length(); + while ( recvBuffer ) + var newlineIndex := recvBuffer.find( "\n", 3 ); + + if ( newlineIndex == 0 || recvBuffer == "" ) + continue outer; endif - recvBuffer += ev.value; - if (recvBuffer.length() < CONTENT_LENGTH_HEADER_KEY_LENGTH) - continue outer; - elseif (recvBuffer[1, CONTENT_LENGTH_HEADER_KEY_LENGTH] != CONTENT_LENGTH_HEADER_KEY) - return error{ errortext := "Invalid header in buffer" }; - else - var previousBufferLength := recvBuffer.length(); - while (recvBuffer) - var newlineIndex := recvBuffer.find("\n", 3); - if (newlineIndex == 0 || recvBuffer == "") - continue outer; - endif + var content_length := CInt( recvBuffer[CONTENT_LENGTH_HEADER_VALUE_START, newlineIndex] ); - var content_length := CInt(recvBuffer[CONTENT_LENGTH_HEADER_VALUE_START, newlineIndex]); + if ( content_length == 0 ) + continue outer; + endif - if (content_length == 0) - continue outer; - endif + var needed_length := newlineIndex + 2 + content_length; - var needed_length := newlineIndex + 2 + content_length; + if ( recvBuffer.length() >= needed_length ) + var msg := recvBuffer[newlineIndex + 3, content_length]; - if (recvBuffer.length() >= needed_length) - var msg := recvBuffer[newlineIndex + 3, content_length]; + var obj := UnpackJSON( msg ); - var obj := UnpackJSON(msg); + if ( obj.type == "response" ) + print( $"{C_MAGENTA_LIGHT}++ [response#{request_seq}] [{obj.command}]{C_RESET} {PackJSON( + obj.body )}" ); - if (obj.type == "response") - print($"{C_MAGENTA_LIGHT}++ [response#{request_seq}] [{obj.command}]{C_RESET} {PackJSON(obj.body)}"); - - dapResponses[obj.request_seq] := obj; - if (request_seq == obj.request_seq) - found := 1; - endif - elseif (obj.type == "event") - dapEvents.append(obj); - print($"{C_MAGENTA_LIGHT}++ [event] [{obj.event}]{C_RESET} {PackJSON(obj.body)}"); - - if (event != "" && event == obj.event) - found := 1; - endif - endif - - if (needed_length == recvBuffer.length()) - recvBuffer := ""; - else - recvBuffer := recvBuffer[needed_length + 1, recvBuffer.length()]; - endif - endif - if (previousBufferLength == recvBuffer.length()) - continue outer; - endif - previousBufferLength := recvBuffer.length(); - Sleepms(100); - endwhile - if (found) - return found; + dapResponses[obj.request_seq] := obj; + if ( request_seq == obj.request_seq ) + found := 1; endif - endif - endwhile + elseif ( obj.type == "event" ) + dapEvents.append( obj ); + print( $"{C_MAGENTA_LIGHT}++ [event] [{obj.event}]{C_RESET} {PackJSON( obj.body )}" ); - return found; -endfunction - -function fill_buffers_for_request(request_seq) - var filled := fill_buffers(0, request_seq := request_seq); - var found := dapResponses.exists(request_seq); - if (found) - return 1; - endif - - filled := fill_buffers(5, request_seq := request_seq); - if (filled == error) - return filled; - endif - - return dapResponses.exists(request_seq); -endfunction - -function fill_buffers_for_event(event, timeout) - var filled := fill_buffers(0, event := event); - - foreach ev in dapEvents - if (ev.event == event) - return 1; - endif - endforeach - - filled := fill_buffers(timeout, event := event); - - foreach ev in dapEvents - if (ev.event == event) - return 1; - endif - endforeach - - if (filled == error) - return filled; - endif - - return 0; -endfunction - -function event_wait(event, timeout := 10) - var found := fill_buffers_for_event(event, timeout); - - if (found) - foreach result in dapEvents - if (result.event == event) - dapEvents.erase(_result_iter); - return result.body; + if ( event != "" && event == obj.event ) + found := 1; endif - endforeach - endif + endif - return error{ errortext := $"No event for type {event}"}; -endfunction - -function request(command, arguments) - var request_seq := nextSequence; - - var body := struct{ - command := command, - arguments := arguments, - type := "request", - seq := nextSequence++ - }; - - var content := PackJSON(body); - print($"{C_GREEN}-> [request#{request_seq}] [{command}]{C_RESET} {PackJSON(arguments)}"); - - var request_text := "Content-Length: " + (content.length()) + CChr(13) + CChr(10) + CChr(13) + CChr(10) + content; - connection.transmit(request_text); - - var found := fill_buffers_for_request(request_seq); - - if (found) - var result := dapResponses[request_seq]; - dapResponses.erase(request_seq); - if (result.success) - return result.body; + if ( needed_length == recvBuffer.length() ) + recvBuffer := ""; + else + recvBuffer := recvBuffer[needed_length + 1, recvBuffer.length()]; + endif endif - print($"{C_RED}!! [response#{request_seq}]{C_RESET} failed: {result.message}"); - - return error{ errortext := $"Request {command}#{request_seq} failed: {result.message}" }; + if ( previousBufferLength == recvBuffer.length() ) + continue outer; + endif + previousBufferLength := recvBuffer.length(); + Sleepms( 100 ); + endwhile + if ( found ) + return found; + endif endif + endwhile - print($"{C_RED}[req seq#{request_seq}]{C_RESET} timed out: {found}"); - return error{ errortext := $"Request {command}#{request_seq} timed out: {found}"}; + return found; endfunction -function request_succeeded(byref err, command, arguments := struct{}) - err := 0; - var response := request(command, arguments); - if (response) - print($"{C_CYAN}<- [response] [{command}]{C_RESET}"); - return response; - endif - err := ret_error(response); - return 0; +function fill_buffers_for_request( request_seq ) + var filled := fill_buffers( 0, request_seq := request_seq ); + var found := dapResponses.exists( request_seq ); + if ( found ) + return 1; + endif + + filled := fill_buffers( 5, request_seq := request_seq ); + if ( filled == error ) + return filled; + endif + + return dapResponses.exists( request_seq ); endfunction -function event_received(byref err, event, timeout := 5) - err := 0; - var response := event_wait(event, timeout); - if (response) - print($"{C_CYAN}<- [event] [{event}]{C_RESET}"); - return response; +function fill_buffers_for_event( event, timeout ) + var filled := fill_buffers( 0, event := event ); + + foreach ev in dapEvents + if ( ev.event == event ) + return 1; endif - err := ret_error(response); - return 0; + endforeach + + filled := fill_buffers( timeout, event := event ); + + foreach ev in dapEvents + if ( ev.event == event ) + return 1; + endif + endforeach + + if ( filled == error ) + return filled; + endif + + return 0; +endfunction + +function event_wait( event, timeout := 10 ) + var found := fill_buffers_for_event( event, timeout ); + + if ( found ) + foreach result in dapEvents + if ( result.event == event ) + dapEvents.erase( _result_iter ); + return result.body; + endif + endforeach + endif + + return error{ errortext := $"No event for type {event}" }; +endfunction + +function request( command, arguments ) + var request_seq := nextSequence; + + var body := struct{ command := command, arguments := arguments, + type := "request", seq := nextSequence++ }; + + var content := PackJSON( body ); + print( $"{C_GREEN}-> [request#{request_seq}] [{command}]{C_RESET} {PackJSON( arguments )}" ); + + var request_text := "Content-Length: " + ( content.length() ) + CChr( 13 ) + CChr( 10 ) + CChr( 13 ) + + CChr( 10 ) + content; + connection.transmit( request_text ); + + var found := fill_buffers_for_request( request_seq ); + + if ( found ) + var result := dapResponses[request_seq]; + dapResponses.erase( request_seq ); + if ( result.success ) + return result.body; + endif + print( $"{C_RED}!! [response#{request_seq}]{C_RESET} failed: {result.message}" ); + + return error{ errortext := $"Request {command}#{request_seq} failed: {result.message}" }; + endif + + print( $"{C_RED}[req seq#{request_seq}]{C_RESET} timed out: {found}" ); + return error{ errortext := $"Request {command}#{request_seq} timed out: {found}" }; +endfunction + +function request_succeeded( byref err, command, arguments := struct{} ) + err := 0; + var response := request( command, arguments ); + if ( response ) + print( $"{C_CYAN}<- [response] [{command}]{C_RESET}" ); + return response; + endif + err := ret_error( response ); + return 0; +endfunction + +function event_received( byref err, event, timeout := 5 ) + err := 0; + var response := event_wait( event, timeout ); + if ( response ) + print( $"{C_CYAN}<- [event] [{event}]{C_RESET}" ); + return response; + endif + err := ret_error( response ); + return 0; endfunction diff --git a/testsuite/pol/testpkgs/debugger/test_debugger.src b/testsuite/pol/testpkgs/debugger/test_debugger.src index 401800151..19ca31726 100644 --- a/testsuite/pol/testpkgs/debugger/test_debugger.src +++ b/testsuite/pol/testpkgs/debugger/test_debugger.src @@ -5,56 +5,50 @@ use os; const TIMEOUT := 2 * 60; // 2 minutes program test_debugger() - return 1; + return 1; endprogram exported function test_debugger_attach() - var debuggee := start_script("debuggee", 1); - if (!debuggee) - return ret_error($"Could not start debuggee: {debuggee}"); - endif + var debuggee := start_script( "debuggee", 1 ); + if ( !debuggee ) + return ret_error( $"Could not start debuggee: {debuggee}" ); + endif - print($"Started debuggee {debuggee.pid}"); + print( $"Started debuggee {debuggee.pid}" ); - var params := struct{ - debuggee_pid := debuggee.pid, - test_type := "attach", - test_script_pid := GetPid() - }; + var params := struct{ debuggee_pid := debuggee.pid, test_type := "attach", + test_script_pid := GetPid() }; - var test_result := start_debugger_client(params); - debuggee.kill(); + var test_result := start_debugger_client( params ); + debuggee.kill(); - return test_result; + return test_result; endfunction - exported function test_debugger_launch() - var params := struct{ - test_type := "launch", - test_script_pid := GetPid() - }; + var params := struct{ test_type := "launch", test_script_pid := GetPid() }; - var test_result := start_debugger_client(params); + var test_result := start_debugger_client( params ); - return test_result; + return test_result; endfunction -function start_debugger_client(params) - var conn := OpenConnection( "127.0.0.1", 5002, "debugger_client", params := params, assume_string:=1, keep_connection:=1, ignore_line_breaks:=1 ); - if (!conn) - return ret_error($"Could not create debugger connection: {conn}"); - endif +function start_debugger_client( params ) + var conn := OpenConnection( "127.0.0.1", 5002, "debugger_client", params := params, + assume_string := 1, keep_connection := 1, ignore_line_breaks := 1 ); + if ( !conn ) + return ret_error( $"Could not create debugger connection: {conn}" ); + endif - var ev; - if (ev := os::wait_for_event(TIMEOUT)) - if (ev.result == 1) - GetProcess(conn.pid).kill(); - return 1; - endif - GetProcess(conn.pid).kill(); - return ev.result; + var ev; + if ( ev := os::wait_for_event( TIMEOUT ) ) + if ( ev.result == 1 ) + GetProcess( conn.pid ).kill(); + return 1; endif - GetProcess(conn.pid).kill(); - return ret_error($"Test timed out after {TIMEOUT} seconds"); + GetProcess( conn.pid ).kill(); + return ev.result; + endif + GetProcess( conn.pid ).kill(); + return ret_error( $"Test timed out after {TIMEOUT} seconds" ); endfunction diff --git a/testsuite/pol/testpkgs/funcref/external.src b/testsuite/pol/testpkgs/funcref/external.src index a992e8d3e..574a6e19b 100644 --- a/testsuite/pol/testpkgs/funcref/external.src +++ b/testsuite/pol/testpkgs/funcref/external.src @@ -3,7 +3,7 @@ var ext_glob1 := "xg1"; var ext_glob2 := "xg2"; program external( foo ) - var res := foo(); + var res := foo(); - return $"called foo(), res={res}"; + return $"called foo(), res={res}"; endprogram diff --git a/testsuite/pol/testpkgs/funcref/test_call.src b/testsuite/pol/testpkgs/funcref/test_call.src index 3164fb20b..ada21a30f 100644 --- a/testsuite/pol/testpkgs/funcref/test_call.src +++ b/testsuite/pol/testpkgs/funcref/test_call.src @@ -78,12 +78,11 @@ exported function test_call_destroyed_executor() return ret_error( $"Spawned process not destroyed in time" ); dowhile ( 0 ); - spawned.SendEvent( struct{ - type := "call", - pid := GetPid(), - args := { 1, 2, 3 }, - mapper := @(what) { return what * 100; } - } ); + spawned.SendEvent( struct{ type := "call", + pid := GetPid(), args := { 1, 2, 3 }, + mapper := @( what ) { + return what * 100; + } } ); ev := wait_for_event( 1 ); @@ -113,7 +112,9 @@ function user_func_no_globals() endfunction function embedded_globals() - return @{ return @{ glob := "glob set inside embedded_globals"; + return @{ + return @{ + glob := "glob set inside embedded_globals"; return "return from embedded_globals"; }(); }(); diff --git a/testsuite/pol/testpkgs/house/cleanup.src b/testsuite/pol/testpkgs/house/cleanup.src index efebee44e..860a93a84 100644 --- a/testsuite/pol/testpkgs/house/cleanup.src +++ b/testsuite/pol/testpkgs/house/cleanup.src @@ -1,5 +1,5 @@ use uo; -foreach multi in (ListMultisInBox(0,0,-200,10000,10000,200)) - DestroyMulti(multi); +foreach multi in ( ListMultisInBox( 0, 0, -200, 10000, 10000, 200 ) ) + DestroyMulti( multi ); endforeach diff --git a/testsuite/pol/testpkgs/house/test_house.src b/testsuite/pol/testpkgs/house/test_house.src index 449693ce9..4fcf692c9 100644 --- a/testsuite/pol/testpkgs/house/test_house.src +++ b/testsuite/pol/testpkgs/house/test_house.src @@ -6,71 +6,71 @@ include "testutil"; var multi; program test_house() - multi:=CreateMultiAtLocation(50,50,0,0x12000); - if (!multi) - return ret_error("Failed to create multi "+multi); + multi := CreateMultiAtLocation( 50, 50, 0, 0x12000 ); + if ( !multi ) + return ret_error( "Failed to create multi " + multi ); endif - if (multi.x != 50 || multi.y != 50 || multi.z != 0 || multi.multiid != 0x6b) - var er:="Wrong pos or multiid: {},{},{} {}".format(multi.x, multi.y, multi.z, multi.multiid); - return ret_error(er); + if ( multi.x != 50 || multi.y != 50 || multi.z != 0 || multi.multiid != 0x6b ) + var er := "Wrong pos or multiid: {},{},{} {}".format( multi.x, multi.y, multi.z, multi.multiid ); + return ret_error( er ); endif return 1; endprogram exported function components() - if (multi.components.size()!=2) - return ret_error("Components count does not match: "+multi.components.size()); + if ( multi.components.size() != 2 ) + return ret_error( "Components count does not match: " + multi.components.size() ); endif - foreach comp in (multi.components) - if (comp.graphic == 0x6a5) - if (comp.x!=50 || comp.y!=53 || comp.z!=7) - return ret_error("Wrong door pos:{},{},{}".format(comp.x,comp.y,comp.z)); + foreach comp in ( multi.components ) + if ( comp.graphic == 0x6a5 ) + if ( comp.x != 50 || comp.y != 53 || comp.z != 7 ) + return ret_error( "Wrong door pos:{},{},{}".format( comp.x, comp.y, comp.z ) ); endif - elseif (comp.graphic == 0xbd2) - if (comp.x!=52 || comp.y!=54 || comp.z!=5) - return ret_error("Wrong sign pos:{},{},{}".format(comp.x,comp.y,comp.z)); + elseif ( comp.graphic == 0xbd2 ) + if ( comp.x != 52 || comp.y != 54 || comp.z != 5 ) + return ret_error( "Wrong sign pos:{},{},{}".format( comp.x, comp.y, comp.z ) ); endif else - return ret_error("Invalid component: "+hex(comp.graphic)); - endif + return ret_error( "Invalid component: " + hex( comp.graphic ) ); + endif endforeach return 1; endfunction exported function footprint() - var fp:=multi.footprint; - if (fp.xmin != 47 || fp.ymin != 47 || fp.xmax != 54 || fp.ymax != 54) - return ret_error("Invalid foodprint: "+fp); + var fp := multi.footprint; + if ( fp.xmin != 47 || fp.ymin != 47 || fp.xmax != 54 || fp.ymax != 54 ) + return ret_error( "Invalid foodprint: " + fp ); endif return 1; endfunction exported function move_item() - var item:=CreateItemAtLocation(0,0,0, 0x3e3f); - item.movable:=1; - if (item.multi) - return ret_error("Item is already inside of a multi "+item.multi); + var item := CreateItemAtLocation( 0, 0, 0, 0x3e3f ); + item.movable := 1; + if ( item.multi ) + return ret_error( "Item is already inside of a multi " + item.multi ); endif - var res:=MoveObjectToLocation(item,multi.x,multi.y,5); - if (!res) - return ret_error("failed to move to multi: "+res); + var res := MoveObjectToLocation( item, multi.x, multi.y, 5 ); + if ( !res ) + return ret_error( "failed to move to multi: " + res ); endif - if (item.z != 7) - return ret_error("Wrong standing height: "+item.z); + if ( item.z != 7 ) + return ret_error( "Wrong standing height: " + item.z ); endif - if (item.multi.serial != multi.serial) - return ret_error("Item not part of multi: "+item.multi); + if ( item.multi.serial != multi.serial ) + return ret_error( "Item not part of multi: " + item.multi ); endif - if (item.serial == multi.items[0].serial) - return ret_error("Item not part of multi: "+multi.items); + if ( item.serial == multi.items[0].serial ) + return ret_error( "Item not part of multi: " + multi.items ); endif - res:=MoveObjectToLocation(item,0,0,0,flags:=MOVEOBJECT_FORCELOCATION); - if (!res) - return ret_error("failed to move back to world: "+res); + res := MoveObjectToLocation( item, 0, 0, 0, flags := MOVEOBJECT_FORCELOCATION ); + if ( !res ) + return ret_error( "failed to move back to world: " + res ); endif - if (item.multi) - return ret_error("Item still part of multi: "+item.multi); + if ( item.multi ) + return ret_error( "Item still part of multi: " + item.multi ); endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction diff --git a/testsuite/pol/testpkgs/house/test_house_set_multiid.src b/testsuite/pol/testpkgs/house/test_house_set_multiid.src index 1f8765d7c..ecf74e049 100644 --- a/testsuite/pol/testpkgs/house/test_house_set_multiid.src +++ b/testsuite/pol/testpkgs/house/test_house_set_multiid.src @@ -10,30 +10,32 @@ endprogram // Helper function used in multiple tests. Creates an NPC at `x` , `y`. If `multi` is passed, also // checks that `npc.multi == multi` and a walkon event was triggered. -function create_npc(x, y, multi) - var npc := new_npc_resource( ":testnpc:probe_npc", x, y, 0, override_properties := struct{ CProps := dictionary{ "#TestPid" -> GetPid() } } ); +function create_npc( x, y, multi ) + var npc := new_npc_resource( ":testnpc:probe_npc", x, y, 0, override_properties := struct{ CProps := dictionary{ "#TestPid" -> GetPid() + } + } ); if ( !npc ) return npc; - elseif (multi) - if (npc.multi != multi) - return ret_error($"Incorrect npc.multi, expected {multi.serial}, got {npc.multi.serial ?: npc.multi}"); + elseif ( multi ) + if ( npc.multi != multi ) + return ret_error( $"Incorrect npc.multi, expected {multi.serial}, got {npc.multi.serial ?: npc.multi}" ); endif - Sleepms(1); - var ev := wait_for_event(0); - if (!ev) - return ret_error( $"No walkon event received for {npc.serial}"); + Sleepms( 1 ); + var ev := wait_for_event( 0 ); + if ( !ev ) + return ret_error( $"No walkon event received for {npc.serial}" ); - elseif (ev.who != npc) - return ret_error($"Incorrect walkon ev.who, expected {npc.serial}, got {ev.who.serial ?: ev.who}"); + elseif ( ev.who != npc ) + return ret_error( $"Incorrect walkon ev.who, expected {npc.serial}, got {ev.who.serial ?: ev.who}" ); - elseif (ev.tile.serial != multi.serial) // Must check serial since tile = ItemRef and is multi = MultiRef - return ret_error($"Incorrect walkon ev.tile, expected {multi.serial}, got {ev.tile.serial ?: ev.tile}"); + elseif ( ev.tile.serial != multi.serial ) // Must check serial since tile = ItemRef and is multi = MultiRef + return ret_error( $"Incorrect walkon ev.tile, expected {multi.serial}, got {ev.tile.serial ?: ev.tile}" ); endif else - if (npc.multi) + if ( npc.multi ) clear_event_queue(); - return ret_error("Incorrect npc.multi, expected no multi, got {npc.multi.serial}"); + return ret_error( "Incorrect npc.multi, expected no multi, got {npc.multi.serial}" ); endif endif @@ -42,52 +44,52 @@ endfunction exported function keep_components() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "SmallHouse"), @(multi) { - if (multi.multiid != 0x6b) - return ret_error($"Incorrect initial multiid, expected 0x6b, actual 0x{multi.multiid:x}"); + return add_resource( new_multi_resource( 100, 75, 0, "SmallHouse" ), @( multi ) { + if ( multi.multiid != 0x6b ) + return ret_error( $"Incorrect initial multiid, expected 0x6b, actual 0x{multi.multiid:x}" ); endif var initial_components := multi.components; - var res := multi.set_multiid(0x6c, CRMULTI_KEEP_COMPONENTS); - if (!res) - return ret_error($"multi.set_multiid failed: {res}"); + var res := multi.set_multiid( 0x6c, CRMULTI_KEEP_COMPONENTS ); + if ( !res ) + return ret_error( $"multi.set_multiid failed: {res}" ); endif - if (multi.multiid != 0x6c) - return ret_error($"Incorrect new multiid, expected 0x6c, actual 0x{multi.multiid:x} "); + if ( multi.multiid != 0x6c ) + return ret_error( $"Incorrect new multiid, expected 0x6c, actual 0x{multi.multiid:x} " ); endif - if (multi.components != initial_components) - return ret_error($"Components changed"); + if ( multi.components != initial_components ) + return ret_error( $"Components changed" ); endif return 1; - }); - }); + } ); + } ); endfunction exported function recreate_components() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "SmallHouse"), @(multi) { - if (multi.multiid != 0x6b) - return ret_error($"Incorrect initial multiid, expected 0x6b, actual 0x{multi.multiid:x}"); + return add_resource( new_multi_resource( 100, 75, 0, "SmallHouse" ), @( multi ) { + if ( multi.multiid != 0x6b ) + return ret_error( $"Incorrect initial multiid, expected 0x6b, actual 0x{multi.multiid:x}" ); endif var initial_components := multi.components; - var res := multi.set_multiid(0x6c, CRMULTI_KEEP_COMPONENTS); - if (!res) - return ret_error($"multi.set_multiid failed: {res}"); + var res := multi.set_multiid( 0x6c, CRMULTI_KEEP_COMPONENTS ); + if ( !res ) + return ret_error( $"multi.set_multiid failed: {res}" ); endif - if (multi.components != initial_components) - return ret_error("Components changed"); + if ( multi.components != initial_components ) + return ret_error( "Components changed" ); endif return 1; - }); - }); + } ); + } ); endfunction /* @@ -117,119 +119,106 @@ and spawns NPCs and items in the in locations highlighted: // Success, there are no NPCs so everything can change. exported function change_no_npcs() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return multi.set_multiid(0x13eb, CRMULTI_KEEP_COMPONENTS); // dirt-hole-se - }); - }); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return multi.set_multiid( 0x13eb, CRMULTI_KEEP_COMPONENTS ); // dirt-hole-se + } ); + } ); endfunction - // Failure, no itemdesc for "does-not-exist" exported function change_bad_multiid_string() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return ret_error_not_equal( - multi.set_multiid( "does-not-exist", CRMULTI_KEEP_COMPONENTS), - error, - "Expected error when setting bad string multiid" - ); - }); - }); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return ret_error_not_equal( multi.set_multiid( "does-not-exist", CRMULTI_KEEP_COMPONENTS ), + error, "Expected error when setting bad string multiid" ); + } ); + } ); endfunction // Failure, no descriptor for 15243 exported function change_bad_multiid_long() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return ret_error_not_equal( - multi.set_multiid( 15243, CRMULTI_KEEP_COMPONENTS), - error, - "Expected error when setting bad long multiid" - ); - }); - }); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return ret_error_not_equal( multi.set_multiid( 15243, CRMULTI_KEEP_COMPONENTS ), error, + "Expected error when setting bad long multiid" ); + } ); + } ); endfunction // Success, npcSE is in the 'hole' of the target multidef. Should not get a walkon event. exported function change_npc_in_target_hole() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return add_resource( create_npc(101, 76, multi), @(npcSE) { - return invoke_if( multi.set_multiid( "dirt-hole-se", CRMULTI_KEEP_COMPONENTS), @{ - Sleepms(1); - var ev := wait_for_event(0); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return add_resource( create_npc( 101, 76, multi ), @( npcSE ) { + return invoke_if( multi.set_multiid( "dirt-hole-se", CRMULTI_KEEP_COMPONENTS ), @{ + Sleepms( 1 ); + var ev := wait_for_event( 0 ); if ( ev ) - return ret_error($"Erroneously received event (walkon?): {ev} "); + return ret_error( $"Erroneously received event (walkon?): {ev} " ); endif return 1; - }); - }); - }); - }); + } ); + } ); + } ); + } ); endfunction // Success, npcNE is on a valid location in both old and target multidef. exported function change_npc_in_both_valid() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return add_resource( create_npc(99, 76, multi), @(npcNE) { - return invoke_if( multi.set_multiid(0x13eb, CRMULTI_KEEP_COMPONENTS), @{ // dirt-hole-se - Sleepms(1); - var ev := wait_for_event(0); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return add_resource( create_npc( 99, 76, multi ), @( npcNE ) { + return invoke_if( multi.set_multiid( 0x13eb, CRMULTI_KEEP_COMPONENTS ), @{ // dirt-hole-se + Sleepms( 1 ); + var ev := wait_for_event( 0 ); if ( ev ) - return ret_error($"Erroneously received event (walkon?): {ev} "); + return ret_error( $"Erroneously received event (walkon?): {ev} " ); endif return 1; - }); - }); - }); - }); + } ); + } ); + } ); + } ); endfunction // Failure, npcNW is on a location not in old multidef but in target multidef. exported function change_npc_notin_target_hole() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return add_resource( create_npc(99, 74, uninit), @(npcNW) { - return ret_error_not_equal( - multi.set_multiid(0x13eb, CRMULTI_KEEP_COMPONENTS), - error, - "Expected set_multiid error" - ); - }); - }); - }); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return add_resource( create_npc( 99, 74, uninit ), @( npcNW ) { + return ret_error_not_equal( multi.set_multiid( 0x13eb, CRMULTI_KEEP_COMPONENTS ), + error, "Expected set_multiid error" ); + } ); + } ); + } ); endfunction // Failure, item is on a location not in old multidef but in target multidef. exported function change_item_notin_target_hole() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return add_resource( new_item_resource(99, 74, 0, "goldcoin" ), @(itemNW) { - return ret_error_not_equal( - multi.set_multiid(0x13eb, CRMULTI_KEEP_COMPONENTS), - error, - "Expected set_multiid error" - ); - }); - }); - }); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return add_resource( new_item_resource( 99, 74, 0, "goldcoin" ), @( itemNW ) { + return ret_error_not_equal( multi.set_multiid( 0x13eb, CRMULTI_KEEP_COMPONENTS ), + error, "Expected set_multiid error" ); + } ); + } ); + } ); endfunction // Success, npcNW is on a location not in old multidef but in target multidef but using CRMULTI_IGNORE_ALL. exported function npc_notin_target_hole_ignore() return with_resources( @{ - return add_resource( new_multi_resource(100,75,0, "dirt-hole-nw"), @(multi) { - return add_resource( create_npc(99, 74, uninit), @(npcNW) { - return invoke_if( multi.set_multiid(0x13eb, CRMULTI_IGNORE_ALL | CRMULTI_KEEP_COMPONENTS), @{ - Sleepms(1); - var ev := wait_for_event(0); + return add_resource( new_multi_resource( 100, 75, 0, "dirt-hole-nw" ), @( multi ) { + return add_resource( create_npc( 99, 74, uninit ), @( npcNW ) { + return invoke_if( multi.set_multiid( 0x13eb, CRMULTI_IGNORE_ALL | CRMULTI_KEEP_COMPONENTS ), @{ + Sleepms( 1 ); + var ev := wait_for_event( 0 ); if ( !ev ) - return ret_error($"Did not receive walkon event: {ev} "); + return ret_error( $"Did not receive walkon event: {ev} " ); endif return 1; - }); - }); - }); - }); + } ); + } ); + } ); + } ); endfunction diff --git a/testsuite/pol/testpkgs/house/test_houserange.src b/testsuite/pol/testpkgs/house/test_houserange.src index 4f014d84e..248bfe5c7 100644 --- a/testsuite/pol/testpkgs/house/test_houserange.src +++ b/testsuite/pol/testpkgs/house/test_houserange.src @@ -6,40 +6,40 @@ include "testutil"; var multi; program test_houserange() - multi:=CreateMultiAtLocation(100,100,0,0x12001); - if (!multi) - return ret_error("Failed to create multi "+multi); + multi := CreateMultiAtLocation( 100, 100, 0, 0x12001 ); + if ( !multi ) + return ret_error( "Failed to create multi " + multi ); endif - if (multi.x != 100 || multi.y != 100 || multi.z != 0 || multi.multiid != 0x6c) - var er:="Wrong pos or multiid: {},{},{} {}".format(multi.x, multi.y, multi.z, multi.multiid); - return ret_error(er); + if ( multi.x != 100 || multi.y != 100 || multi.z != 0 || multi.multiid != 0x6c ) + var er := "Wrong pos or multiid: {},{},{} {}".format( multi.x, multi.y, multi.z, multi.multiid ); + return ret_error( er ); endif return 1; endprogram exported function footprint() - var fp:=multi.footprint; - if (fp.xmin != 70 || fp.ymin != 100 || fp.xmax != 129 || fp.ymax != 100) - return ret_error("Invalid foodprint: "+fp); + var fp := multi.footprint; + if ( fp.xmin != 70 || fp.ymin != 100 || fp.xmax != 129 || fp.ymax != 100 ) + return ret_error( "Invalid foodprint: " + fp ); endif return 1; endfunction exported function multisinbox() // only one tile inside the box - var multis:=ListMultisInBox(60,100,0,70,100,0); - if (!multis) - return ret_error("No multi found"); + var multis := ListMultisInBox( 60, 100, 0, 70, 100, 0 ); + if ( !multis ) + return ret_error( "No multi found" ); endif - if (!(multi in multis)) - return ret_error("Wrong multi found: "+multis); + if ( !( multi in multis ) ) + return ret_error( "Wrong multi found: " + multis ); endif return 1; endfunction exported function update_range() - if (PolCore().update_range != 49) // multi 6c 30+1+18 - return ret_error("wrong update range: "+PolCore().update_range); + if ( PolCore().update_range != 49 ) // multi 6c 30+1+18 + return ret_error( "wrong update range: " + PolCore().update_range ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/house/walkon.src b/testsuite/pol/testpkgs/house/walkon.src index 96c03940e..ab4f47b23 100644 --- a/testsuite/pol/testpkgs/house/walkon.src +++ b/testsuite/pol/testpkgs/house/walkon.src @@ -2,9 +2,6 @@ use os; use uo; program walk_on_bantile( who, tile ) - GetProcess( GetObjProperty( who, "#TestPid" ) ).SendEvent( struct{ - type := "walkon", - who := who, - tile := tile - }); + GetProcess( GetObjProperty( who, "#TestPid" ) ).SendEvent( struct{ type := "walkon", + who := who, tile := tile } ); endprogram diff --git a/testsuite/pol/testpkgs/item/container_events/caninsert.src b/testsuite/pol/testpkgs/item/container_events/caninsert.src index 270b18d9d..da768832c 100644 --- a/testsuite/pol/testpkgs/item/container_events/caninsert.src +++ b/testsuite/pol/testpkgs/item/container_events/caninsert.src @@ -1,9 +1,15 @@ use uo; use os; -program caninsertscript( character, container, movetype, inserttype, adding_item, existing_stack, amount_to_add ) - GetProcess( GetObjProperty(container, "#TestPid") ).sendevent( struct{ - type := "container_caninsert", - args := { character, container, movetype, inserttype, adding_item, existing_stack, amount_to_add } - } ); +program caninsertscript( character, container, movetype, inserttype, adding_item, existing_stack, + amount_to_add ) + GetProcess( GetObjProperty( container, "#TestPid" ) ).sendevent( struct{ type := "container_caninsert", + args := { character, + container, + movetype, + inserttype, + adding_item, + existing_stack, + amount_to_add } + } ); endprogram diff --git a/testsuite/pol/testpkgs/item/container_events/canremove.src b/testsuite/pol/testpkgs/item/container_events/canremove.src index bbc5bedde..f18f6ed81 100644 --- a/testsuite/pol/testpkgs/item/container_events/canremove.src +++ b/testsuite/pol/testpkgs/item/container_events/canremove.src @@ -2,15 +2,18 @@ use uo; use os; program canremovescript( character, container, item, movetype, item_amount ) - GetProcess( GetObjProperty(container, "#TestPid") ).sendevent( struct{ - type := "container_canremove", - args := { character, container, item, movetype, item_amount } - } ); + GetProcess( GetObjProperty( container, "#TestPid" ) ).sendevent( struct{ type := "container_canremove", + args := { character, + container, + item, + movetype, + item_amount } + } ); - // do not allow removing an odd amount of items - if (movetype == MOVETYPE_PLAYER) - return item_amount & 1 == 0; - endif + // do not allow removing an odd amount of items + if ( movetype == MOVETYPE_PLAYER ) + return item_amount & 1 == 0; + endif - return 1; + return 1; endprogram diff --git a/testsuite/pol/testpkgs/item/container_events/oninsert.src b/testsuite/pol/testpkgs/item/container_events/oninsert.src index 7178f8761..b0a1ac5cc 100644 --- a/testsuite/pol/testpkgs/item/container_events/oninsert.src +++ b/testsuite/pol/testpkgs/item/container_events/oninsert.src @@ -1,9 +1,15 @@ use uo; use os; -program oninsertscript( character, container, movetype, inserttype, adding_item, existing_stack, amount_to_add ) - GetProcess( GetObjProperty( container, "#TestPid") ).sendevent( struct{ - type := "container_oninsert", - args := { character, container, movetype, inserttype, adding_item, existing_stack, amount_to_add } - } ); +program oninsertscript( character, container, movetype, inserttype, adding_item, existing_stack, + amount_to_add ) + GetProcess( GetObjProperty( container, "#TestPid" ) ).sendevent( struct{ type := "container_oninsert", + args := { character, + container, + movetype, + inserttype, + adding_item, + existing_stack, + amount_to_add } + } ); endprogram diff --git a/testsuite/pol/testpkgs/item/container_events/onremove.src b/testsuite/pol/testpkgs/item/container_events/onremove.src index 961433d23..6bb0e42a6 100644 --- a/testsuite/pol/testpkgs/item/container_events/onremove.src +++ b/testsuite/pol/testpkgs/item/container_events/onremove.src @@ -2,8 +2,12 @@ use uo; use os; program onremovescript( character, container, item, item_amount, movetype, split_from ) - GetProcess( GetObjProperty( container, "#TestPid") ).sendevent( struct{ - type := "container_onremove", - args := { character, container, item, item_amount, movetype, split_from } - } ); + GetProcess( GetObjProperty( container, "#TestPid" ) ).sendevent( struct{ type := "container_onremove", + args := { character, + container, + item, + item_amount, + movetype, + split_from } + } ); endprogram diff --git a/testsuite/pol/testpkgs/item/control_destroy.src b/testsuite/pol/testpkgs/item/control_destroy.src index 9e8275892..7daa91482 100644 --- a/testsuite/pol/testpkgs/item/control_destroy.src +++ b/testsuite/pol/testpkgs/item/control_destroy.src @@ -1,9 +1,9 @@ use uo; use os; -program control_destroy(item) - sleepms(10); - DestroyItem(item); - item:=0; // clear reference - Polcore().internal(7); //destroy all orphan objects +program control_destroy( item ) + sleepms( 10 ); + DestroyItem( item ); + item := 0; // clear reference + Polcore().internal( 7 ); // destroy all orphan objects endprogram diff --git a/testsuite/pol/testpkgs/item/control_echo.src b/testsuite/pol/testpkgs/item/control_echo.src index 35504484f..c0417a6d7 100644 --- a/testsuite/pol/testpkgs/item/control_echo.src +++ b/testsuite/pol/testpkgs/item/control_echo.src @@ -3,16 +3,16 @@ use uo; const SYSEVENT_SPEECH := 0x00000001; -program main(item) +program main( item ) RegisterForSpeechEvents( item, 12 ); - while (1) - var ev := os::wait_for_event(30); - case(ev.type) + while ( 1 ) + var ev := os::wait_for_event( 30 ); + case ( ev.type ) SYSEVENT_SPEECH: var tokens := ev.tokens; tokens.sort(); // This needs to match what's tested in test_client's say_something_with_tokens - PrintTextAbove(item, $"source=[item] text=[{ev.text}] tokens=[{tokens}]"); + PrintTextAbove( item, $"source=[item] text=[{ev.text}] tokens=[{tokens}]" ); endcase endwhile endprogram diff --git a/testsuite/pol/testpkgs/item/control_restartable.src b/testsuite/pol/testpkgs/item/control_restartable.src index c42d77a34..4085ca9ca 100644 --- a/testsuite/pol/testpkgs/item/control_restartable.src +++ b/testsuite/pol/testpkgs/item/control_restartable.src @@ -1,15 +1,15 @@ use os; use uo; -program main(item) - var test_pid := GetObjProperty(item, "#TestPid"); +program main( item ) + var test_pid := GetObjProperty( item, "#TestPid" ); - if (test_pid) - GetProcess(test_pid).sendevent( struct{ control_script_pid := GetPid() }); - endif + if ( test_pid ) + GetProcess( test_pid ).sendevent( struct{ control_script_pid := GetPid() } ); + endif - while (item) - // Use a long period to ensure the executor properly terminates. - Sleep(100); - endwhile + while ( item ) + // Use a long period to ensure the executor properly terminates. + Sleep( 100 ); + endwhile endprogram diff --git a/testsuite/pol/testpkgs/item/method.src b/testsuite/pol/testpkgs/item/method.src index c1154005d..0a6f7dc8b 100644 --- a/testsuite/pol/testpkgs/item/method.src +++ b/testsuite/pol/testpkgs/item/method.src @@ -2,18 +2,17 @@ program MethodTest() return 1; endprogram -exported function Outer(item) +exported function Outer( item ) item.InnerCrash(); endfunction -exported function InnerCrash(item) +exported function InnerCrash( item ) var foo := "bar"; endfunction -exported function Outer2(item) - var i:=1; +exported function Outer2( item ) + var i := 1; item.InnerCrash(); ++i; return i; endfunction - diff --git a/testsuite/pol/testpkgs/item/test_item.src b/testsuite/pol/testpkgs/item/test_item.src index 011715b99..f5a0c16d0 100644 --- a/testsuite/pol/testpkgs/item/test_item.src +++ b/testsuite/pol/testpkgs/item/test_item.src @@ -10,101 +10,101 @@ endprogram exported function test_item_realm_move() // crashed by wrongly converting coordinates between realms - var item:=CreateItemAtLocation(0,0,0,0xf3f); - if (!item) - return ret_error("Failed to create item "+item); + var item := CreateItemAtLocation( 0, 0, 0, 0xf3f ); + if ( !item ) + return ret_error( "Failed to create item " + item ); endif - MoveObjectToLocation(item,1000,1000,0,"britannia2",MOVEOBJECT_FORCELOCATION); - if (item.x != 1000 || item.y != 1000 || item.realm != "britannia2") - var res:=$"Failed initial move: {item.x},{item.y},{item.realm}"; - DestroyItem(item); - return ret_error(res); + MoveObjectToLocation( item, 1000, 1000, 0, "britannia2", MOVEOBJECT_FORCELOCATION ); + if ( item.x != 1000 || item.y != 1000 || item.realm != "britannia2" ) + var res := $"Failed initial move: {item.x},{item.y},{item.realm}"; + DestroyItem( item ); + return ret_error( res ); endif - MoveObjectToLocation(item,10,10,0,"britannia",MOVEOBJECT_FORCELOCATION); - if (item.x != 10 || item.y != 10 || item.realm != "britannia") - var res:=$"Failed to move: {item.x},{item.y},{item.realm}"; - DestroyItem(item); - return ret_error(res); + MoveObjectToLocation( item, 10, 10, 0, "britannia", MOVEOBJECT_FORCELOCATION ); + if ( item.x != 10 || item.y != 10 || item.realm != "britannia" ) + var res := $"Failed to move: {item.x},{item.y},{item.realm}"; + DestroyItem( item ); + return ret_error( res ); endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction exported function test_item_cursed() - var cnt:=CreateItemAtLocation(0,0,0,0x200001); - if (!cnt) - return ret_error("Failed to create container "+cnt); + var cnt := CreateItemAtLocation( 0, 0, 0, 0x200001 ); + if ( !cnt ) + return ret_error( "Failed to create container " + cnt ); endif // Create one stack of gold - var gold1 := CreateItemInContainer(cnt, "goldcoin", 1000); - if (!gold1) - return ret_error($"Failed to create goldcoin {gold1}"); + var gold1 := CreateItemInContainer( cnt, "goldcoin", 1000 ); + if ( !gold1 ) + return ret_error( $"Failed to create goldcoin {gold1}" ); endif // Create another stack of gold, will be stacked onto existing item `gold1` - var gold2 := CreateItemInContainer(cnt, "goldcoin", 2000); - if (!gold2) - return ret_error($"Failed to create goldcoin {gold2}"); - elseif (EnumerateItemsInContainer(cnt).size() != 1) - return ret_error("Expected one item -- gold -- in container"); - elseif (gold1 != gold2) - return ret_error("Expected second created gold to stack with first"); + var gold2 := CreateItemInContainer( cnt, "goldcoin", 2000 ); + if ( !gold2 ) + return ret_error( $"Failed to create goldcoin {gold2}" ); + elseif ( EnumerateItemsInContainer( cnt ).size() != 1 ) + return ret_error( "Expected one item -- gold -- in container" ); + elseif ( gold1 != gold2 ) + return ret_error( "Expected second created gold to stack with first" ); endif // Create one stack of cursed gold - var cursedgold1 := CreateItemInContainer(cnt, "cursedgoldcoin", 3000); - if (!cursedgold1) - return ret_error($"Failed to create cursedgoldcoin {cursedgold1}"); + var cursedgold1 := CreateItemInContainer( cnt, "cursedgoldcoin", 3000 ); + if ( !cursedgold1 ) + return ret_error( $"Failed to create cursedgoldcoin {cursedgold1}" ); endif // Create another stack of cursed gold, will be stacked onto existing item `cursedgold1` - var cursedgold2 := CreateItemInContainer(cnt, "cursedgoldcoin", 4000); - if (!cursedgold2) - return ret_error($"Failed to create cursedgoldcoin {cursedgold2}"); - elseif (cursedgold1 != cursedgold2) - return ret_error("Expected second created cursedgold to stack with first"); - elseif (cursedgold1.cursed == 0) - return ret_error("Expected created cursedgold to have cursed == 1"); - elseif (EnumerateItemsInContainer(cnt).size() != 2) - return ret_error("Expected two items -- gold and cursedgold -- in container"); + var cursedgold2 := CreateItemInContainer( cnt, "cursedgoldcoin", 4000 ); + if ( !cursedgold2 ) + return ret_error( $"Failed to create cursedgoldcoin {cursedgold2}" ); + elseif ( cursedgold1 != cursedgold2 ) + return ret_error( "Expected second created cursedgold to stack with first" ); + elseif ( cursedgold1.cursed == 0 ) + return ret_error( "Expected created cursedgold to have cursed == 1" ); + elseif ( EnumerateItemsInContainer( cnt ).size() != 2 ) + return ret_error( "Expected two items -- gold and cursedgold -- in container" ); endif - DestroyItem(cnt); + DestroyItem( cnt ); return 1; endfunction exported function test_item_method_crash() - var item:=CreateItemAtLocation(0,0,0,0x300001); - if (!item) - return ret_error("Failed to create item "+item); + var item := CreateItemAtLocation( 0, 0, 0, 0x300001 ); + if ( !item ) + return ret_error( "Failed to create item " + item ); endif item.Outer(); // this crashed - if (item.Outer2() != 2) - DestroyItem(item); - return ret_error("Locals backup seems to be broken"); + if ( item.Outer2() != 2 ) + DestroyItem( item ); + return ret_error( "Locals backup seems to be broken" ); endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction exported function test_create_item_container_loc() - var cnt := CreateItemAtLocation(0,0,0,0x200001); - if (!cnt) - return ret_error("Failed to create container "+cnt); + var cnt := CreateItemAtLocation( 0, 0, 0, 0x200001 ); + if ( !cnt ) + return ret_error( "Failed to create container " + cnt ); endif - var item := CreateItemInContainer(cnt, "goldcoin", 1000, 80, 90); - if (!item) - return ret_error($"Could not create item: {item}"); - elseif (item.x != 80 || item.y != 90) + var item := CreateItemInContainer( cnt, "goldcoin", 1000, 80, 90 ); + if ( !item ) + return ret_error( $"Could not create item: {item}" ); + elseif ( item.x != 80 || item.y != 90 ) var msg := $"Item not in expected location: item.x ({item.x}) != 80 or item.y ({item.y}) != 90"; - DestroyItem(cnt); - return ret_error(msg); + DestroyItem( cnt ); + return ret_error( msg ); endif - DestroyItem(cnt); + DestroyItem( cnt ); return 1; endfunction @@ -112,152 +112,149 @@ exported function test_item_controlscript_restart() // The control script starting is asynchronous, as it is just scheduled to run // upon item creation. Configure the item to send an event to this test script // when the control script begins execution. - var desc := GetItemDescriptor("RestartableItem"); + var desc := GetItemDescriptor( "RestartableItem" ); desc.SaveOnExit := 0; - desc.CProps := dictionary{ - "#TestPid" -> GetPid() - }; + desc.CProps := dictionary{ "#TestPid" -> GetPid() }; - var item := CreateItemAtLocation(0, 0, 0, desc); - if (!item) - return ret_error($"Failed to create item: ${item}"); + var item := CreateItemAtLocation( 0, 0, 0, desc ); + if ( !item ) + return ret_error( $"Failed to create item: ${item}" ); endif var err, initial_control_script_pid, restarted_control_script_pid; // Receive process id by event from the initial control script created via item creation. - if (!(initial_control_script_pid := get_pid_from_control_script(err, item, "initial"))) - DestroyItem(item); + if ( !( initial_control_script_pid := get_pid_from_control_script( err, item, "initial" ) ) ) + DestroyItem( item ); return err; endif // Restart the control script. - var restarted := RestartScript(item); - if (!restarted) - DestroyItem(item); - return ret_error($"Failed to RestartScript on item: ${restarted}"); + var restarted := RestartScript( item ); + if ( !restarted ) + DestroyItem( item ); + return ret_error( $"Failed to RestartScript on item: ${restarted}" ); endif // Receive process id by event from the new control script created by RestartScript. - if (!(restarted_control_script_pid := get_pid_from_control_script(err, item, "restarted"))) - DestroyItem(item); + if ( !( restarted_control_script_pid := get_pid_from_control_script( err, item, "restarted" ) ) ) + DestroyItem( item ); return err; endif // The initial and restarted process ids are different. - if (initial_control_script_pid == restarted_control_script_pid) - DestroyItem(item); - return ret_error($"The item's initial control script PID ({initial_control_script_pid}) should not equal the restarted control script PID ({restarted_control_script_pid})"); + if ( initial_control_script_pid == restarted_control_script_pid ) + DestroyItem( item ); + return ret_error( $"The item's initial control script PID ({initial_control_script_pid}) should not equal the restarted control script PID ({restarted_control_script_pid})" ); endif // RestartScript should have terminated the previous control script. - var old_process := GetProcess(initial_control_script_pid); - if (old_process) - DestroyItem(item); - return ret_error($"Previous control script unexpectedly still exists: ${old_process}"); + var old_process := GetProcess( initial_control_script_pid ); + if ( old_process ) + DestroyItem( item ); + return ret_error( $"Previous control script unexpectedly still exists: ${old_process}" ); endif - DestroyItem(item); + DestroyItem( item ); return 1; endfunction -function get_pid_from_control_script(byref err, item, label) +function get_pid_from_control_script( byref err, item, label ) // Get event from control script containing its process id. - var control_script_event := wait_for_event(5); - if (!control_script_event) - return err := ret_error($"Did not receive event from {label} control script."); + var control_script_event := wait_for_event( 5 ); + if ( !control_script_event ) + return err := ret_error( $"Did not receive event from {label} control script." ); endif var control_script_pid := control_script_event.control_script_pid; - if (item.process.pid != control_script_pid) - return err := ret_error($"The item's {label} control script PID ({item.process().pid}) does not equal the control script event's PID ({control_script_pid})"); + if ( item.process.pid != control_script_pid ) + return err := ret_error( $"The item's {label} control script PID ({item.process().pid}) does not equal the control script event's PID ({control_script_pid})" ); endif return control_script_pid; endfunction - // controlscript needs to be the last holder of itemref and destroy it // crash test/AddressSanitizer exported function test_item_controlscript_destroy() - var item:=CreateItemAtLocation(0,0,0,0x400003); - item:=0; - sleepms(30); + var item := CreateItemAtLocation( 0, 0, 0, 0x400003 ); + item := 0; + sleepms( 30 ); return 1; endfunction exported function test_item_FindSubstance() - var cnt:=CreateItemAtLocation(0,0,0,0x200001); - if (!cnt) - return ret_error("Failed to create container "+cnt); + var cnt := CreateItemAtLocation( 0, 0, 0, 0x200001 ); + if ( !cnt ) + return ret_error( "Failed to create container " + cnt ); endif - var item:=CreateItemInContainer(cnt, "goldcoin", 1000); - if (!item) - DestroyItem(cnt); - return ret_error($"Failed to create item: {item}"); + var item := CreateItemInContainer( cnt, "goldcoin", 1000 ); + if ( !item ) + DestroyItem( cnt ); + return ret_error( $"Failed to create item: {item}" ); endif var res; do - res := ReserveItem(item); - if (!res) + res := ReserveItem( item ); + if ( !res ) break; endif // Item is reserved, so should fail. res := FindSubstance( cnt, "goldcoin", 1 ); - if (res) - res := ret_error("Unexpected success in FindSubstance"); + if ( res ) + res := ret_error( "Unexpected success in FindSubstance" ); break; endif - res := ReleaseItem(item); - if (!res) + res := ReleaseItem( item ); + if ( !res ) break; endif // Item is not reserved, so should succeed. res := FindSubstance( cnt, "goldcoin", 1, makeinuse := true ); - if (!res) - res := ret_error($"Unexpected failure in FindSubstance: {res}"); + if ( !res ) + res := ret_error( $"Unexpected failure in FindSubstance: {res}" ); break; endif // Item should be reserved - res := ReserveItem(item); - if (res != 2) - res := ret_error($"Unexpected return from ReserveItem: {res}"); + res := ReserveItem( item ); + if ( res != 2 ) + res := ret_error( $"Unexpected return from ReserveItem: {res}" ); break; endif - res := ReleaseItem(item); - if (!res) + res := ReleaseItem( item ); + if ( !res ) break; endif // Item is not reserved, so should succeed. res := FindSubstance( cnt, "goldcoin", 1000, makeinuse := 1 ); - if (!res) - res := ret_error($"Unexpected failure in second FindSubstance: {res}"); + if ( !res ) + res := ret_error( $"Unexpected failure in second FindSubstance: {res}" ); break; endif // Item should be reserved - res := ReserveItem(item); - if (res != 2) - res := ret_error($"Unexpected return from second ReserveItem: {res}"); + res := ReserveItem( item ); + if ( res != 2 ) + res := ret_error( $"Unexpected return from second ReserveItem: {res}" ); break; endif - res := ReleaseItem(item); - if (!res) + res := ReleaseItem( item ); + if ( !res ) break; endif - dowhile (false); + dowhile ( false ); - DestroyItem(item); - DestroyItem(cnt); + DestroyItem( item ); + DestroyItem( cnt ); return res; endfunction @@ -355,7 +352,8 @@ exported function test_held_weight_multi() if ( !cont_half ) ret := ret_error( $"Failed to create cont_half: {cont_half}" ); break; - elseif ( !( ret := ret_error_not_equal( cont_half.held_weight_multiplier, 0.5, $"cont_half.held_weight_multiplier ({cont_half.held_weight_multiplier}) != 0.5" ) ) ) + elseif ( !( ret := ret_error_not_equal( cont_half.held_weight_multiplier, 0.5, + $"cont_half.held_weight_multiplier ({cont_half.held_weight_multiplier}) != 0.5" ) ) ) break; endif @@ -363,7 +361,8 @@ exported function test_held_weight_multi() // Create item via default result from GetItemDescriptor var itemdesc := GetItemDescriptor( "heldweightmultipliermod_quarter" ); - if ( !( ret := ret_error_not_equal( itemdesc.HeldWeightMultiplier, 0.25, $"itemdesc.HeldWeightMultiplier ({itemdesc.HeldWeightMultiplier}) != 0.25" ) ) ) + if ( !( ret := ret_error_not_equal( itemdesc.HeldWeightMultiplier, 0.25, + $"itemdesc.HeldWeightMultiplier ({itemdesc.HeldWeightMultiplier}) != 0.25" ) ) ) break; endif @@ -372,7 +371,8 @@ exported function test_held_weight_multi() if ( !cont_quarter ) ret := ret_error( $"Failed to create cont_quarter: {cont_quarter}" ); break; - elseif ( !( ret := ret_error_not_equal( cont_quarter.held_weight_multiplier, 0.25, $"cont_quarter.held_weight_multiplier ({cont_quarter.held_weight_multiplier}) != 0.25" ) ) ) + elseif ( !( ret := ret_error_not_equal( cont_quarter.held_weight_multiplier, 0.25, + $"cont_quarter.held_weight_multiplier ({cont_quarter.held_weight_multiplier}) != 0.25" ) ) ) break; endif @@ -396,7 +396,8 @@ exported function test_held_weight_multi() var expected_weight_half := 100; // CInt(cont_half_weight_empty + item.weight * 0.5); - if ( !( ret := ret_error_not_equal( cont_half.weight, expected_weight_half, $"cont_half.weight ({cont_half.weight}) != expected_weight_half ({expected_weight_half})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_half.weight, expected_weight_half, + $"cont_half.weight ({cont_half.weight}) != expected_weight_half ({expected_weight_half})" ) ) ) break; endif @@ -406,13 +407,16 @@ exported function test_held_weight_multi() endif // Weight of half-container should reset. - if ( !( ret := ret_error_not_equal( cont_half.weight, cont_half_weight_empty, $"cont_half.weight ({cont_half.weight}) != cont_half_weight_empty ({cont_half_weight_empty})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_half.weight, cont_half_weight_empty, + $"cont_half.weight ({cont_half.weight}) != cont_half_weight_empty ({cont_half_weight_empty})" ) ) ) break; endif var expected_weight_quarter := 75; // CInt(cont_quarter_weight_empty + item.weight * 0.25); - if ( !( ret := ret_error_not_equal( cont_quarter.weight, expected_weight_quarter, $"cont_quarter.weight ({cont_quarter.weight}) != expected_weight_quarter ({expected_weight_quarter})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_quarter.weight, expected_weight_quarter, + $"cont_quarter.weight ({cont_quarter.weight}) != expected_weight_quarter ({expected_weight_quarter})" + ) ) ) break; endif @@ -425,7 +429,9 @@ exported function test_held_weight_multi() var expected_weight_normal := 128; // CInt(cont_normal_weight_empty + cont_half_weight_empty + item.weight * 0.25 + cont_quarter_weight_empty); - if ( !( ret := ret_error_not_equal( cont_normal.weight, expected_weight_normal, $"cont_normal.weight ({cont_normal.weight}) != expected_weight_normal ({expected_weight_normal})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_normal.weight, expected_weight_normal, + $"cont_normal.weight ({cont_normal.weight}) != expected_weight_normal ({expected_weight_normal})" ) + ) ) break; endif @@ -439,15 +445,20 @@ exported function test_held_weight_multi() expected_weight_half := 75; // CInt(cont_half_weight_empty + item_split.weight * 0.50); expected_weight_normal := 140; // CInt(cont_normal_weight_empty + (cont_half_weight_empty + 50 * 0.25) + (cont_quarter_weight_empty + 50 * 0.50)); - if ( !( ret := ret_error_not_equal( cont_normal.weight, expected_weight_normal, $"cont_normal.weight ({cont_normal.weight}) != expected_weight_normal ({expected_weight_normal})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_normal.weight, expected_weight_normal, + $"cont_normal.weight ({cont_normal.weight}) != expected_weight_normal ({expected_weight_normal})" ) + ) ) break; endif - if ( !( ret := ret_error_not_equal( cont_quarter.weight, expected_weight_quarter, $"cont_quarter.weight ({cont_quarter.weight}) != expected_weight_quarter ({expected_weight_quarter})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_quarter.weight, expected_weight_quarter, + $"cont_quarter.weight ({cont_quarter.weight}) != expected_weight_quarter ({expected_weight_quarter})" + ) ) ) break; endif - if ( !( ret := ret_error_not_equal( cont_half.weight, expected_weight_half, $"cont_half.weight ({cont_half.weight}) != expected_weight_half ({expected_weight_half})" ) ) ) + if ( !( ret := ret_error_not_equal( cont_half.weight, expected_weight_half, + $"cont_half.weight ({cont_half.weight}) != expected_weight_half ({expected_weight_half})" ) ) ) break; endif @@ -455,23 +466,23 @@ exported function test_held_weight_multi() dowhile ( false ); if ( item ) - DestroyItem( item ); + DestroyItem( item ); endif if ( item_split ) - DestroyItem( item_split ); + DestroyItem( item_split ); endif if ( cont_normal ) - DestroyItem( cont_normal ); + DestroyItem( cont_normal ); endif if ( cont_half ) - DestroyItem( cont_half ); + DestroyItem( cont_half ); endif if ( cont_quarter ) - DestroyItem( cont_quarter ); + DestroyItem( cont_quarter ); endif return ret; @@ -481,7 +492,7 @@ exported function test_held_weight_multi_itemdesc() var ret, item; do - var itemdesc := GetItemDescriptor("backpack"); + var itemdesc := GetItemDescriptor( "backpack" ); if ( !( ret := itemdesc ) ) break; endif @@ -493,7 +504,8 @@ exported function test_held_weight_multi_itemdesc() break; endif - if ( !( ret := ret_error_not_equal( item.held_weight_multiplier, 0.5, $"item.held_weight_multiplier ({item.held_weight_multiplier}) != 0.5" ) ) ) + if ( !( ret := ret_error_not_equal( item.held_weight_multiplier, 0.5, + $"item.held_weight_multiplier ({item.held_weight_multiplier}) != 0.5" ) ) ) break; endif @@ -518,7 +530,7 @@ exported function test_held_weight_multi_cont_full() break; endif - var desc := GetItemDescriptor(cont_half.objtype); + var desc := GetItemDescriptor( cont_half.objtype ); // Fill container to 50% full (100 weight * 0.5 mod < 100 max weight) var item1 := CreateItemInContainer( cont_half, "goldcoin_heavy", 100 ); @@ -556,7 +568,6 @@ exported function test_held_weight_multi_cont_full() return ret; endfunction - // Tests dynamically changing held_weight_multiplier on containers at // various depths inside other containers. exported function test_held_weight_multi_dynamic() @@ -591,14 +602,16 @@ exported function test_held_weight_multi_dynamic() break; endif - var expected_weight_cont3, expected_weight_cont2, expected_weight_cont1, expected, actual; + var expected_weight_cont3, expected_weight_cont2, expected_weight_cont1, expected, + actual; expected_weight_cont3 := 103; // 100 + 3 expected_weight_cont2 := 106; // (100 + 3) + 3 - expected_weight_cont1 := 109; // ((100 + 3) + 3) + 3 + expected_weight_cont1 := 109; // ((100 + 3) + 3) + 3 expected := array{ expected_weight_cont1, expected_weight_cont2, expected_weight_cont3 }; actual := array{ cont1.weight, cont2.weight, cont3.weight }; - if ( !( ret := ret_error_not_equal( actual, expected, $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) + if ( !( ret := ret_error_not_equal( actual, expected, + $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) break; endif @@ -607,10 +620,11 @@ exported function test_held_weight_multi_dynamic() cont3.held_weight_multiplier := 1; expected_weight_cont3 := 103; // 100 + 3 expected_weight_cont2 := 106; // (100 + 3) + 3 - expected_weight_cont1 := 56; // ((100 + 3) + 3) * 0.5 + 3 + expected_weight_cont1 := 56; // ((100 + 3) + 3) * 0.5 + 3 expected := array{ expected_weight_cont1, expected_weight_cont2, expected_weight_cont3 }; actual := array{ cont1.weight, cont2.weight, cont3.weight }; - if ( !( ret := ret_error_not_equal( actual, expected, $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) + if ( !( ret := ret_error_not_equal( actual, expected, + $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) break; endif @@ -619,10 +633,11 @@ exported function test_held_weight_multi_dynamic() cont3.held_weight_multiplier := 1; expected_weight_cont3 := 103; // 100 + 3 expected_weight_cont2 := 54; // (100 + 3) * 0.5 + 3 - expected_weight_cont1 := 57; // ((100 + 3) * 0.5 + 3) + 3 + expected_weight_cont1 := 57; // ((100 + 3) * 0.5 + 3) + 3 expected := array{ expected_weight_cont1, expected_weight_cont2, expected_weight_cont3 }; actual := array{ cont1.weight, cont2.weight, cont3.weight }; - if ( !( ret := ret_error_not_equal( actual, expected, $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) + if ( !( ret := ret_error_not_equal( actual, expected, + $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) break; endif @@ -631,10 +646,11 @@ exported function test_held_weight_multi_dynamic() cont3.held_weight_multiplier := 0.5; expected_weight_cont3 := 53; // 100 * 0.5 + 3 expected_weight_cont2 := 56; // (100 * 0.5 + 3) + 3 - expected_weight_cont1 := 59; // ((100 * 0.5 + 3) + 3) + 3 + expected_weight_cont1 := 59; // ((100 * 0.5 + 3) + 3) + 3 expected := array{ expected_weight_cont1, expected_weight_cont2, expected_weight_cont3 }; actual := array{ cont1.weight, cont2.weight, cont3.weight }; - if ( !( ret := ret_error_not_equal( actual, expected, $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) + if ( !( ret := ret_error_not_equal( actual, expected, + $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) break; endif @@ -643,10 +659,11 @@ exported function test_held_weight_multi_dynamic() cont3.held_weight_multiplier := 0.5; expected_weight_cont3 := 53; // 100 * 0.5 + 3 expected_weight_cont2 := 56; // (100 * 0.5 + 3) + 3 - expected_weight_cont1 := 31; // ((100 * 0.5 + 3) + 3) * 0.5 + 3 + expected_weight_cont1 := 31; // ((100 * 0.5 + 3) + 3) * 0.5 + 3 expected := array{ expected_weight_cont1, expected_weight_cont2, expected_weight_cont3 }; actual := array{ cont1.weight, cont2.weight, cont3.weight }; - if ( !( ret := ret_error_not_equal( actual, expected, $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) + if ( !( ret := ret_error_not_equal( actual, expected, + $"Weights unequal: actual ({actual}) != expected ({expected})" ) ) ) break; endif diff --git a/testsuite/pol/testpkgs/item/test_load.src b/testsuite/pol/testpkgs/item/test_load.src index 45646c165..c761e7d69 100644 --- a/testsuite/pol/testpkgs/item/test_load.src +++ b/testsuite/pol/testpkgs/item/test_load.src @@ -8,19 +8,18 @@ program testload() endprogram exported function load_container() - var cnt:=CreateItemAtLocation(0,0,0,0x200001); - if (!cnt) - return ret_error("Failed to create container "+cnt); + var cnt := CreateItemAtLocation( 0, 0, 0, 0x200001 ); + if ( !cnt ) + return ret_error( "Failed to create container " + cnt ); endif - if (!cnt.no_drop_exception) - DestroyItem(cnt); - return ret_error("Failed to load nodropexception"); + if ( !cnt.no_drop_exception ) + DestroyItem( cnt ); + return ret_error( "Failed to load nodropexception" ); endif - if (!cnt.no_drop) - DestroyItem(cnt); - return ret_error("Failed to load nodrop"); + if ( !cnt.no_drop ) + DestroyItem( cnt ); + return ret_error( "Failed to load nodrop" ); endif - DestroyItem(cnt); + DestroyItem( cnt ); return 1; endfunction - diff --git a/testsuite/pol/testpkgs/map/test_findpath.src b/testsuite/pol/testpkgs/map/test_findpath.src index 683fd92b2..89a9b672c 100644 --- a/testsuite/pol/testpkgs/map/test_findpath.src +++ b/testsuite/pol/testpkgs/map/test_findpath.src @@ -62,15 +62,13 @@ ox-o ooxo */ exported function path_blocking_diagonal() - var wall:=CreateItemAtLocation(102,101,0,0x6); - var res:=FindPath( 100, 100, 0, 102, 102, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5 ); - var expected:={ - struct{x:=101,y:=101,z:=0}, - struct{x:=102,y:=102,z:=0} - }; - DestroyItem(wall); - var comp:=compare_path(res,expected); - if (!comp) + var wall := CreateItemAtLocation( 102, 101, 0, 0x6 ); + var res := FindPath( 100, 100, 0, 102, 102, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5 ); + var expected := { struct{ x := 101, y := 101, z := 0 }, struct{ x := 102, y := 102, z := 0 } }; + DestroyItem( wall ); + var comp := compare_path( res, expected ); + if ( !comp ) return comp; endif return 1; @@ -90,19 +88,18 @@ o-xo oooo */ exported function path_blocking_diagonal2() - var wall:=CreateItemAtLocation(102,101,0,0x6); - var wall2:=CreateItemAtLocation(101,102,0,0x6); - var res:=FindPath( 100, 100, 0, 102, 102, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5 ); - var expected:={ - struct{x:=101,y:=100,z:=0}, - struct{x:=102,y:=100,z:=0}, - struct{x:=103,y:=101,z:=0}, - struct{x:=102,y:=102,z:=0} - }; - DestroyItem(wall); - DestroyItem(wall2); - var comp:=compare_path(res,expected); - if (!comp) + var wall := CreateItemAtLocation( 102, 101, 0, 0x6 ); + var wall2 := CreateItemAtLocation( 101, 102, 0, 0x6 ); + var res := FindPath( 100, 100, 0, 102, 102, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5 ); + var expected := { struct{ x := 101, y := 100, z := 0 }, + struct{ x := 102, y := 100, z := 0 }, + struct{ x := 103, y := 101, z := 0 }, + struct{ x := 102, y := 102, z := 0 } }; + DestroyItem( wall ); + DestroyItem( wall2 ); + var comp := compare_path( res, expected ); + if ( !comp ) return comp; endif return 1; @@ -114,13 +111,14 @@ OX-o O-Xo */ exported function path_water_blocking2() - var wall:=CreateItemAtLocation(29,28,0,0x6); - var wall2:=CreateItemAtLocation(28,29,0,0x6); - var res:=FindPath( 28, 28, 0, 29, 29, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5 ); - DestroyItem(wall); - DestroyItem(wall2); - if (res.errortext != "Failed to find a path.") - return ret_error($"expected failed to find path, got: {res}"); + var wall := CreateItemAtLocation( 29, 28, 0, 0x6 ); + var wall2 := CreateItemAtLocation( 28, 29, 0, 0x6 ); + var res := FindPath( 28, 28, 0, 29, 29, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5 ); + DestroyItem( wall ); + DestroyItem( wall2 ); + if ( res.errortext != "Failed to find a path." ) + return ret_error( $"expected failed to find path, got: {res}" ); endif return 1; endfunction @@ -139,27 +137,24 @@ O-o Ooo */ exported function path_water_blocking2_ls() - var wall:=CreateItemAtLocation(29,28,0,0x6); - var wall2:=CreateItemAtLocation(28,29,0,0x6); - var res:=FindPath( 28, 28, 0, 29, 29, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5, movemode:="LS" ); - var expected:={ - struct{x:=27,y:=29,z:=-5}, - struct{x:=28,y:=30,z:=-5}, - struct{x:=29,y:=29,z:=0} - }; + var wall := CreateItemAtLocation( 29, 28, 0, 0x6 ); + var wall2 := CreateItemAtLocation( 28, 29, 0, 0x6 ); + var res := FindPath( 28, 28, 0, 29, 29, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5, movemode := "LS" ); + var expected := { struct{ x := 27, y := 29, z := -5 }, + struct{ x := 28, y := 30, z := -5 }, + struct{ x := 29, y := 29, z := 0 } }; - var expected2:={ - struct{x:=29,y:=27,z:=-5}, - struct{x:=30,y:=28,z:=-5}, - struct{x:=29,y:=29,z:=0} - }; + var expected2 := { struct{ x := 29, y := 27, z := -5 }, + struct{ x := 30, y := 28, z := -5 }, + struct{ x := 29, y := 29, z := 0 } }; - DestroyItem(wall); - DestroyItem(wall2); - var comp:=compare_path(res,expected); - if (!comp) - comp:=compare_path(res,expected2); - if (!comp) + DestroyItem( wall ); + DestroyItem( wall2 ); + var comp := compare_path( res, expected ); + if ( !comp ) + comp := compare_path( res, expected2 ); + if ( !comp ) return comp; endif endif @@ -167,50 +162,50 @@ exported function path_water_blocking2_ls() endfunction exported function path_wrongmovemode() - var res:=FindPath( 100, 100, 0, 100, 105, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5, movemode:="B"); - if (res.errortext != "Wrong movemode parameter") - return ret_error($"expected failure wrong movemode, got: {res}"); + var res := FindPath( 100, 100, 0, 100, 105, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5, movemode := "B" ); + if ( res.errortext != "Wrong movemode parameter" ) + return ret_error( $"expected failure wrong movemode, got: {res}" ); endif return 1; endfunction // end of map with blocking walls exported function path_failure_end_of_map() - var wall:=CreateItemAtLocation(191,190,0,0x6); - var wall2:=CreateItemAtLocation(190,191,0,0x6); - var res:=FindPath( 191, 191, 0, 190, 190, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5, movemode:="LS" ); - DestroyItem(wall); - DestroyItem(wall2); - if (res.errortext != "Failed to find a path.") - return ret_error($"expected failed to find path, got: {res}"); + var wall := CreateItemAtLocation( 191, 190, 0, 0x6 ); + var wall2 := CreateItemAtLocation( 190, 191, 0, 0x6 ); + var res := FindPath( 191, 191, 0, 190, 190, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5, movemode := "LS" ); + DestroyItem( wall ); + DestroyItem( wall2 ); + if ( res.errortext != "Failed to find a path." ) + return ret_error( $"expected failed to find path, got: {res}" ); endif return 1; endfunction // end of map with blocking walls exported function path_failure_end_of_map2() - var wall:=CreateItemAtLocation(1,0,0,0x6); - var wall2:=CreateItemAtLocation(0,1,0,0x6); - var res:=FindPath( 0, 0, 0, 1, 1, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5, movemode:="LS" ); - DestroyItem(wall); - DestroyItem(wall2); - if (res.errortext != "Failed to find a path.") - return ret_error($"expected failed to find path, got: {res}"); + var wall := CreateItemAtLocation( 1, 0, 0, 0x6 ); + var wall2 := CreateItemAtLocation( 0, 1, 0, 0x6 ); + var res := FindPath( 0, 0, 0, 1, 1, 0, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, + searchskirt := 5, movemode := "LS" ); + DestroyItem( wall ); + DestroyItem( wall2 ); + if ( res.errortext != "Failed to find a path." ) + return ret_error( $"expected failed to find path, got: {res}" ); endif return 1; endfunction -function compare_path(res,exp) - if (len(res) != len(exp)) - return ret_error($"different length result: {res} expected: {exp}"); +function compare_path( res, exp ) + if ( len( res ) != len( exp ) ) + return ret_error( $"different length result: {res} expected: {exp}" ); endif - for i:=1 to res.size() - if (res[i].x != exp[i].x || - res[i].y != exp[i].y || - res[i].z != exp[i].z) - return ret_error($"different entry result: {res} expected: {exp}"); + for i := 1 to res.size() + if ( res[i].x != exp[i].x || res[i].y != exp[i].y || res[i].z != exp[i].z ) + return ret_error( $"different entry result: {res} expected: {exp}" ); endif endfor return 1; endfunction - diff --git a/testsuite/pol/testpkgs/map/test_getstandingcoordinates.src b/testsuite/pol/testpkgs/map/test_getstandingcoordinates.src index adadae95c..425bcf613 100644 --- a/testsuite/pol/testpkgs/map/test_getstandingcoordinates.src +++ b/testsuite/pol/testpkgs/map/test_getstandingcoordinates.src @@ -4,67 +4,65 @@ use os; include "testutil"; program getstanding() - return 1; + return 1; endprogram -var expected_data := array{ - struct{ "x" := 28, "y" := 82, "z" := -2 }, - struct{ "x" := 29, "y" := 82, "z" := 0 }, - struct{ "x" := 30, "y" := 82, "z" := 0 }, - struct{ "x" := 28, "y" := 83, "z" := -2 }, - struct{ "x" := 29, "y" := 83, "z" := 0 }, - struct{ "x" := 30, "y" := 83, "z" := 0 }, - struct{ "x" := 28, "y" := 84, "z" := -2 }, - struct{ "x" := 29, "y" := 84, "z" := 0 }, - struct{ "x" := 30, "y" := 84, "z" := 0 }, - struct{ "x" := 28, "y" := 85, "z" := -2 }, - struct{ "x" := 29, "y" := 85, "z" := 0 }, - struct{ "x" := 30, "y" := 85, "z" := 0 }, - struct{ "x" := 28, "y" := 86, "z" := -2 }, - struct{ "x" := 29, "y" := 86, "z" := 0 }, - struct{ "x" := 30, "y" := 86, "z" := 0 }, - struct{ "x" := 28, "y" := 87, "z" := -2 }, - struct{ "x" := 29, "y" := 87, "z" := 0 }, - struct{ "x" := 30, "y" := 87, "z" := 0 }, - struct{ "x" := 28, "y" := 88, "z" := -2 }, - struct{ "x" := 29, "y" := 88, "z" := 0 }, - struct{ "x" := 30, "y" := 88, "z" := 0 }, - struct{ "x" := 28, "y" := 89, "z" := -2 }, - struct{ "x" := 29, "y" := 89, "z" := 0 }, - struct{ "x" := 30, "y" := 89, "z" := 0 }, - struct{ "x" := 28, "y" := 90, "z" := -2 }, - struct{ "x" := 29, "y" := 90, "z" := 0 }, - struct{ "x" := 30, "y" := 90, "z" := 0 }, - struct{ "x" := 28, "y" := 91, "z" := -2 }, - struct{ "x" := 29, "y" := 91, "z" := 0 }, - struct{ "x" := 30, "y" := 91, "z" := 0 }, - struct{ "x" := 28, "y" := 92, "z" := -2 }, - struct{ "x" := 29, "y" := 92, "z" := 0 }, - struct{ "x" := 30, "y" := 92, "z" := 0 } -}; +var expected_data := array{ struct{ "x" := 28, "y" := 82, "z" := -2 }, + struct{ "x" := 29, "y" := 82, "z" := 0 }, + struct{ "x" := 30, "y" := 82, "z" := 0 }, + struct{ "x" := 28, "y" := 83, "z" := -2 }, + struct{ "x" := 29, "y" := 83, "z" := 0 }, + struct{ "x" := 30, "y" := 83, "z" := 0 }, + struct{ "x" := 28, "y" := 84, "z" := -2 }, + struct{ "x" := 29, "y" := 84, "z" := 0 }, + struct{ "x" := 30, "y" := 84, "z" := 0 }, + struct{ "x" := 28, "y" := 85, "z" := -2 }, + struct{ "x" := 29, "y" := 85, "z" := 0 }, + struct{ "x" := 30, "y" := 85, "z" := 0 }, + struct{ "x" := 28, "y" := 86, "z" := -2 }, + struct{ "x" := 29, "y" := 86, "z" := 0 }, + struct{ "x" := 30, "y" := 86, "z" := 0 }, + struct{ "x" := 28, "y" := 87, "z" := -2 }, + struct{ "x" := 29, "y" := 87, "z" := 0 }, + struct{ "x" := 30, "y" := 87, "z" := 0 }, + struct{ "x" := 28, "y" := 88, "z" := -2 }, + struct{ "x" := 29, "y" := 88, "z" := 0 }, + struct{ "x" := 30, "y" := 88, "z" := 0 }, + struct{ "x" := 28, "y" := 89, "z" := -2 }, + struct{ "x" := 29, "y" := 89, "z" := 0 }, + struct{ "x" := 30, "y" := 89, "z" := 0 }, + struct{ "x" := 28, "y" := 90, "z" := -2 }, + struct{ "x" := 29, "y" := 90, "z" := 0 }, + struct{ "x" := 30, "y" := 90, "z" := 0 }, + struct{ "x" := 28, "y" := 91, "z" := -2 }, + struct{ "x" := 29, "y" := 91, "z" := 0 }, + struct{ "x" := 30, "y" := 91, "z" := 0 }, + struct{ "x" := 28, "y" := 92, "z" := -2 }, + struct{ "x" := 29, "y" := 92, "z" := 0 }, + struct{ "x" := 30, "y" := 92, "z" := 0 } }; exported function getstanding() - var coords := GetStandingCoordinates(25, 87, 5); + var coords := GetStandingCoordinates( 25, 87, 5 ); - // Uncomment this block to generate a preformatted list of the function's return values, for updating expected_data above + // Uncomment this block to generate a preformatted list of the function's return values, for updating expected_data above - // foreach coord in (coords) - // var multi := coords.multi ? $", \"multi\" := {coord.multi}" : ""; - // var comma := _coord_iter == coords.size() ? "" : ","; - // print($" struct\{ \"x\" := {coord.x}, \"y\" := {coord.y}, \"z\" := {coord.z}{multi} \}{comma}"); - // endforeach + // foreach coord in (coords) + // var multi := coords.multi ? $", \"multi\" := {coord.multi}" : ""; + // var comma := _coord_iter == coords.size() ? "" : ","; + // print($" struct\{ \"x\" := {coord.x}, \"y\" := {coord.y}, \"z\" := {coord.z}{multi} \}{comma}"); + // endforeach - var i; - for (i := 1; i <= coords.size(); i++) - var coord := coords[i]; - var expected := expected_data[i]; - if (coord.x != expected.x || coord.y != expected.y || coord.z != expected.z) - return ret_error($"Invalid data returned at index {i}. Expected {expected}; got {coord}"); - endif - endfor - - if (coords.size() != expected_data.size()) - return ret_error($"Invalid number of coordinates returned. Expected {expected_data.size()}; got {coords.size()}"); + var i; + for ( i := 1; i <= coords.size(); i++ ) + var coord := coords[i]; + var expected := expected_data[i]; + if ( coord.x != expected.x || coord.y != expected.y || coord.z != expected.z ) + return ret_error( $"Invalid data returned at index {i}. Expected {expected}; got {coord}" ); endif - return 1; + endfor + + if ( coords.size() != expected_data.size() ) + return ret_error( $"Invalid number of coordinates returned. Expected {expected_data.size()}; got {coords.size()}" ); + endif + return 1; endfunction diff --git a/testsuite/pol/testpkgs/map/test_liststatics.src b/testsuite/pol/testpkgs/map/test_liststatics.src index 620aa74aa..16da9b45c 100644 --- a/testsuite/pol/testpkgs/map/test_liststatics.src +++ b/testsuite/pol/testpkgs/map/test_liststatics.src @@ -8,15 +8,17 @@ program liststatics() endprogram exported function inbox() - var info:=ListStaticsInBox(154,154,-128,154,153,128); - if (len(info)!=2) - return ret_error($"wrong number of statics got : {info}"); + var info := ListStaticsInBox( 154, 154, -128, 154, 153, 128 ); + if ( len( info ) != 2 ) + return ret_error( $"wrong number of statics got : {info}" ); endif - if ( info[1].objtype!=0x05c3 || info[1].x!=154 || info[1].y!=153 || info[1].z!=27 || info[1].hue!=0) - return ret_error("Wrong static found at pos 1 :"+info[1]); + if ( info[1].objtype != 0x05c3 || info[1].x != 154 || info[1].y != 153 || info[1].z != 27 || + info[1].hue != 0 ) + return ret_error( "Wrong static found at pos 1 :" + info[1] ); endif - if (info[1].objtype!=0x05c3 || info[2].x !=154 || info[2].y!=154 || info[2].z!=27 || info[2].hue!=1) - return ret_error("Wrong static found at pos 2 :"+info[2]); + if ( info[1].objtype != 0x05c3 || info[2].x != 154 || info[2].y != 154 || info[2].z != 27 || + info[2].hue != 1 ) + return ret_error( "Wrong static found at pos 2 :" + info[2] ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/map/test_mapinfo.src b/testsuite/pol/testpkgs/map/test_mapinfo.src index 8a5590760..d098134b2 100644 --- a/testsuite/pol/testpkgs/map/test_mapinfo.src +++ b/testsuite/pol/testpkgs/map/test_mapinfo.src @@ -8,31 +8,39 @@ program map_info() endprogram exported function mapinfo() - var errortext:=""; - for x:=31 to 33 - for y:=20 to 30 - var info:=GetMapInfo(x,y); - if (y<28) - if (info.landtile != 0xa8 || info.z != -5) - errortext+="Wrong mapinfo {},{}: expected {},{} got {},{}\n".format(x,y,0xa8,-5,info.landtile,info.z); + var errortext := ""; + for x := 31 to 33 + for y := 20 to 30 + var info := GetMapInfo( x, y ); + if ( y < 28 ) + if ( info.landtile != 0xa8 || info.z != -5 ) + errortext += "Wrong mapinfo {},{}: expected {},{} got {},{}\n".format( x, y, 0xa8, -5, + info.landtile, + info.z ); endif - elseif (y==28) - if (info.landtile != 0x17 || info.z != -2) - errortext+="Wrong mapinfo {},{}: expected {},{} got {},{}\n".format(x,y,0x17,-3,info.landtile,info.z); + elseif ( y == 28 ) + if ( info.landtile != 0x17 || info.z != -2 ) + errortext += "Wrong mapinfo {},{}: expected {},{} got {},{}\n".format( x, y, 0x17, -3, + info.landtile, + info.z ); endif - elseif (y==29) - if (info.landtile != 0x17 || info.z != 0) - errortext+="Wrong mapinfo {},{}: expected {},{} got {},{}\n".format(x,y,0x17,0,info.landtile,info.z); + elseif ( y == 29 ) + if ( info.landtile != 0x17 || info.z != 0 ) + errortext += "Wrong mapinfo {},{}: expected {},{} got {},{}\n".format( x, y, 0x17, 0, + info.landtile, + info.z ); endif - elseif (y>=30) - if (info.landtile != 0x3 || info.z != 0) - errortext+="Wrong mapinfo {},{}: expected {},{} got {},{}\n".format(x,y,0x3,0,info.landtile,info.z); + elseif ( y >= 30 ) + if ( info.landtile != 0x3 || info.z != 0 ) + errortext += "Wrong mapinfo {},{}: expected {},{} got {},{}\n".format( x, y, 0x3, 0, + info.landtile, + info.z ); endif endif endfor endfor - if (len(errortext)) - return ret_error(errortext); + if ( len( errortext ) ) + return ret_error( errortext ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/misc/test_cmds.src b/testsuite/pol/testpkgs/misc/test_cmds.src index b624a3e59..5e9724366 100644 --- a/testsuite/pol/testpkgs/misc/test_cmds.src +++ b/testsuite/pol/testpkgs/misc/test_cmds.src @@ -9,10 +9,9 @@ program testcmds() endprogram exported function find_cmds() - var cmds:=ListTextCommands(); - if (cmds["testmisc"][1][1].dir != "textcmd/test/" || - cmds["testmisc"][1][1].script != "dummycmd.ecl") - return ret_error("missing textcmd: "+cmds); + var cmds := ListTextCommands(); + if ( cmds["testmisc"][1][1].dir != "textcmd/test/" || cmds["testmisc"][1][1].script != "dummycmd.ecl" ) + return ret_error( "missing textcmd: " + cmds ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/misc/test_env.src b/testsuite/pol/testpkgs/misc/test_env.src index e9a636815..87d983a37 100644 --- a/testsuite/pol/testpkgs/misc/test_env.src +++ b/testsuite/pol/testpkgs/misc/test_env.src @@ -6,35 +6,35 @@ program test_env() endprogram exported function get_env() - var res:=GetEnvironmentVariable("POLCORE_TEST"); - if (res != "1") - return ret_error("Environment variable not found got: "+res); + var res := GetEnvironmentVariable( "POLCORE_TEST" ); + if ( res != "1" ) + return ret_error( "Environment variable not found got: " + res ); endif return 1; endfunction exported function list_env() - var res:=GetEnvironmentVariable(); - if (res["POLCORE_TEST"] != "1") - return ret_error("Environment variable not found got: "+res); + var res := GetEnvironmentVariable(); + if ( res["POLCORE_TEST"] != "1" ) + return ret_error( "Environment variable not found got: " + res ); endif return 1; endfunction exported function get_noaccess_env() - foreach env in ({"POLCORE_TEST_NOACCESS", "polcore_test_noaccess"}) - var res:=GetEnvironmentVariable(env); - if (res.errortext != "Environment Variable access disallowed due to pol.cfg setting") - return ret_error("Environment variable was found when expected access error, got: "+res); + foreach env in ( { "POLCORE_TEST_NOACCESS", "polcore_test_noaccess" } ) + var res := GetEnvironmentVariable( env ); + if ( res.errortext != "Environment Variable access disallowed due to pol.cfg setting" ) + return ret_error( "Environment variable was found when expected access error, got: " + res ); endif endforeach return 1; endfunction exported function get_notfound_env() - var res:=GetEnvironmentVariable("POLCORE_TEST_NOTFOUND"); - if (res.errortext != "Environment variable not found") - return ret_error("Environment variable found when expected not found error, got: "+res); + var res := GetEnvironmentVariable( "POLCORE_TEST_NOTFOUND" ); + if ( res.errortext != "Environment variable not found" ) + return ret_error( "Environment variable found when expected not found error, got: " + res ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/misc/test_httprequest.src b/testsuite/pol/testpkgs/misc/test_httprequest.src index 5c96433da..82cd3eb69 100644 --- a/testsuite/pol/testpkgs/misc/test_httprequest.src +++ b/testsuite/pol/testpkgs/misc/test_httprequest.src @@ -6,71 +6,73 @@ program test_httprequest() endprogram exported function test_httprequest_regular() - var res := HTTPRequest("http://127.0.0.1:5006/pkg/webserver/test.ecl?body=%7B%22status%22%3A200%7D"); + var res := HTTPRequest( "http://127.0.0.1:5006/pkg/webserver/test.ecl?body=%7B%22status%22%3A200%7D" ); var expected := "{\"status\":200}"; - if (res != expected) - return ret_error($"HTTPRequest returned '{res}', expecting '{expected}'"); + if ( res != expected ) + return ret_error( $"HTTPRequest returned '{res}', expecting '{expected}'" ); endif return 1; endfunction exported function test_httprequest_ext_status() - var res := HTTPRequest("http://127.0.0.1:5006/pkg/webserver/test.ecl?status=429&body=%7B%22status%22%3A429%7D", flags := HTTPREQUEST_EXTENDED_RESPONSE); + var res := HTTPRequest( "http://127.0.0.1:5006/pkg/webserver/test.ecl?status=429&body=%7B%22status%22%3A429%7D", + flags := HTTPREQUEST_EXTENDED_RESPONSE ); var actual, expected; - actual := TypeOfInt(res); + actual := TypeOfInt( res ); expected := OT_DICTIONARY; - if (actual != expected) - return ret_error($"HTTPRequest returned type {actual}, expecting {expected}"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned type {actual}, expecting {expected}" ); endif actual := res.status; expected := 429; - if (actual != expected) - return ret_error($"HTTPRequest returned status {actual}, expecting {expected}"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned status {actual}, expecting {expected}" ); endif actual := res.statusText; expected := "Too Many Requests"; - if (actual != expected) - return ret_error($"HTTPRequest returned statusText '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned statusText '{actual}', expecting '{expected}'" ); endif actual := res.body; expected := "{\"status\":429}"; - if (actual != expected) - return ret_error($"HTTPRequest returned body '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned body '{actual}', expecting '{expected}'" ); endif return 1; endfunction exported function test_httprequest_ext_headers() - var res := HTTPRequest("http://127.0.0.1:5006/pkg/webserver/test.ecl?headers=%5B%7B%22name%22%3A%22test1%22%2C%22value%22%3A%22value1%22%7D%2C%7B%22name%22%3A%22test2%22%2C%22value%22%3A%22value2a%22%7D%2C%7B%22name%22%3A%22test2%22%2C%22value%22%3A%22value2b%22%7D%5D", flags := HTTPREQUEST_EXTENDED_RESPONSE); + var res := HTTPRequest( "http://127.0.0.1:5006/pkg/webserver/test.ecl?headers=%5B%7B%22name%22%3A%22test1%22%2C%22value%22%3A%22value1%22%7D%2C%7B%22name%22%3A%22test2%22%2C%22value%22%3A%22value2a%22%7D%2C%7B%22name%22%3A%22test2%22%2C%22value%22%3A%22value2b%22%7D%5D", + flags := HTTPREQUEST_EXTENDED_RESPONSE ); var actual, expected; - actual := TypeOfInt(res); + actual := TypeOfInt( res ); expected := OT_DICTIONARY; - if (actual != expected) - return ret_error($"HTTPRequest returned type {actual}, expecting {expected}"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned type {actual}, expecting {expected}" ); endif - actual := TypeOfInt(res.headers); + actual := TypeOfInt( res.headers ); expected := OT_DICTIONARY; - if (actual != expected) - return ret_error($"HTTPRequest returned headers type {actual}, expecting {expected}"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned headers type {actual}, expecting {expected}" ); endif actual := res.headers.test1; expected := "value1"; - if (actual != expected) - return ret_error($"HTTPRequest returned headers.test1 '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned headers.test1 '{actual}', expecting '{expected}'" ); endif actual := res.headers.test2; expected := "value2a, value2b"; - if (actual != expected) - return ret_error($"HTTPRequest returned headers.test2 '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned headers.test2 '{actual}', expecting '{expected}'" ); endif return 1; diff --git a/testsuite/pol/testpkgs/misc/test_polcore.src b/testsuite/pol/testpkgs/misc/test_polcore.src index a96961434..0de1fa1e8 100644 --- a/testsuite/pol/testpkgs/misc/test_polcore.src +++ b/testsuite/pol/testpkgs/misc/test_polcore.src @@ -8,8 +8,8 @@ program testpolcore() endprogram exported function polcore_memory() - PolCore().internal(2); // memory estimation log - PolCore().internal(5); // memory estimation log (scriptscheduler) - PolCore().internal(6, "scripts/tests.ecl"); // memory estimation log (script) + PolCore().internal( 2 ); // memory estimation log + PolCore().internal( 5 ); // memory estimation log (scriptscheduler) + PolCore().internal( 6, "scripts/tests.ecl" ); // memory estimation log (script) return 1; endfunction diff --git a/testsuite/pol/testpkgs/misc/test_polsystem.src b/testsuite/pol/testpkgs/misc/test_polsystem.src index d5548e210..07e97cca3 100644 --- a/testsuite/pol/testpkgs/misc/test_polsystem.src +++ b/testsuite/pol/testpkgs/misc/test_polsystem.src @@ -9,9 +9,9 @@ program testpolsystem() endprogram exported function test_md5() - var res := MD5Encrypt("Hello World"); - if (res != "b10a8db164e0754105b7a99be72e3fe5") - return ret_error($"failed to generate hash, got {res}"); + var res := MD5Encrypt( "Hello World" ); + if ( res != "b10a8db164e0754105b7a99be72e3fe5" ) + return ret_error( $"failed to generate hash, got {res}" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/misc/test_www.src b/testsuite/pol/testpkgs/misc/test_www.src index a4d73c38d..ab2902f77 100644 --- a/testsuite/pol/testpkgs/misc/test_www.src +++ b/testsuite/pol/testpkgs/misc/test_www.src @@ -5,127 +5,130 @@ program test_httprequest() return 1; endprogram -function createUrl(order) +function createUrl( order ) return $"http://127.0.0.1:5006/pkg/webserver/test.ecl?testPid={GetPid()}&order={order}&status=200&body=Okay&headers=%5B%7B%22name%22%3A%22test1%22%2C%22value%22%3A%22value1%22%7D%5D"; endfunction // Checks if status, headers, and body were written based off expected values -function checkEvent(expected) - var ev := os::wait_for_event(15); - if (!ev) - return ret_error($"www wait_for_event failed, returned {ev}"); +function checkEvent( expected ) + var ev := os::wait_for_event( 15 ); + if ( !ev ) + return ret_error( $"www wait_for_event failed, returned {ev}" ); endif - if (ev.status != expected.status || ev.headers != expected.headers || ev.body != expected.body) - return ret_error($"www event values (status = {ev.status}, headers = {ev.headers}, body = {ev.body}) not as expected (status = {expected.status}, headers = {expected.headers}, body = {expected.body})"); + if ( ev.status != expected.status || ev.headers != expected.headers || ev.body != expected.body ) + return ret_error( $"www event values (status = {ev.status}, headers = {ev.headers}, body = {ev.body}) not as expected (status = {expected.status}, headers = {expected.headers}, body = {expected.body})" ); endif return 1; endfunction exported function test_www_status_headers_body() - var res := HTTPRequest(createUrl("status,headers,body")); - return checkEvent(struct{status := 1, headers := 1, body := 1}); + var res := HTTPRequest( createUrl( "status,headers,body" ) ); + return checkEvent( struct{ status := 1, headers := 1, body := 1 } ); endfunction exported function test_www_status_body_headers() - var res := HTTPRequest(createUrl("status,body,headers")); - return checkEvent(struct{status := 1, headers := error, body := 1}); + var res := HTTPRequest( createUrl( "status,body,headers" ) ); + return checkEvent( struct{ status := 1, headers := error, body := 1 } ); endfunction exported function test_www_headers_status_body() - var res := HTTPRequest(createUrl("headers,status,body")); - return checkEvent(struct{status := error, headers := 1, body := 1}); + var res := HTTPRequest( createUrl( "headers,status,body" ) ); + return checkEvent( struct{ status := error, headers := 1, body := 1 } ); endfunction exported function test_www_headers_body_status() - var res := HTTPRequest(createUrl("headers,body,status")); - return checkEvent(struct{status := error, headers := 1, body := 1}); + var res := HTTPRequest( createUrl( "headers,body,status" ) ); + return checkEvent( struct{ status := error, headers := 1, body := 1 } ); endfunction exported function test_www_body_headers_status() - var res := HTTPRequest(createUrl("body,headers,status")); - return checkEvent(struct{status := error, headers := error, body := 1}); + var res := HTTPRequest( createUrl( "body,headers,status" ) ); + return checkEvent( struct{ status := error, headers := error, body := 1 } ); endfunction exported function test_www_body_status_headers() - var res := HTTPRequest(createUrl("body,status,headers")); - return checkEvent(struct{status := error, headers := error, body := 1}); + var res := HTTPRequest( createUrl( "body,status,headers" ) ); + return checkEvent( struct{ status := error, headers := error, body := 1 } ); endfunction exported function test_www_status_body() - var res := HTTPRequest(createUrl("status,body")); - return checkEvent(struct{status := 1, body := 1}); + var res := HTTPRequest( createUrl( "status,body" ) ); + return checkEvent( struct{ status := 1, body := 1 } ); endfunction exported function test_www_body_status() - var res := HTTPRequest(createUrl("body,status")); - return checkEvent(struct{status := error, body := 1}); + var res := HTTPRequest( createUrl( "body,status" ) ); + return checkEvent( struct{ status := error, body := 1 } ); endfunction exported function test_www_headers_body() - var res := HTTPRequest(createUrl("headers,body")); - return checkEvent(struct{headers := 1, body := 1}); + var res := HTTPRequest( createUrl( "headers,body" ) ); + return checkEvent( struct{ headers := 1, body := 1 } ); endfunction exported function test_www_status_headers() - var res := HTTPRequest(createUrl("status,headers")); - return checkEvent(struct{status := 1, headers := 1}); + var res := HTTPRequest( createUrl( "status,headers" ) ); + return checkEvent( struct{ status := 1, headers := 1 } ); endfunction exported function test_www_headers_status() - var res := HTTPRequest(createUrl("headers,status")); - return checkEvent(struct{status := error, headers := 1}); + var res := HTTPRequest( createUrl( "headers,status" ) ); + return checkEvent( struct{ status := error, headers := 1 } ); endfunction exported function test_www_body_headers() - var res := HTTPRequest(createUrl("body,headers")); - return checkEvent(struct{headers := error, body := 1}); + var res := HTTPRequest( createUrl( "body,headers" ) ); + return checkEvent( struct{ headers := error, body := 1 } ); endfunction // Make sure status code, status text, and content-type are sent even if no Write*() was performed inside script exported function test_www_defaults() - var res := HTTPRequest($"http://127.0.0.1:5006/pkg/webserver/test.ecl", flags := HTTPREQUEST_EXTENDED_RESPONSE); + var res := HTTPRequest( $"http://127.0.0.1:5006/pkg/webserver/test.ecl", + flags := HTTPREQUEST_EXTENDED_RESPONSE ); var actual := res.status; var expected := 200; - if (actual != expected) - return ret_error($"HTTPRequest returned status {actual}, expecting {expected}"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned status {actual}, expecting {expected}" ); endif actual := res.statusText; expected := "OK"; - if (actual != expected) - return ret_error($"HTTPRequest returned statusText '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned statusText '{actual}', expecting '{expected}'" ); endif actual := res.headers["content-type"]; expected := "text/html"; - if (actual != expected) - return ret_error($"HTTPRequest returned headers['content-type'] '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned headers['content-type'] '{actual}', expecting '{expected}'" ); endif return 1; endfunction // Check if Content-Type can be overwritten exported function test_www_custom_content_type() - var res := HTTPRequest($"http://127.0.0.1:5006/pkg/webserver/test.ecl?headers=%5B%7B%22name%22%3A%22content-type%22%2C%22value%22%3A%22text%2Fplain%22%7D%5D", flags := HTTPREQUEST_EXTENDED_RESPONSE); + var res := HTTPRequest( $"http://127.0.0.1:5006/pkg/webserver/test.ecl?headers=%5B%7B%22name%22%3A%22content-type%22%2C%22value%22%3A%22text%2Fplain%22%7D%5D", + flags := HTTPREQUEST_EXTENDED_RESPONSE ); var actual := res.headers["content-type"]; var expected := "text/plain"; - if (actual != expected) - return ret_error($"HTTPRequest returned headers['content-type'] '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned headers['content-type'] '{actual}', expecting '{expected}'" ); endif return 1; endfunction // Check status reason phrase can be overwritten exported function test_www_custom_status_reason() - var res := HTTPRequest($"http://127.0.0.1:5006/pkg/webserver/test.ecl?status=200&statusText=Alright", flags := HTTPREQUEST_EXTENDED_RESPONSE); + var res := HTTPRequest( $"http://127.0.0.1:5006/pkg/webserver/test.ecl?status=200&statusText=Alright", + flags := HTTPREQUEST_EXTENDED_RESPONSE ); var actual := res.statusText; var expected := "Alright"; - if (actual != expected) - return ret_error($"HTTPRequest returned statusText '{actual}', expecting '{expected}'"); + if ( actual != expected ) + return ret_error( $"HTTPRequest returned statusText '{actual}', expecting '{expected}'" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/misc/textcmd/test/dummycmd.src b/testsuite/pol/testpkgs/misc/textcmd/test/dummycmd.src index f77cc9f5f..983c9f2f0 100644 --- a/testsuite/pol/testpkgs/misc/textcmd/test/dummycmd.src +++ b/testsuite/pol/testpkgs/misc/textcmd/test/dummycmd.src @@ -1,4 +1,4 @@ -program dummy(unused who, unused arg) +program dummy( unused who, unused arg ) return 1; endprogram diff --git a/testsuite/pol/testpkgs/npc/ai_enteredarea.src b/testsuite/pol/testpkgs/npc/ai_enteredarea.src index aeca1ec17..ed094367e 100644 --- a/testsuite/pol/testpkgs/npc/ai_enteredarea.src +++ b/testsuite/pol/testpkgs/npc/ai_enteredarea.src @@ -5,32 +5,30 @@ use npc; include "sysevent"; program enteredarea() - var me := self(); - var who_entered := array{}; - var who_left := array{}; - - var evmask_txt := me.getprop("evmask"); - - var evmask; - case(evmask_txt) - "onlynpc": evmask := EVMASK_ONLY_NPC; - "onlypc": evmask := EVMASK_ONLY_PC; - default: evmask := EVMASK_ALL; - endcase - - EnableEvents(SYSEVENT_ENTEREDAREA | SYSEVENT_LEFTAREA, 10, evmask); - - me.setprop("ready", 1); - - while(me) - var ev := wait_for_event(5); - case (ev.type) - SYSEVENT_ENTEREDAREA: - who_entered.append(ev.source.serial); - me.setprop("who_entered", who_entered); - SYSEVENT_LEFTAREA: - who_left.append(ev.source.serial); - me.setprop("who_left", who_left); - endcase - endwhile + var me := self(); + var who_entered := array{}; + var who_left := array{}; + + var evmask_txt := me.getprop( "evmask" ); + + var evmask; + case ( evmask_txt ) + "onlynpc": evmask := EVMASK_ONLY_NPC; + "onlypc": evmask := EVMASK_ONLY_PC; + default: evmask := EVMASK_ALL; + endcase + + EnableEvents( SYSEVENT_ENTEREDAREA | SYSEVENT_LEFTAREA, 10, evmask ); + + me.setprop( "ready", 1 ); + + while ( me ) + var ev := wait_for_event( 5 ); + case ( ev.type ) + SYSEVENT_ENTEREDAREA: + who_entered.append( ev.source.serial ); + me.setprop( "who_entered", who_entered ); + SYSEVENT_LEFTAREA: who_left.append( ev.source.serial ); me.setprop( "who_left", who_left ); + endcase + endwhile endprogram diff --git a/testsuite/pol/testpkgs/npc/ai_movement.src b/testsuite/pol/testpkgs/npc/ai_movement.src index a1fefacf2..5f588adc4 100644 --- a/testsuite/pol/testpkgs/npc/ai_movement.src +++ b/testsuite/pol/testpkgs/npc/ai_movement.src @@ -2,19 +2,19 @@ use npc; use os; program ai() - var me:=Self(); + var me := Self(); - var x:=100; - var y:=100; - if (me.x != x || me.y != y) - me.setprop("testerror","wrong start coords"); + var x := 100; + var y := 100; + if ( me.x != x || me.y != y ) + me.setprop( "testerror", "wrong start coords" ); return; endif - var res:=Move("N"); - if (!res || me.x!=100 || me.y != 99) - me.setprop("testerror","Failed to move N: {}: {},{}".format(res,me.x,me.y)); + var res := Move( "N" ); + if ( !res || me.x != 100 || me.y != 99 ) + me.setprop( "testerror", "Failed to move N: {}: {},{}".format( res, me.x, me.y ) ); return; endif - + me.kill(); endprogram diff --git a/testsuite/pol/testpkgs/npc/ai_speech.src b/testsuite/pol/testpkgs/npc/ai_speech.src index 57b7d68af..944e6ab64 100644 --- a/testsuite/pol/testpkgs/npc/ai_speech.src +++ b/testsuite/pol/testpkgs/npc/ai_speech.src @@ -5,26 +5,26 @@ use uo; const SYSEVENT_SPEECH := 0x00000001; program ai() - EnableEvents(SYSEVENT_SPEECH, 12); + EnableEvents( SYSEVENT_SPEECH, 12 ); - var queue_size := GetObjProperty(Self(), "EventSize"); - if (queue_size != error) - Set_Event_Queue_Size(queue_size); + var queue_size := GetObjProperty( Self(), "EventSize" ); + if ( queue_size != error ) + Set_Event_Queue_Size( queue_size ); endif - while (1) + while ( 1 ) // We use wait_for_event(0) with Sleep() because events are not queued if // the script is _actively_ waiting for events. This forces queuing in order to // test issues with queued events. - var ev := os::wait_for_event(0); + var ev := os::wait_for_event( 0 ); - case(ev.type) + case ( ev.type ) SYSEVENT_SPEECH: var tokens := ev.tokens; tokens.sort(); // This needs to match what's tested in test_client's say_something_with_tokens - Say($"source=[npc] text=[{ev.text}] tokens=[{tokens}]"); + Say( $"source=[npc] text=[{ev.text}] tokens=[{tokens}]" ); endcase - Sleep(1); + Sleep( 1 ); endwhile endprogram diff --git a/testsuite/pol/testpkgs/npc/cleanup.src b/testsuite/pol/testpkgs/npc/cleanup.src index 0cdaf05c7..fe1d2ab78 100644 --- a/testsuite/pol/testpkgs/npc/cleanup.src +++ b/testsuite/pol/testpkgs/npc/cleanup.src @@ -1,8 +1,8 @@ use uo; -foreach mob in (listmobilesinbox(0,0,-200,10000,10000,2000)) +foreach mob in ( listmobilesinbox( 0, 0, -200, 10000, 10000, 2000 ) ) mob.kill(); endforeach -foreach item in (listitemsinboxofobjtype(0x2006,0,0,-200,10000,10000,2000)) - destroyitem(item); +foreach item in ( listitemsinboxofobjtype( 0x2006, 0, 0, -200, 10000, 10000, 2000 ) ) + destroyitem( item ); endforeach diff --git a/testsuite/pol/testpkgs/npc/test_npc.src b/testsuite/pol/testpkgs/npc/test_npc.src index a4f4ccfdc..f4b22b9be 100644 --- a/testsuite/pol/testpkgs/npc/test_npc.src +++ b/testsuite/pol/testpkgs/npc/test_npc.src @@ -8,207 +8,208 @@ program npc_ai() endprogram exported function npc_ai_movement() - var npc:=CreateNPCFromTemplate(":testnpc:test_movement",100,100,0); - if (!npc) - return ret_error("Could not create NPC: "+npc); + var npc := CreateNPCFromTemplate( ":testnpc:test_movement", 100, 100, 0 ); + if ( !npc ) + return ret_error( "Could not create NPC: " + npc ); endif - while(1) - sleepms(10); - if (!npc.process) - if (!npc) + while ( 1 ) + sleepms( 10 ); + if ( !npc.process ) + if ( !npc ) break; endif - return ret_error(npc.getprop("testerror")); + return ret_error( npc.getprop( "testerror" ) ); endif endwhile return 1; endfunction -function wait_for_prop(npc, propname, max_try := 50) - while(npc and max_try > 0) - sleepms(10); - max_try--; - var prop := npc.getprop(propname); - if (prop.errortext == "Property not found") - continue; - endif - return prop; - endwhile - return ret_error("Timeout waiting for {} on serial {}".format(propname, npc.serial)); +function wait_for_prop( npc, propname, max_try := 50 ) + while ( npc and max_try > 0 ) + sleepms( 10 ); + max_try--; + var prop := npc.getprop( propname ); + if ( prop.errortext == "Property not found" ) + continue; + endif + return prop; + endwhile + return ret_error( "Timeout waiting for {} on serial {}".format( propname, npc.serial ) ); endfunction exported function npc_enteredarea() - return npc_test_areaevents(":testnpc:test_enteredarea", 1); + return npc_test_areaevents( ":testnpc:test_enteredarea", 1 ); endfunction exported function npc_enteredarea_npconly() - return npc_test_areaevents(":testnpc:test_enteredarea_onlynpc", 1); + return npc_test_areaevents( ":testnpc:test_enteredarea_onlynpc", 1 ); endfunction exported function npc_enteredarea_pconly() - return npc_test_areaevents(":testnpc:test_enteredarea_onlypc", 0); + return npc_test_areaevents( ":testnpc:test_enteredarea_onlypc", 0 ); endfunction -function npc_test_areaevents(template, expected_to_see) - var x := 100; - var y := 100; - var range := 10; // defined in ai_enteredarea.src +function npc_test_areaevents( template, expected_to_see ) + var x := 100; + var y := 100; + var range := 10; // defined in ai_enteredarea.src - var npc := CreateNPCFromTemplate(template,x,y,0); - if (!npc) - return ret_error("Could not create NPC: "+npc); - endif - - var ready := wait_for_prop(npc, "ready"); - if (ready.errortext) - return ready; - endif - - // test if it can see npcs created at the four borders of the event range - var probe_npc1 := CreateNPCFromTemplate(":testnpc:probe_npc",x+range,y+range,0); - var probe_npc2 := CreateNPCFromTemplate(":testnpc:probe_npc",x-range,y-range,0); - var probe_npc3 := CreateNPCFromTemplate(":testnpc:probe_npc",x-range,y+range,0); - var probe_npc4 := CreateNPCFromTemplate(":testnpc:probe_npc",x+range,y-range,0); - - // test if it CANT see npcs created right outside the border of the event range - var probe_npc1_notseen := CreateNPCFromTemplate(":testnpc:probe_npc",x+range,y+range+1,0); - var probe_npc2_notseen := CreateNPCFromTemplate(":testnpc:probe_npc",x-range,y-range-1,0); - var probe_npc3_notseen := CreateNPCFromTemplate(":testnpc:probe_npc",x-range-1,y+range,0); - var probe_npc4_notseen := CreateNPCFromTemplate(":testnpc:probe_npc",x+range+1,y-range,0); - - // test if it can see an npc created outside, then moved in - var probe_npc_outside_then_in := CreateNPCFromTemplate(":testnpc:probe_npc",x+range+10,y-range-10,0); - MoveObjectToLocation(probe_npc_outside_then_in, x+range-2, y+range-2, 0); - - // the order matters - var in_range_npcs := { - probe_npc1.serial, - probe_npc2.serial, - probe_npc3.serial, - probe_npc4.serial, - probe_npc_outside_then_in.serial - }; - var nExpected := in_range_npcs.size(); - - if (!expected_to_see) - var who_entered := wait_for_prop(npc, "who_entered", max_try := 3); - if (who_entered.errortext) - if (who_entered.errortext["Timeout waiting for"]) - //expected - go on - else - return who_entered; - endif - elseif (who_entered) - return ret_error("NPC saw other NPCs entering but shouldnt"); - else - return ret_error("NPC did something odd: " + CStr(who_entered)); - endif + var npc := CreateNPCFromTemplate( template, x, y, 0 ); + if ( !npc ) + return ret_error( "Could not create NPC: " + npc ); + endif + + var ready := wait_for_prop( npc, "ready" ); + if ( ready.errortext ) + return ready; + endif + + // test if it can see npcs created at the four borders of the event range + var probe_npc1 := CreateNPCFromTemplate( ":testnpc:probe_npc", x + range, y + range, 0 ); + var probe_npc2 := CreateNPCFromTemplate( ":testnpc:probe_npc", x - range, y - range, 0 ); + var probe_npc3 := CreateNPCFromTemplate( ":testnpc:probe_npc", x - range, y + range, 0 ); + var probe_npc4 := CreateNPCFromTemplate( ":testnpc:probe_npc", x + range, y - range, 0 ); + + // test if it CANT see npcs created right outside the border of the event range + var probe_npc1_notseen := CreateNPCFromTemplate( ":testnpc:probe_npc", x + range, y + range + 1, + 0 ); + var probe_npc2_notseen := CreateNPCFromTemplate( ":testnpc:probe_npc", x - range, y - range - 1, + 0 ); + var probe_npc3_notseen := CreateNPCFromTemplate( ":testnpc:probe_npc", x - range - 1, y + range, + 0 ); + var probe_npc4_notseen := CreateNPCFromTemplate( ":testnpc:probe_npc", x + range + 1, y - range, + 0 ); + + // test if it can see an npc created outside, then moved in + var probe_npc_outside_then_in := CreateNPCFromTemplate( ":testnpc:probe_npc", x + range + 10, + y - range - 10, 0 ); + MoveObjectToLocation( probe_npc_outside_then_in, x + range - 2, y + range - 2, 0 ); + + // the order matters + var in_range_npcs := { probe_npc1.serial, probe_npc2.serial, probe_npc3.serial, + probe_npc4.serial, probe_npc_outside_then_in.serial }; + var nExpected := in_range_npcs.size(); + + if ( !expected_to_see ) + var who_entered := wait_for_prop( npc, "who_entered", max_try := 3 ); + if ( who_entered.errortext ) + if ( who_entered.errortext["Timeout waiting for"] ) + // expected - go on + else + return who_entered; + endif + elseif ( who_entered ) + return ret_error( "NPC saw other NPCs entering but shouldnt" ); else - var who_entered := wait_for_prop(npc, "who_entered"); - if (who_entered.errortext) - return who_entered; - endif - - if (who_entered.size() < nExpected) - return ret_error("NPC only received {} ENTEREDAREA events out of {}.".format(who_entered.size(), nExpected)); - endif - - foreach serial in who_entered - var idx := serial in in_range_npcs; - if (!idx) - return ret_error("Unexpected NPC was seen entering: {}".format(serial)); - endif - if (_serial_iter != idx) - return ret_error("NPC seen entering out of order: {} / {}".format(idx, _serial_iter)); - endif - endforeach - endif - - // test if it can see them leaving - MoveObjectToLocation(probe_npc1, x+range+1, y+range+1, 0); - MoveObjectToLocation(probe_npc2, x-range-1, y-range-1, 0); - MoveObjectToLocation(probe_npc3, x-range-1, y+range+1, 0); - MoveObjectToLocation(probe_npc4, x+range+1, y-range-1, 0); - // this one too - MoveObjectToLocation(probe_npc_outside_then_in, x+range+20, y+range+20, 0); - - // test that it DOESNT see them leaving - MoveObjectToLocation(probe_npc1_notseen, x+range+10, y+range+10, 0); - MoveObjectToLocation(probe_npc2_notseen, x-range-10, y-range-10, 0); - MoveObjectToLocation(probe_npc3_notseen, x-range-10, y+range+10, 0); - MoveObjectToLocation(probe_npc4_notseen, x+range+10, y-range-10, 0); - - - if (!expected_to_see) - var who_left := wait_for_prop(npc, "who_left", max_try := 3); - if (who_left.errortext) - if (who_left.errortext["Timeout waiting for"]) - //expected - go on - else - return who_left; - endif - elseif (who_left) - return ret_error("NPC saw other NPCs leaving but shouldnt"); - else - return ret_error("NPC did something odd: " + CStr(who_left)); - endif - else - var who_left := wait_for_prop(npc, "who_left"); - if (who_left.errortext) - return who_left; - endif - - if (who_left.size() < nExpected) - return ret_error("NPC only received {} LEFTAREA events out of {}.".format(who_left.size(), nExpected)); - endif - - foreach serial in who_left - var idx := serial in in_range_npcs; - if (!idx) - return ret_error("Unexpected NPC was seen leaving: {}".format(serial)); - endif - if (_serial_iter != idx) - return ret_error("NPC seen leaving out of order: {} / {}".format(idx, _serial_iter)); - endif - endforeach + return ret_error( "NPC did something odd: " + CStr( who_entered ) ); endif - - npc.kill(); - - probe_npc1.kill(); - probe_npc2.kill(); - probe_npc3.kill(); - probe_npc4.kill(); - - probe_npc1_notseen.kill(); - probe_npc2_notseen.kill(); - probe_npc3_notseen.kill(); - probe_npc4_notseen.kill(); - - probe_npc_outside_then_in.kill(); - - return 1; + else + var who_entered := wait_for_prop( npc, "who_entered" ); + if ( who_entered.errortext ) + return who_entered; + endif + + if ( who_entered.size() < nExpected ) + return ret_error( "NPC only received {} ENTEREDAREA events out of {}.".format( who_entered.size(), + nExpected ) ); + endif + + foreach serial in who_entered + var idx := serial in in_range_npcs; + if ( !idx ) + return ret_error( "Unexpected NPC was seen entering: {}".format( serial ) ); + endif + if ( _serial_iter != idx ) + return ret_error( "NPC seen entering out of order: {} / {}".format( idx, _serial_iter ) ); + endif + endforeach + endif + + // test if it can see them leaving + MoveObjectToLocation( probe_npc1, x + range + 1, y + range + 1, 0 ); + MoveObjectToLocation( probe_npc2, x - range - 1, y - range - 1, 0 ); + MoveObjectToLocation( probe_npc3, x - range - 1, y + range + 1, 0 ); + MoveObjectToLocation( probe_npc4, x + range + 1, y - range - 1, 0 ); + // this one too + MoveObjectToLocation( probe_npc_outside_then_in, x + range + 20, y + range + 20, 0 ); + + // test that it DOESNT see them leaving + MoveObjectToLocation( probe_npc1_notseen, x + range + 10, y + range + 10, 0 ); + MoveObjectToLocation( probe_npc2_notseen, x - range - 10, y - range - 10, 0 ); + MoveObjectToLocation( probe_npc3_notseen, x - range - 10, y + range + 10, 0 ); + MoveObjectToLocation( probe_npc4_notseen, x + range + 10, y - range - 10, 0 ); + + if ( !expected_to_see ) + var who_left := wait_for_prop( npc, "who_left", max_try := 3 ); + if ( who_left.errortext ) + if ( who_left.errortext["Timeout waiting for"] ) + // expected - go on + else + return who_left; + endif + elseif ( who_left ) + return ret_error( "NPC saw other NPCs leaving but shouldnt" ); + else + return ret_error( "NPC did something odd: " + CStr( who_left ) ); + endif + else + var who_left := wait_for_prop( npc, "who_left" ); + if ( who_left.errortext ) + return who_left; + endif + + if ( who_left.size() < nExpected ) + return ret_error( "NPC only received {} LEFTAREA events out of {}.".format( who_left.size(), + nExpected ) ); + endif + + foreach serial in who_left + var idx := serial in in_range_npcs; + if ( !idx ) + return ret_error( "Unexpected NPC was seen leaving: {}".format( serial ) ); + endif + if ( _serial_iter != idx ) + return ret_error( "NPC seen leaving out of order: {} / {}".format( idx, _serial_iter ) ); + endif + endforeach + endif + + npc.kill(); + + probe_npc1.kill(); + probe_npc2.kill(); + probe_npc3.kill(); + probe_npc4.kill(); + + probe_npc1_notseen.kill(); + probe_npc2_notseen.kill(); + probe_npc3_notseen.kill(); + probe_npc4_notseen.kill(); + + probe_npc_outside_then_in.kill(); + + return 1; endfunction exported function test_load_desc_props() - var npc:=CreateNPCFromTemplate(":testnpc:load_npc",100,100,0); - if (!npc) - return ret_error("Could not create NPC: "+npc); + var npc := CreateNPCFromTemplate( ":testnpc:load_npc", 100, 100, 0 ); + if ( !npc ) + return ret_error( "Could not create NPC: " + npc ); endif - if (!npc.weapon.getprop("weaponcprop")) + if ( !npc.weapon.getprop( "weaponcprop" ) ) npc.kill(); - return ret_error("Failed to load weapon cprop"); + return ret_error( "Failed to load weapon cprop" ); endif - if (!npc.shield.getprop("shieldcprop")) + if ( !npc.shield.getprop( "shieldcprop" ) ) npc.kill(); - return ret_error("Failed to load shield cprop"); + return ret_error( "Failed to load shield cprop" ); endif - if (!npc.no_drop_exception) + if ( !npc.no_drop_exception ) npc.kill(); - return ret_error("Failed to load nodropexception"); + return ret_error( "Failed to load nodropexception" ); endif npc.kill(); @@ -217,23 +218,23 @@ endfunction exported function test_npc_realm_move() // crashed by wrongly converting coordinates between realms - var npc:=CreateNPCFromTemplate(":testnpc:load_npc",100,100,0); - if (!npc) - return ret_error("Could not create NPC: "+npc); + var npc := CreateNPCFromTemplate( ":testnpc:load_npc", 100, 100, 0 ); + if ( !npc ) + return ret_error( "Could not create NPC: " + npc ); endif - MoveObjectToLocation(npc,1000,1000,0,"britannia2",MOVEOBJECT_FORCELOCATION); - if (npc.x != 1000 || npc.y != 1000 || npc.realm != "britannia2") - var res:=$"Failed initial move: {npc.x},{npc.y},{npc.realm}"; + MoveObjectToLocation( npc, 1000, 1000, 0, "britannia2", MOVEOBJECT_FORCELOCATION ); + if ( npc.x != 1000 || npc.y != 1000 || npc.realm != "britannia2" ) + var res := $"Failed initial move: {npc.x},{npc.y},{npc.realm}"; npc.kill(); - return ret_error(res); + return ret_error( res ); endif - MoveObjectToLocation(npc,10,10,0,"britannia",MOVEOBJECT_FORCELOCATION); - if (npc.x != 10 || npc.y != 10 || npc.realm != "britannia") - var res:=$"Failed to move: {npc.x},{npc.y},{npc.realm}"; + MoveObjectToLocation( npc, 10, 10, 0, "britannia", MOVEOBJECT_FORCELOCATION ); + if ( npc.x != 10 || npc.y != 10 || npc.realm != "britannia" ) + var res := $"Failed to move: {npc.x},{npc.y},{npc.realm}"; npc.kill(); - return ret_error(res); + return ret_error( res ); endif npc.kill(); @@ -244,20 +245,20 @@ endfunction Test that with WarmodeInhibitsRegen=3 (NPCs Only), an _NPC_ in war mode _will not_ regenerate health. */ exported function npc_warmodeinhibitsregen() - var npc:=CreateNPCFromTemplate(":testnpc:load_npc",100,100,0); - if (!npc) - return ret_error("Could not create NPC: "+npc); + var npc := CreateNPCFromTemplate( ":testnpc:load_npc", 100, 100, 0 ); + if ( !npc ) + return ret_error( "Could not create NPC: " + npc ); endif - npc.setwarmode(1); - SetVital( npc, "Life", GetVital( npc, "Life" ) / 2); + npc.setwarmode( 1 ); + SetVital( npc, "Life", GetVital( npc, "Life" ) / 2 ); var damaged_health := GetVital( npc, "Life" ); - Sleep(6); + Sleep( 6 ); var waited_health := GetVital( npc, "Life" ); npc.kill(); - if (damaged_health != waited_health) - return ret_error($"NPC health changed between sleeping: {damaged_health} -> {waited_health}"); + if ( damaged_health != waited_health ) + return ret_error( $"NPC health changed between sleeping: {damaged_health} -> {waited_health}" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/restart/test_account.src b/testsuite/pol/testpkgs/restart/test_account.src index 5f6d6510e..445a90f23 100644 --- a/testsuite/pol/testpkgs/restart/test_account.src +++ b/testsuite/pol/testpkgs/restart/test_account.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_account() return 1; @@ -11,43 +11,52 @@ endprogram // save/load test for things in Account class exported function load_save_account() - var props:={ -// {"Name", {"",1}}, + var props := { // {"Name", {"",1}}, // {"Password", {"",1}}, - {"PasswordHash", {"usernamepasswordhash",MD5Encrypt("restart_accountmypass")}}, - {"Enabled", {"enabled",0}}, -// {"DefaultPrivs", {"",1}}, - {"DefaultCmdLevel", {"defaultcmdlevel",1}}, - {"UOExpansion", {"uo_expansion","SE"}} - }; + { "PasswordHash", + { "usernamepasswordhash", MD5Encrypt( "restart_accountmypass" ) + } + }, + { + "Enabled", + { "enabled", 0 } + }, // {"DefaultPrivs", {"",1}}, + { + "DefaultCmdLevel", + { "defaultcmdlevel", 1 } + }, + { + "UOExpansion", + { "uo_expansion", "SE" } + } }; - if (testrun == 1) - var acc:=CreateAccount("restart_account","mypass",0); - if (!acc) - return ret_error($"failed to create account {acc}"); + if ( testrun == 1 ) + var acc := CreateAccount( "restart_account", "mypass", 0 ); + if ( !acc ) + return ret_error( $"failed to create account {acc}" ); endif - acc.setdefaultcmdlevel(1); - acc.set_uo_expansion("SE"); - acc.addcharacter(1); - acc.setprop("test",1); + acc.setdefaultcmdlevel( 1 ); + acc.set_uo_expansion( "SE" ); + acc.addcharacter( 1 ); + acc.setprop( "test", 1 ); else - var acc := FindAccount("restart_account"); - if (!acc) - return ret_error("failed to find account"); + var acc := FindAccount( "restart_account" ); + if ( !acc ) + return ret_error( "failed to find account" ); endif foreach prop in props - var val:=acc.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := acc.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - var chr:=acc.getcharacter(1); - if (!chr) - return ret_error($"failed to load chr {chr}"); + var chr := acc.getcharacter( 1 ); + if ( !chr ) + return ret_error( $"failed to load chr {chr}" ); endif - if (acc.getprop("test")!=1) - return ret_error($"failed to load cprop :"+acc.getprop("test")); + if ( acc.getprop( "test" ) != 1 ) + return ret_error( $"failed to load cprop :" + acc.getprop( "test" ) ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_armor.src b/testsuite/pol/testpkgs/restart/test_armor.src index d45445c4b..2edd7a34e 100644 --- a/testsuite/pol/testpkgs/restart/test_armor.src +++ b/testsuite/pol/testpkgs/restart/test_armor.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_armor() return 1; @@ -11,36 +11,39 @@ endprogram // save/load test for things in Armor exported function load_save_armor() - var props:={ - {"AR_mod", {"ar_mod",12}}, - {"OnHitScript", {"onhitscript",":testrestart:myhitscript"}} - }; + var props := { { "AR_mod", + { "ar_mod", 12 } + }, + { + "OnHitScript", + { "onhitscript", ":testrestart:myhitscript" } + } }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, "restart_test_armor",1,"britannia2"); - item.name:="load_save_armor"; - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, "restart_test_armor", 1, "britannia2" ); + item.name := "load_save_armor"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_armor", item.serial); + SetGlobalProperty( "test_item_storage_armor", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach else - var serial := GetGlobalProperty("test_item_storage_armor"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_armor" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach endif diff --git a/testsuite/pol/testpkgs/restart/test_boat.src b/testsuite/pol/testpkgs/restart/test_boat.src index ab735fdfb..0edc024fc 100644 --- a/testsuite/pol/testpkgs/restart/test_boat.src +++ b/testsuite/pol/testpkgs/restart/test_boat.src @@ -2,7 +2,7 @@ use os; use uo; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_boat() return 1; @@ -10,44 +10,42 @@ endprogram // save/load test for things in Boat class exported function load_save_boat() - var props:={ - {"MultiID", {"multiid",0x0}} - }; + var props := { { "MultiID", { "multiid", 0x0 } } }; - if (testrun == 1) - var boat:=CreateMultiAtLocation(10,50,-4,0x11000); - boat.name:="load_save_boat"; - if (!boat) - return ret_error($"failed to create boat {boat}"); + if ( testrun == 1 ) + var boat := CreateMultiAtLocation( 10, 50, -4, 0x11000 ); + boat.name := "load_save_boat"; + if ( !boat ) + return ret_error( $"failed to create boat {boat}" ); endif - var npc:=CreateNPCFromTemplate(":testrestart:restart_npc",9,50,0); - boat.setprop("npc",npc.serial); - SetGlobalProperty("test_storage_boat", boat.serial); + var npc := CreateNPCFromTemplate( ":testrestart:restart_npc", 9, 50, 0 ); + boat.setprop( "npc", npc.serial ); + SetGlobalProperty( "test_storage_boat", boat.serial ); else - var serial := GetGlobalProperty("test_storage_boat"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_storage_boat" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var boat := SystemFindObjectBySerial(serial); - if (!boat) - return ret_error($"Boat with serial {serial:#x} does not exists: {boat})"); + var boat := SystemFindObjectBySerial( serial ); + if ( !boat ) + return ret_error( $"Boat with serial {serial:#x} does not exists: {boat})" ); endif foreach prop in props - var val:=boat.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := boat.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - if (len(boat.components)!=4) - return ret_error($"invalid components: {boat.components}"); + if ( len( boat.components ) != 4 ) + return ret_error( $"invalid components: {boat.components}" ); endif - if (len(boat.mobiles)!=1) - return ret_error($"invalid traveller size: {boat.mobiles}"); + if ( len( boat.mobiles ) != 1 ) + return ret_error( $"invalid traveller size: {boat.mobiles}" ); endif - if (boat.mobiles[1].serial != boat.getprop("npc")) - return ret_error($"invalid traveller {boat.mobiles[1].serial} != "+boat.getprop("npc")); + if ( boat.mobiles[1].serial != boat.getprop( "npc" ) ) + return ret_error( $"invalid traveller {boat.mobiles[1].serial} != " + boat.getprop( "npc" ) ); endif endif diff --git a/testsuite/pol/testpkgs/restart/test_char.src b/testsuite/pol/testpkgs/restart/test_char.src index 1cacc393d..8697fc407 100644 --- a/testsuite/pol/testpkgs/restart/test_char.src +++ b/testsuite/pol/testpkgs/restart/test_char.src @@ -4,7 +4,7 @@ use attributes; use vitals; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_char() return 1; @@ -12,146 +12,209 @@ endprogram // save/load test for things in Character class exported function load_save_character() - var props:={ -// {"Account", {"",1}}, // indirect + var props := { // {"Account", {"",1}}, // indirect // {"CharIdx", {"",1}}, // indirect - {"CmdLevel", {"cmdlevel",1}}, - {"Concealed", {"concealed",1}}, - {"TrueColor", {"truecolor",105}}, - {"TrueObjtype", {"trueobjtype",0x166}}, -// {"RegisteredHouse", {"",1}}, - {"Gender", {"gender",1}}, - {"Race", {"race",RACE_GARGOYLE}}, -// {"Dead", {"",1}}, // other test - {"MountedSteps", {"mountedsteps",7}}, - {"Hidden", {"hidden",1}}, - {"Frozen", {"frozen",1}}, - {"MovementWalkMod", {"movecost_walk_mod",8.1}}, - {"MovementRunMod", {"movecost_run_mod",8.2}}, -{"MovementWalkMountedMod", {"movecost_walk_mounted_mod",8.3}}, - {"MovementRunMountedMod", {"movecost_run_mounted_mod",8.4}}, - {"CarryingCapacityMod", {"carrying_capacity_mod",9}}, -// {"pAttr->name", {"",1}}, // functions + { "CmdLevel", + { "cmdlevel", 1 } + }, + { + "Concealed", + { "concealed", 1 } + }, + { + "TrueColor", + { "truecolor", 105 } + }, + { + "TrueObjtype", + { "trueobjtype", 0x166 } + }, // {"RegisteredHouse", {"",1}}, + { + "Gender", + { "gender", 1 } + }, + { + "Race", + { "race", RACE_GARGOYLE } + }, // {"Dead", {"",1}}, // other test + { + "MountedSteps", + { "mountedsteps", 7 } + }, + { + "Hidden", + { "hidden", 1 } + }, + { + "Frozen", + { "frozen", 1 } + }, + { + "MovementWalkMod", + { "movecost_walk_mod", 8.1 } + }, + { + "MovementRunMod", + { "movecost_run_mod", 8.2 } + }, + { + "MovementWalkMountedMod", + { "movecost_walk_mounted_mod", 8.3 } + }, + { + "MovementRunMountedMod", + { "movecost_run_mounted_mod", 8.4 } + }, + { + "CarryingCapacityMod", + { "carrying_capacity_mod", 9 } + }, // {"pAttr->name", {"",1}}, // functions // {"pVital->name", {"",1}}, // npc? - {"Statcap", {"statcap",256}}, - {"Skillcap", {"skillcap",701}}, - {"Followers", {"followers",9}}, - {"FollowersMax", {"followers_max",10}}, - {"Tithing", {"tithing",11}}, -// {"MoveMode", {"",1}}, + { + "Statcap", + { "statcap", 256 } + }, + { + "Skillcap", + { "skillcap", 701 } + }, + { + "Followers", + { "followers", 9 } + }, + { + "FollowersMax", + { "followers_max", 10 } + }, + { + "Tithing", + { "tithing", 11 } + }, // {"MoveMode", {"",1}}, // {"Privs", {"",1}}, //method // {"Settings", {"",1}}, //method // {"CreatedAt", {"",1}}, // {"SquelchedUntil", {"",1}}, //method // {"DeafenedUntil", {"",1}}, //method - {"TitlePrefix", {"title_prefix","myprefix"}}, - {"TitleSuffix", {"title_suffix","mysuffix"}}, - {"TitleGuild", {"title_guild","myguild"}}, - {"TitleRace", {"title_race","myrace"}}, - {"Murderer", {"murderer",1}} -// {"PartyCanLoot", {"",1}}, // client only settable? -// {"Reportable", {"",1}}, // other test -// {"LastCorpse", {"",1}}, // other test - }; + { + "TitlePrefix", + { "title_prefix", "myprefix" } + }, + { + "TitleSuffix", + { "title_suffix", "mysuffix" } + }, + { + "TitleGuild", + { "title_guild", "myguild" } + }, + { + "TitleRace", + { "title_race", "myrace" } + }, + { + "Murderer", + { "murderer", 1 } + } // {"PartyCanLoot", {"",1}}, // client only settable? + // {"Reportable", {"",1}}, // other test + // {"LastCorpse", {"",1}}, // other test + }; - if (testrun == 1) - var chr:=createAccountWithChar("restart_test_char", "pass"); - if (!chr) + if ( testrun == 1 ) + var chr := createAccountWithChar( "restart_test_char", "pass" ); + if ( !chr ) return chr; endif foreach prop in props - chr.set_member(prop[2][1],prop[2][2]); + chr.set_member( prop[2][1], prop[2][2] ); endforeach - grantprivilege(chr,"hiddenattack"); - grantprivilege(chr,"runwhilestealth"); - chr.enable("hiddenattack"); - SetAttributeBaseValue(chr,"Strength",900); - SetAttributeCap(chr,"Strength",950); - SetAttributeLock(chr,"Strength",ATTRIBUTE_LOCK_DOWN); - SetAttributeBaseValue(chr,"INT",901); - SetAttributeCap(chr,"INT",1002); - SetAttributeLock(chr,"INT",ATTRIBUTE_LOCK_LOCKED); + grantprivilege( chr, "hiddenattack" ); + grantprivilege( chr, "runwhilestealth" ); + chr.enable( "hiddenattack" ); + SetAttributeBaseValue( chr, "Strength", 900 ); + SetAttributeCap( chr, "Strength", 950 ); + SetAttributeLock( chr, "Strength", ATTRIBUTE_LOCK_DOWN ); + SetAttributeBaseValue( chr, "INT", 901 ); + SetAttributeCap( chr, "INT", 1002 ); + SetAttributeLock( chr, "INT", ATTRIBUTE_LOCK_LOCKED ); - chr.deaf(300); - chr.squelch(400); + chr.deaf( 300 ); + chr.squelch( 400 ); else - var a:=FindAccount("restart_test_char"); - if (!a) - return ret_error("failed to find account"); + var a := FindAccount( "restart_test_char" ); + if ( !a ) + return ret_error( "failed to find account" ); endif - var chr:=a.getcharacter(1); - if (!chr) - return ret_error("failed to find char"); + var chr := a.getcharacter( 1 ); + if ( !chr ) + return ret_error( "failed to find char" ); endif foreach prop in props - var val:=chr.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := chr.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - if (!chr.enabled("hiddenattack")) - return ret_error("priv not enabled"); + if ( !chr.enabled( "hiddenattack" ) ) + return ret_error( "priv not enabled" ); endif - if (chr.enabled("runwhilestealth")) - return ret_error("priv is enabled"); + if ( chr.enabled( "runwhilestealth" ) ) + return ret_error( "priv is enabled" ); endif - if (chr.privileges().size()!=2) - return ret_error($"wrong number of privs {chr.privileges()}"); + if ( chr.privileges().size() != 2 ) + return ret_error( $"wrong number of privs {chr.privileges()}" ); endif - var v:={ GetAttributeBaseValue(chr,"Strength"), - GetAttributeCap(chr,"Strength"), - GetAttributeLock(chr,"Strength") }; - if (v != {900,950,ATTRIBUTE_LOCK_DOWN}) - return ret_error($"invalid STR values {v}"); + var v := { GetAttributeBaseValue( chr, "Strength" ), GetAttributeCap( + chr, "Strength" ), GetAttributeLock( chr, "Strength" ) }; + if ( v != { 900, 950, ATTRIBUTE_LOCK_DOWN } ) + return ret_error( $"invalid STR values {v}" ); endif - v:={ GetAttributeBaseValue(chr,"INT"), - GetAttributeCap(chr,"INT"), - GetAttributeLock(chr,"INT") }; - if (v != {901,1002,ATTRIBUTE_LOCK_LOCKED}) - return ret_error($"invalid INT values {v}"); + v := { GetAttributeBaseValue( chr, "INT" ), GetAttributeCap( + chr, "INT" ), GetAttributeLock( chr, "INT" ) }; + if ( v != { 901, 1002, ATTRIBUTE_LOCK_LOCKED } ) + return ret_error( $"invalid INT values {v}" ); endif - if (!chr.deafed) - return ret_error("failed to save deaf status"); + if ( !chr.deafed ) + return ret_error( "failed to save deaf status" ); endif - if (!chr.squelched) - return ret_error("failed to save squelch status"); + if ( !chr.squelched ) + return ret_error( "failed to save squelch status" ); endif endif return 1; endfunction exported function load_save_character_dead() - if (testrun == 1) - var chr:=createAccountWithChar("restart_test_chardead", "pass"); - if (!chr) + if ( testrun == 1 ) + var chr := createAccountWithChar( "restart_test_chardead", "pass" ); + if ( !chr ) return chr; endif - var chr1:=createAccountWithChar("restart_test_charkiller", "pass"); - if (!chr1) + var chr1 := createAccountWithChar( "restart_test_charkiller", "pass" ); + if ( !chr1 ) return chr1; endif - chr.kill(chr1); - chr.setprop("testcorpse",chr.getcorpse().serial); + chr.kill( chr1 ); + chr.setprop( "testcorpse", chr.getcorpse().serial ); else - var chr:=FindAccount("restart_test_chardead").getcharacter(1); - if (!chr) - return ret_error("failed to find char"); + var chr := FindAccount( "restart_test_chardead" ).getcharacter( 1 ); + if ( !chr ) + return ret_error( "failed to find char" ); endif - var chr1:=FindAccount("restart_test_charkiller").getcharacter(1); - if (!chr) - return ret_error("failed to find char"); + var chr1 := FindAccount( "restart_test_charkiller" ).getcharacter( 1 ); + if ( !chr ) + return ret_error( "failed to find char" ); endif - if (!chr.dead) - return ret_error("chr is not dead"); + if ( !chr.dead ) + return ret_error( "chr is not dead" ); endif - if (chr.getcorpse().serial != chr.getprop("testcorpse")) - return ret_error("failed to save corpse"); + if ( chr.getcorpse().serial != chr.getprop( "testcorpse" ) ) + return ret_error( "failed to save corpse" ); endif - if (len(chr.reportables)!=1 || chr.reportables[1].killer != chr1) - return ret_error($"Invalid reportables: {chr.reportables}"); + if ( len( chr.reportables ) != 1 || chr.reportables[1].killer != chr1 ) + return ret_error( $"Invalid reportables: {chr.reportables}" ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_container.src b/testsuite/pol/testpkgs/restart/test_container.src index 86a1bad94..db5f5fac2 100644 --- a/testsuite/pol/testpkgs/restart/test_container.src +++ b/testsuite/pol/testpkgs/restart/test_container.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_container() return 1; @@ -11,38 +11,47 @@ endprogram // save/load test for things in Container class exported function load_save_container() - var props:={ - {"Max_Items_mod", {"max_items_mod",10}}, - {"Max_Weight_mod", {"max_weight_mod",11}}, - {"Max_Slots_mod", {"max_slots_mod",12}}, - {"NoDropException", {"no_drop_exception",1}} - }; + var props := { { "Max_Items_mod", + { "max_items_mod", 10 } + }, + { + "Max_Weight_mod", + { "max_weight_mod", 11 } + }, + { + "Max_Slots_mod", + { "max_slots_mod", 12 } + }, + { + "NoDropException", + { "no_drop_exception", 1 } + } }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, "restart_test_container",1,"britannia2"); - item.name:="load_save_container"; - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, "restart_test_container", 1, "britannia2" ); + item.name := "load_save_container"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_container", item.serial); + SetGlobalProperty( "test_item_storage_container", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach else - var serial := GetGlobalProperty("test_item_storage_container"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_container" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach endif diff --git a/testsuite/pol/testpkgs/restart/test_corpse.src b/testsuite/pol/testpkgs/restart/test_corpse.src index 3f803e53a..19bf27263 100644 --- a/testsuite/pol/testpkgs/restart/test_corpse.src +++ b/testsuite/pol/testpkgs/restart/test_corpse.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_corpse() return 1; @@ -11,48 +11,51 @@ endprogram // save/load test for things in Corpse class exported function load_save_corpse() - if (testrun == 1) - var npc:=CreateNPCFromTemplate(":testrestart:restart_npc",100,100,0,0,"britannia2"); - if (!npc) - return ret_error($"failed to create npc {npc}"); + if ( testrun == 1 ) + var npc := CreateNPCFromTemplate( ":testrestart:restart_npc", 100, 100, 0, 0, "britannia2" ); + if ( !npc ) + return ret_error( $"failed to create npc {npc}" ); endif - SetGlobalProperty("test_item_storage_npc_corpse", npc.serial); + SetGlobalProperty( "test_item_storage_npc_corpse", npc.serial ); var npcserial := npc.serial; npc.kill(); var item; - var items:=ListObjectsInBoxOfClass(POLCLASS_CORPSE,100,100,0,100,100,0,"britannia2"); + var items := ListObjectsInBoxOfClass( POLCLASS_CORPSE, 100, 100, 0, 100, 100, 0, "britannia2" ); foreach i in items - if (i.ownerserial == npcserial) - item:=i; + if ( i.ownerserial == npcserial ) + item := i; break; endif endforeach - if (!item) - return ret_error($"failed to get item {items}"); + if ( !item ) + return ret_error( $"failed to get item {items}" ); endif - SetGlobalProperty("test_item_storage_corpse", item.serial); + SetGlobalProperty( "test_item_storage_corpse", item.serial ); else - var serial := GetGlobalProperty("test_item_storage_corpse"); - var npcserial := GetGlobalProperty("test_item_storage_npc_corpse"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_corpse" ); + var npcserial := GetGlobalProperty( "test_item_storage_npc_corpse" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif - var props:={ - {"CorpseType", {"corpsetype",0x190}}, - {"OwnerSerial", {"ownerserial",npcserial}} -// {"TakeContentsToGrave", {"",1} - }; + var props := { { "CorpseType", + { "corpsetype", 0x190 } + }, + { + "OwnerSerial", + { "ownerserial", npcserial } + } // {"TakeContentsToGrave", {"",1} + }; foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach endif diff --git a/testsuite/pol/testpkgs/restart/test_datafile.src b/testsuite/pol/testpkgs/restart/test_datafile.src index 55b52b136..d33fe8f12 100644 --- a/testsuite/pol/testpkgs/restart/test_datafile.src +++ b/testsuite/pol/testpkgs/restart/test_datafile.src @@ -3,81 +3,81 @@ use uo; use datafile; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_datafile() return 1; endprogram exported function load_save_datafile_stringkey() - if (testrun == 1) - var df := CreateDataFile(":TestRestart:dfstring",DF_KEYTYPE_STRING); - if (!df) - return ret_error($"failed to create {df}"); + if ( testrun == 1 ) + var df := CreateDataFile( ":TestRestart:dfstring", DF_KEYTYPE_STRING ); + if ( !df ) + return ret_error( $"failed to create {df}" ); endif - var ele1 := df.createelement("key1"); - var ele2 := df.createelement("key2"); - ele1.setprop("prop1-1",1); - ele1.setprop("prop1-2",2); - ele2.setprop("prop2-1",3); + var ele1 := df.createelement( "key1" ); + var ele2 := df.createelement( "key2" ); + ele1.setprop( "prop1-1", 1 ); + ele1.setprop( "prop1-2", 2 ); + ele2.setprop( "prop2-1", 3 ); else - var df := OpenDataFile(":TestRestart:dfstring"); - if (!df) - return ret_error($"failed to open {df}"); + var df := OpenDataFile( ":TestRestart:dfstring" ); + if ( !df ) + return ret_error( $"failed to open {df}" ); endif - if (len(df.keys())!=2) - return ret_error($"count of keys {df.keys()}!=2"); + if ( len( df.keys() ) != 2 ) + return ret_error( $"count of keys {df.keys()}!=2" ); endif - var ele1 := df.findelement("key1"); - var ele2 := df.findelement("key2"); - if (!ele1 || !ele2) - return ret_error($"elements not found {ele1}/{ele2}"); + var ele1 := df.findelement( "key1" ); + var ele2 := df.findelement( "key2" ); + if ( !ele1 || !ele2 ) + return ret_error( $"elements not found {ele1}/{ele2}" ); endif - if (ele1.getprop("prop1-1")!=1) - return ret_error("prop 1-1 not found "+ele1.getprop("prop1-1")); + if ( ele1.getprop( "prop1-1" ) != 1 ) + return ret_error( "prop 1-1 not found " + ele1.getprop( "prop1-1" ) ); endif - if (ele1.getprop("prop1-2")!=2) - return ret_error("prop 1-2 not found "+ele1.getprop("prop1-1")); + if ( ele1.getprop( "prop1-2" ) != 2 ) + return ret_error( "prop 1-2 not found " + ele1.getprop( "prop1-1" ) ); endif - if (ele2.getprop("prop2-1")!=3) - return ret_error("prop 2-1 not found "+ele2.getprop("prop1-1")); + if ( ele2.getprop( "prop2-1" ) != 3 ) + return ret_error( "prop 2-1 not found " + ele2.getprop( "prop1-1" ) ); endif endif return 1; endfunction exported function load_save_datafile_intkey() - if (testrun == 1) - var df := CreateDataFile(":TestRestart:dfint",DF_KEYTYPE_INTEGER); - if (!df) - return ret_error($"failed to create {df}"); + if ( testrun == 1 ) + var df := CreateDataFile( ":TestRestart:dfint", DF_KEYTYPE_INTEGER ); + if ( !df ) + return ret_error( $"failed to create {df}" ); endif - var ele1 := df.createelement(10); - var ele2 := df.createelement(11); - ele1.setprop("prop1-1",1); - ele1.setprop("prop1-2",2); - ele2.setprop("prop2-1",3); + var ele1 := df.createelement( 10 ); + var ele2 := df.createelement( 11 ); + ele1.setprop( "prop1-1", 1 ); + ele1.setprop( "prop1-2", 2 ); + ele2.setprop( "prop2-1", 3 ); else - var df := OpenDataFile(":TestRestart:dfint"); - if (!df) - return ret_error($"failed to open {df}"); + var df := OpenDataFile( ":TestRestart:dfint" ); + if ( !df ) + return ret_error( $"failed to open {df}" ); endif - if (len(df.keys())!=2) - return ret_error($"count of keys {df.keys()}!=2"); + if ( len( df.keys() ) != 2 ) + return ret_error( $"count of keys {df.keys()}!=2" ); endif - var ele1 := df.findelement(10); - var ele2 := df.findelement(11); - if (!ele1 || !ele2) - return ret_error($"elements not found {ele1}/{ele2}"); + var ele1 := df.findelement( 10 ); + var ele2 := df.findelement( 11 ); + if ( !ele1 || !ele2 ) + return ret_error( $"elements not found {ele1}/{ele2}" ); endif - if (ele1.getprop("prop1-1")!=1) - return ret_error("prop 1-1 not found "+ele1.getprop("prop1-1")); + if ( ele1.getprop( "prop1-1" ) != 1 ) + return ret_error( "prop 1-1 not found " + ele1.getprop( "prop1-1" ) ); endif - if (ele1.getprop("prop1-2")!=2) - return ret_error("prop 1-2 not found "+ele1.getprop("prop1-1")); + if ( ele1.getprop( "prop1-2" ) != 2 ) + return ret_error( "prop 1-2 not found " + ele1.getprop( "prop1-1" ) ); endif - if (ele2.getprop("prop2-1")!=3) - return ret_error("prop 2-1 not found "+ele2.getprop("prop1-1")); + if ( ele2.getprop( "prop2-1" ) != 3 ) + return ret_error( "prop 2-1 not found " + ele2.getprop( "prop1-1" ) ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_guild.src b/testsuite/pol/testpkgs/restart/test_guild.src index 82a119008..f77401936 100644 --- a/testsuite/pol/testpkgs/restart/test_guild.src +++ b/testsuite/pol/testpkgs/restart/test_guild.src @@ -3,59 +3,59 @@ use uo; use guilds; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_guild() return 1; endprogram exported function load_save_guild() - if (testrun == 1) - var chr1:=createAccountWithChar("restart_test_guild1", "pass"); - var chr2:=createAccountWithChar("restart_test_guild2", "pass"); - var guild1:=CreateGuild(); - var guild2:=CreateGuild(); - var guild3:=CreateGuild(); - if (!chr1 || !chr2 || !guild1 || !guild2 || !guild3) - return ret_error($"create failed {chr1} {chr2} {guild1} {guild2} {guild3}"); + if ( testrun == 1 ) + var chr1 := createAccountWithChar( "restart_test_guild1", "pass" ); + var chr2 := createAccountWithChar( "restart_test_guild2", "pass" ); + var guild1 := CreateGuild(); + var guild2 := CreateGuild(); + var guild3 := CreateGuild(); + if ( !chr1 || !chr2 || !guild1 || !guild2 || !guild3 ) + return ret_error( $"create failed {chr1} {chr2} {guild1} {guild2} {guild3}" ); endif - guild1.setprop("name","test"); - guild2.setprop("name","ally"); - guild3.setprop("name","enemy"); - guild1.addallyguild(guild2); - guild1.addenemyguild(guild3); - guild1.addmember(chr1); - guild1.addmember(chr2); + guild1.setprop( "name", "test" ); + guild2.setprop( "name", "ally" ); + guild3.setprop( "name", "enemy" ); + guild1.addallyguild( guild2 ); + guild1.addenemyguild( guild3 ); + guild1.addmember( chr1 ); + guild1.addmember( chr2 ); else - var guilds:=listguilds(); - if (len(guilds)<3) - return ret_error($"failed to load guilds {guilds}"); + var guilds := listguilds(); + if ( len( guilds ) < 3 ) + return ret_error( $"failed to load guilds {guilds}" ); endif var test; foreach g in guilds - if (g.getprop("name")=="test") - test:=g; + if ( g.getprop( "name" ) == "test" ) + test := g; endif endforeach - if (!test) - return ret_error("failed to find guild"); + if ( !test ) + return ret_error( "failed to find guild" ); endif - if (test.allyguilds[1].getprop("name")!="ally") - return ret_error($"wrong ally {test.allyguilds}"); + if ( test.allyguilds[1].getprop( "name" ) != "ally" ) + return ret_error( $"wrong ally {test.allyguilds}" ); endif - if (test.enemyguilds[1].getprop("name")!="enemy") - return ret_error($"wrong enemy {test.enemyguilds}"); + if ( test.enemyguilds[1].getprop( "name" ) != "enemy" ) + return ret_error( $"wrong enemy {test.enemyguilds}" ); endif - var chr1:=FindAccount("restart_test_guild1").getcharacter(1); - var chr2:=FindAccount("restart_test_guild2").getcharacter(1); - if (len(test.members)!=2) - return ret_error($"lost members {test.members}"); + var chr1 := FindAccount( "restart_test_guild1" ).getcharacter( 1 ); + var chr2 := FindAccount( "restart_test_guild2" ).getcharacter( 1 ); + if ( len( test.members ) != 2 ) + return ret_error( $"lost members {test.members}" ); endif - if (!test.ismember(chr1)) - return ret_error($"{chr1.serial : #x} is not a member"); + if ( !test.ismember( chr1 ) ) + return ret_error( $"{chr1.serial: #x} is not a member" ); endif - if (!test.ismember(chr2)) - return ret_error($"{chr2.serial : #x} is not a member"); + if ( !test.ismember( chr2 ) ) + return ret_error( $"{chr2.serial: #x} is not a member" ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_house.src b/testsuite/pol/testpkgs/restart/test_house.src index d1d33ddcd..5d667298c 100644 --- a/testsuite/pol/testpkgs/restart/test_house.src +++ b/testsuite/pol/testpkgs/restart/test_house.src @@ -2,7 +2,7 @@ use os; use uo; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_house() return 1; @@ -10,77 +10,75 @@ endprogram // save/load test for things in House class exported function load_save_house() - var props:={ - {"MultiID", {"multiid",0x6b}} - }; + var props := { { "MultiID", { "multiid", 0x6b } } }; - if (testrun == 1) - var house:=CreateMultiAtLocation(50,50,0,0x12000); - house.name:="load_save_house"; - if (!house) - return ret_error($"failed to create house {house}"); + if ( testrun == 1 ) + var house := CreateMultiAtLocation( 50, 50, 0, 0x12000 ); + house.name := "load_save_house"; + if ( !house ) + return ret_error( $"failed to create house {house}" ); endif - SetGlobalProperty("test_storage_house", house.serial); + SetGlobalProperty( "test_storage_house", house.serial ); else - var serial := GetGlobalProperty("test_storage_house"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_storage_house" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var house := SystemFindObjectBySerial(serial); - if (!house) - return ret_error($"House with serial {serial:#x} does not exists: {house})"); + var house := SystemFindObjectBySerial( serial ); + if ( !house ) + return ret_error( $"House with serial {serial:#x} does not exists: {house})" ); endif foreach prop in props - var val:=house.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := house.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - if (len(house.components)!=2) // door, sign - return ret_error($"invalid components: {house.components}"); + if ( len( house.components ) != 2 ) // door, sign + return ret_error( $"invalid components: {house.components}" ); endif endif return 1; endfunction exported function load_save_house_custom() - var props:={ - {"Custom", {"custom",1}} -// {"Current", {"",1}}, -// {"Working", {"",1}}, -// {"Backup", {"",1}}, -// {"DesignRevision", {"",1}} - }; + var props := { { "Custom", + { "custom", 1 } + } // {"Current", {"",1}}, + // {"Working", {"",1}}, + // {"Backup", {"",1}}, + // {"DesignRevision", {"",1}} + }; - if (testrun == 1) - var house:=CreateMultiAtLocation(60,60,0,0x12000); - house.name:="load_save_house_custom"; - if (!house) - return ret_error($"failed to create house {house}"); + if ( testrun == 1 ) + var house := CreateMultiAtLocation( 60, 60, 0, 0x12000 ); + house.name := "load_save_house_custom"; + if ( !house ) + return ret_error( $"failed to create house {house}" ); endif - SetGlobalProperty("test_storage_house_custom", house.serial); - house.setcustom(1); + SetGlobalProperty( "test_storage_house_custom", house.serial ); + house.setcustom( 1 ); else - var serial := GetGlobalProperty("test_storage_house_custom"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_storage_house_custom" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var house := SystemFindObjectBySerial(serial); - if (!house) - return ret_error($"House with serial {serial:#x} does not exists: {house}"); + var house := SystemFindObjectBySerial( serial ); + if ( !house ) + return ret_error( $"House with serial {serial:#x} does not exists: {house}" ); endif foreach prop in props - var val:=house.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := house.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - if (len(house.house_parts)!=140) - return ret_error($"invalid number of parts: "+len(house.house_parts)); + if ( len( house.house_parts ) != 140 ) + return ret_error( $"invalid number of parts: " + len( house.house_parts ) ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_item.src b/testsuite/pol/testpkgs/restart/test_item.src index 46b98fddc..3eb7e3ada 100644 --- a/testsuite/pol/testpkgs/restart/test_item.src +++ b/testsuite/pol/testpkgs/restart/test_item.src @@ -3,51 +3,51 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_item() return 1; endprogram exported function test_saveonexit() - if (testrun == 1) + if ( testrun == 1 ) // Test setting SaveOnExit in item descriptor successfully changes item save behavior - var desc := GetItemDescriptor(0xeed); + var desc := GetItemDescriptor( 0xeed ); desc.SaveOnExit := 0; - var item := CreateItemAtLocation(55,55,0, desc); - if (!item) - return ret_error($"Could not create should-not-save item in first server run: {item}"); + var item := CreateItemAtLocation( 55, 55, 0, desc ); + if ( !item ) + return ret_error( $"Could not create should-not-save item in first server run: {item}" ); endif - SetGlobalProperty("test_item_shouldNotExist", item.serial); + SetGlobalProperty( "test_item_shouldNotExist", item.serial ); // Change SaveOnExit to true, to enable saving the item desc.SaveOnExit := 1; - var item2 := CreateItemAtLocation(55,55,0, desc); - if (!item2) - return ret_error($"Could not create should-save item in first server run: {item2}"); + var item2 := CreateItemAtLocation( 55, 55, 0, desc ); + if ( !item2 ) + return ret_error( $"Could not create should-save item in first server run: {item2}" ); endif - SetGlobalProperty("test_item_shouldExist", item2.serial); + SetGlobalProperty( "test_item_shouldExist", item2.serial ); else // Check that the item that should not exist does not exist - var serial := GetGlobalProperty("test_item_shouldNotExist"); - if (!serial) - return ret_error("Global property test_item_shouldNotExist not found"); + var serial := GetGlobalProperty( "test_item_shouldNotExist" ); + if ( !serial ) + return ret_error( "Global property test_item_shouldNotExist not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (item) - return ret_error($"Item with serial {item.serial:#x} erroneously exists: {item.desc} (objtype {item.objtype:#x}) at ({item.x}, {item.y}, {item.z})"); + var item := SystemFindObjectBySerial( serial ); + if ( item ) + return ret_error( $"Item with serial {item.serial:#x} erroneously exists: {item.desc} (objtype {item.objtype:#x}) at ({item.x}, {item.y}, {item.z})" ); endif // Check that the item that should exist does exist - var serial2 := GetGlobalProperty("test_item_shouldExist"); - if (!serial2) - return ret_error("Global property test_item_shouldExist not found"); + var serial2 := GetGlobalProperty( "test_item_shouldExist" ); + if ( !serial2 ) + return ret_error( "Global property test_item_shouldExist not found" ); endif - var item2 := SystemFindObjectBySerial(serial2); - if (!item2) - return ret_error($"Item with serial {serial2:#x} does not exists: {item2})"); + var item2 := SystemFindObjectBySerial( serial2 ); + if ( !item2 ) + return ret_error( $"Item with serial {serial2:#x} does not exists: {item2})" ); endif endif return 1; @@ -55,56 +55,106 @@ endfunction // save/load test for things in Item exported function load_save_item() - var props:={ - {"Name", {"name","load_save_item"}}, -// {"Layer", {"",1}}, - {"Movable", {"movable",1}}, - {"Invisible", {"invisible",1}}, - {"Cursed", {"cursed",1}}, - {"OnUseScript", {"usescript","myusescript"}}, - {"EquipScript", {"equipscript","myequipscript"}}, - {"UnequipScript", {"unequipscript","myunequipscript"}}, - {"SnoopScript", {"snoopscript","mysnoopscript"}}, - {"DecayAt", {"decayat",12345678}}, - {"SellPrice", {"sellprice",111}}, - {"BuyPrice", {"buyprice",110}}, - {"Newbie", {"newbie",1}}, - {"Insured", {"insured",1}}, - {"MaxHp_mod", {"maxhp_mod",200}}, - {"Hp", {"hp",123}}, - {"Quality", {"quality",1.123}}, - {"NameSuffix", {"name_suffix","my_suffix"}}, - {"NoDrop", {"no_drop",1}} - }; + var props := { { "Name", + { "name", "load_save_item" } + }, // {"Layer", {"",1}}, + { + "Movable", + { "movable", 1 } + }, + { + "Invisible", + { "invisible", 1 } + }, + { + "Cursed", + { "cursed", 1 } + }, + { + "OnUseScript", + { "usescript", "myusescript" } + }, + { + "EquipScript", + { "equipscript", "myequipscript" } + }, + { + "UnequipScript", + { "unequipscript", "myunequipscript" } + }, + { + "SnoopScript", + { "snoopscript", "mysnoopscript" } + }, + { + "DecayAt", + { "decayat", 12345678 } + }, + { + "SellPrice", + { "sellprice", 111 } + }, + { + "BuyPrice", + { "buyprice", 110 } + }, + { + "Newbie", + { "newbie", 1 } + }, + { + "Insured", + { "insured", 1 } + }, + { + "MaxHp_mod", + { "maxhp_mod", 200 } + }, + { + "Hp", + { "hp", 123 } + }, + { + "Quality", + { "quality", 1.123 } + }, + { + "NameSuffix", + { "name_suffix", "my_suffix" } + }, + { + "NoDrop", + { "no_drop", 1 } + } }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, 0xf3f,1234,"britannia2"); - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, 0xf3f, 1234, "britannia2" ); + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_item", item.serial); + SetGlobalProperty( "test_item_storage_item", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach else - var serial := GetGlobalProperty("test_item_storage_item"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_item" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - if (item.amount != 1234) - return ret_error($"wrong amount {item.amount} != 1234"); + if ( item.amount != 1234 ) + return ret_error( $"wrong amount {item.amount} != 1234" ); endif endif return 1; @@ -112,7 +162,7 @@ endfunction // save/load test for things in Item (descriptor only) exported function load_save_item_descriptor() - var desc := GetItemDescriptor("restart_test"); + var desc := GetItemDescriptor( "restart_test" ); desc.FireResist := 1; desc.ColdResist := 2; desc.EnergyResist := 3; @@ -137,54 +187,123 @@ exported function load_save_item_descriptor() desc.PoisonResistCap := 22; desc.Luck := 23; desc.SwingSpeedIncrease := 24; - var props:={ - {"FireResist", {"resist_fire", desc.FireResist}}, - {"ColdResist", {"resist_cold", desc.ColdResist}}, - {"EnergyResist", {"resist_energy", desc.EnergyResist}}, - {"PoisonResist", {"resist_poison", desc.PoisonResist}}, - {"PhysicalResist", {"resist_physical", desc.PhysicalResist}}, - {"FireDamage", {"damage_fire", desc.FireDamage}}, - {"ColdDamage", {"damage_cold", desc.ColdDamage}}, - {"EnergyDamage", {"damage_energy", desc.EnergyDamage}}, - {"PoisonDamage", {"damage_poison", desc.PoisonDamage}}, - {"PhysicalDamage", {"damage_physical", desc.PhysicalDamage}}, - {"LowerReagentCost", {"lower_reagent_cost", desc.LowerReagentCost}}, - {"SpellDamageIncrease", {"spell_damage_increase", desc.SpellDamageIncrease}}, - {"FasterCasting", {"faster_casting", desc.FasterCasting}}, - {"FasterCastRecovery", {"faster_cast_recovery", desc.FasterCastRecovery}}, - {"DefenceIncrease", {"defence_increase", desc.DefenceIncrease}}, - {"DefenceIncreaseCap", {"defence_increase_cap", desc.DefenceIncreaseCap}}, - {"LowerManaCost", {"lower_mana_cost", desc.LowerManaCost}}, - {"FireResistCap", {"resist_fire_cap", desc.FireResistCap}}, - {"ColdResistCap", {"resist_cold_cap", desc.ColdResistCap}}, - {"EnergyResistCap", {"resist_energy_cap", desc.EnergyResistCap}}, - {"PhysicalResistCap", {"resist_physical_cap", desc.PhysicalResistCap}}, - {"PoisonResistCap", {"resist_poison_cap", desc.PoisonResistCap}}, - {"Luck", {"luck", desc.Luck}}, - {"SwingSpeedIncrease", {"swing_speed_increase", desc.SwingSpeedIncrease}} - }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, desc,1,"britannia2"); - item.name:="load_save_item_descriptor"; - if (!item) - return ret_error($"failed to create item {item}"); + var props := { { "FireResist", + { "resist_fire", desc.FireResist } + }, + { + "ColdResist", + { "resist_cold", desc.ColdResist } + }, + { + "EnergyResist", + { "resist_energy", desc.EnergyResist } + }, + { + "PoisonResist", + { "resist_poison", desc.PoisonResist } + }, + { + "PhysicalResist", + { "resist_physical", desc.PhysicalResist } + }, + { + "FireDamage", + { "damage_fire", desc.FireDamage } + }, + { + "ColdDamage", + { "damage_cold", desc.ColdDamage } + }, + { + "EnergyDamage", + { "damage_energy", desc.EnergyDamage } + }, + { + "PoisonDamage", + { "damage_poison", desc.PoisonDamage } + }, + { + "PhysicalDamage", + { "damage_physical", desc.PhysicalDamage } + }, + { + "LowerReagentCost", + { "lower_reagent_cost", desc.LowerReagentCost } + }, + { + "SpellDamageIncrease", + { "spell_damage_increase", desc.SpellDamageIncrease } + }, + { + "FasterCasting", + { "faster_casting", desc.FasterCasting } + }, + { + "FasterCastRecovery", + { "faster_cast_recovery", desc.FasterCastRecovery } + }, + { + "DefenceIncrease", + { "defence_increase", desc.DefenceIncrease } + }, + { + "DefenceIncreaseCap", + { "defence_increase_cap", desc.DefenceIncreaseCap } + }, + { + "LowerManaCost", + { "lower_mana_cost", desc.LowerManaCost } + }, + { + "FireResistCap", + { "resist_fire_cap", desc.FireResistCap } + }, + { + "ColdResistCap", + { "resist_cold_cap", desc.ColdResistCap } + }, + { + "EnergyResistCap", + { "resist_energy_cap", desc.EnergyResistCap } + }, + { + "PhysicalResistCap", + { "resist_physical_cap", desc.PhysicalResistCap } + }, + { + "PoisonResistCap", + { "resist_poison_cap", desc.PoisonResistCap } + }, + { + "Luck", + { "luck", desc.Luck } + }, + { + "SwingSpeedIncrease", + { "swing_speed_increase", desc.SwingSpeedIncrease } + } }; + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, desc, 1, "britannia2" ); + item.name := "load_save_item_descriptor"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_item_descriptor", item.serial); + SetGlobalProperty( "test_item_storage_item_descriptor", item.serial ); else - var serial := GetGlobalProperty("test_item_storage_item_descriptor"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_item_descriptor" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach endif @@ -193,40 +312,40 @@ endfunction // save/load test for things in Item (container) exported function load_save_item_in_container() - if (testrun == 1) - var cnt := CreateItemAtLocation(10,11,-5, "restart_test_container",1,"britannia2"); - if (!cnt) - return ret_error($"failed to create item {cnt}"); + if ( testrun == 1 ) + var cnt := CreateItemAtLocation( 10, 11, -5, "restart_test_container", 1, "britannia2" ); + if ( !cnt ) + return ret_error( $"failed to create item {cnt}" ); endif - cnt.name:="load_save_cnt_for_item"; - var item := CreateItemInContainer(cnt, 0xeed, 1, 2, 3); - if (!item) - return ret_error($"failed to create item {item}"); + cnt.name := "load_save_cnt_for_item"; + var item := CreateItemInContainer( cnt, 0xeed, 1, 2, 3 ); + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - item.name:="load_save_item_in_container"; - SetGlobalProperty("test_item_storage_item_in_cnt", item.serial); - SetGlobalProperty("test_item_storage_cnt_item_in_cnt", cnt.serial); + item.name := "load_save_item_in_container"; + SetGlobalProperty( "test_item_storage_item_in_cnt", item.serial ); + SetGlobalProperty( "test_item_storage_cnt_item_in_cnt", cnt.serial ); else - var serial := GetGlobalProperty("test_item_storage_item_in_cnt"); - var serialcnt := GetGlobalProperty("test_item_storage_cnt_item_in_cnt"); - if (!serial || !serialcnt) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_item_in_cnt" ); + var serialcnt := GetGlobalProperty( "test_item_storage_cnt_item_in_cnt" ); + if ( !serial || !serialcnt ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif - var cnt := SystemFindObjectBySerial(serialcnt); - if (!cnt) - return ret_error($"Cnt with serial {serialcnt:#x} does not exists: {cnt})"); + var cnt := SystemFindObjectBySerial( serialcnt ); + if ( !cnt ) + return ret_error( $"Cnt with serial {serialcnt:#x} does not exists: {cnt})" ); endif - if (item.container != cnt) - return ret_error($"Item not in container: {item.container} != {cnt.serial}"); + if ( item.container != cnt ) + return ret_error( $"Item not in container: {item.container} != {cnt.serial}" ); endif - if (item.x != 2 || item.y != 3) - return ret_error($"wrong coordinates ({item.x},{item.y}) != (2,3)"); + if ( item.x != 2 || item.y != 3 ) + return ret_error( $"wrong coordinates ({item.x},{item.y}) != (2,3)" ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_lockable.src b/testsuite/pol/testpkgs/restart/test_lockable.src index 66dc4af3d..f9ba4cf87 100644 --- a/testsuite/pol/testpkgs/restart/test_lockable.src +++ b/testsuite/pol/testpkgs/restart/test_lockable.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_lockable() return 1; @@ -11,35 +11,33 @@ endprogram // save/load test for things in Lockable class exported function load_save_lockable() - var props:={ - {"Locked", {"locked",1}} - }; + var props := { { "Locked", { "locked", 1 } } }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, "restart_test_container",1,"britannia2"); - item.name:="load_save_lockable"; - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, "restart_test_container", 1, "britannia2" ); + item.name := "load_save_lockable"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_lockable", item.serial); + SetGlobalProperty( "test_item_storage_lockable", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach else - var serial := GetGlobalProperty("test_item_storage_lockable"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_lockable" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach endif diff --git a/testsuite/pol/testpkgs/restart/test_map.src b/testsuite/pol/testpkgs/restart/test_map.src index d7d1c0274..5fbd90710 100644 --- a/testsuite/pol/testpkgs/restart/test_map.src +++ b/testsuite/pol/testpkgs/restart/test_map.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_map() return 1; @@ -11,56 +11,77 @@ endprogram // save/load test for things in Map class exported function load_save_map() - var props:={ - {"xwest", {"xwest",1}}, - {"ynorth", {"ynorth",2}}, - {"xeast", {"xeast",10}}, - {"ysouth", {"ysouth",20}}, - {"gumpwidth", {"gumpwidth",100}}, - {"gumpheight", {"gumpheight",200}}, - {"facetid", {"facetid",3}}, - {"editable", {"editable",1}} -// {"NumPins", {"",1}}, //tested via appendpin - }; + var props := { { "xwest", + { "xwest", 1 } + }, + { + "ynorth", + { "ynorth", 2 } + }, + { + "xeast", + { "xeast", 10 } + }, + { + "ysouth", + { "ysouth", 20 } + }, + { + "gumpwidth", + { "gumpwidth", 100 } + }, + { + "gumpheight", + { "gumpheight", 200 } + }, + { + "facetid", + { "facetid", 3 } + }, + { + "editable", + { "editable", 1 } + } // {"NumPins", {"",1}}, //tested via appendpin + }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, "restart_test_map",1,"britannia2"); - item.name:="load_save_map"; - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, "restart_test_map", 1, "britannia2" ); + item.name := "load_save_map"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_map", item.serial); + SetGlobalProperty( "test_item_storage_map", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach - item.appendpin(4,5); - item.appendpin(6,7); + item.appendpin( 4, 5 ); + item.appendpin( 6, 7 ); else - var serial := GetGlobalProperty("test_item_storage_map"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_map" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - var pins:=item.getpins(); - if (len(pins)!=2) - return ret_error("invalid number of pins: {pins}"); + var pins := item.getpins(); + if ( len( pins ) != 2 ) + return ret_error( "invalid number of pins: {pins}" ); endif - if (pins[1].x!=4 or pins[1].y!=5) - return ret_error($"invalid coord {pins[1]} != 4,5"); + if ( pins[1].x != 4 or pins[1].y != 5 ) + return ret_error( $"invalid coord {pins[1]} != 4,5" ); endif - if (pins[2].x!=6 or pins[2].y!=7) - return ret_error($"invalid coord {pins[2]} != 6,7"); + if ( pins[2].x != 6 or pins[2].y != 7 ) + return ret_error( $"invalid coord {pins[2]} != 6,7" ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_npc.src b/testsuite/pol/testpkgs/restart/test_npc.src index 280f5bccb..d94a7da86 100644 --- a/testsuite/pol/testpkgs/restart/test_npc.src +++ b/testsuite/pol/testpkgs/restart/test_npc.src @@ -3,7 +3,7 @@ use uo; use vitals; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_npc() return 1; @@ -11,132 +11,219 @@ endprogram // save/load test for things in NPC class exported function load_save_npc() - var override:=struct{ - AR := 101, - script := "restartnpcscript", - SpeechColor := 102, - SpeechFont := 103, - RunSpeed := 210, - UseAdjustments := 0, - FireResist := 1, - ColdResist := 2, - EnergyResist := 3, - PoisonResist := 4, - PhysicalResist := 5, - FireDamage := 6, - ColdDamage := 7, - EnergyDamage := 8, - PoisonDamage := 9, - PhysicalDamage := 10, - LowerReagentCost := 11, - SpellDamageIncrease := 12, - FasterCasting := 13, - FasterCastRecovery := 14, - DefenceIncrease := 15, - DefenceIncreaseCap := 16, - LowerManaCost := 17, - FireResistCap := 18, - ColdResistCap := 19, - EnergyResistCap := 20, - PhysicalResistCap := 21, - PoisonResistCap := 22, - Luck := 23, - SwingSpeedIncrease := 24, - NoDropException := 1 - }; - var props:={ -// {"RegisteredHouse", {"",1}}, - {"AR", {"ar", override.AR}}, - {"script", {"script", override.script}}, -// {"master", {"",1}}, //method - {"SpeechColor", {"speech_color", override.SpeechColor}}, - {"SpeechFont", {"speech_font", override.SpeechFont}}, - {"RunSpeed", {"run_speed",210}}, - {"UseAdjustments", {"use_adjustments",0}}, - {"FireResist", {"resist_fire", override.FireResist}}, - {"ColdResist", {"resist_cold", override.ColdResist}}, - {"EnergyResist", {"resist_energy", override.EnergyResist}}, - {"PoisonResist", {"resist_poison", override.PoisonResist}}, - {"PhysicalResist", {"resist_physical", override.PhysicalResist}}, - {"FireDamage", {"damage_fire", override.FireDamage}}, - {"ColdDamage", {"damage_cold", override.ColdDamage}}, - {"EnergyDamage", {"damage_energy", override.EnergyDamage}}, - {"PoisonDamage", {"damage_poison", override.PoisonDamage}}, - {"PhysicalDamage", {"damage_physical", override.PhysicalDamage}}, - {"LowerReagentCost", {"lower_reagent_cost", override.LowerReagentCost}}, - {"SpellDamageIncrease", {"spell_damage_increase", override.SpellDamageIncrease}}, - {"FasterCasting", {"faster_casting", override.FasterCasting}}, - {"FasterCastRecovery", {"faster_cast_recovery", override.FasterCastRecovery}}, - {"DefenceIncrease", {"defence_increase", override.DefenceIncrease}}, - {"DefenceIncreaseCap", {"defence_increase_cap", override.DefenceIncreaseCap}}, - {"LowerManaCost", {"lower_mana_cost", override.LowerManaCost}}, - {"FireResistCap", {"resist_fire_cap", override.FireResistCap}}, - {"ColdResistCap", {"resist_cold_cap", override.ColdResistCap}}, - {"EnergyResistCap", {"resist_energy_cap", override.EnergyResistCap}}, - {"PhysicalResistCap", {"resist_physical_cap", override.PhysicalResistCap}}, - {"PoisonResistCap", {"resist_poison_cap", override.PoisonResistCap}}, - {"Luck", {"luck", override.Luck}}, - {"SwingSpeedIncrease", {"swing_speed_increase", override.SwingSpeedIncrease}}, - {"NoDropException", {"no_drop_exception",1}} - }; - if (testrun == 1) - var npc:=CreateNPCFromTemplate(":testrestart:restart_npc",49,50,0,override,"britannia2"); - if (!npc) - return ret_error($"failed to create npc {npc}"); + var override := struct{ AR := 101, + script := "restartnpcscript", + SpeechColor := 102, + SpeechFont := 103, + RunSpeed := 210, + UseAdjustments := 0, + FireResist := 1, + ColdResist := 2, + EnergyResist := 3, + PoisonResist := 4, + PhysicalResist := 5, + FireDamage := 6, + ColdDamage := 7, + EnergyDamage := 8, + PoisonDamage := 9, + PhysicalDamage := 10, + LowerReagentCost := 11, + SpellDamageIncrease := 12, + FasterCasting := 13, + FasterCastRecovery := 14, + DefenceIncrease := 15, + DefenceIncreaseCap := 16, + LowerManaCost := 17, + FireResistCap := 18, + ColdResistCap := 19, + EnergyResistCap := 20, + PhysicalResistCap := 21, + PoisonResistCap := 22, + Luck := 23, + SwingSpeedIncrease := 24, + NoDropException := 1 }; + var props := { // {"RegisteredHouse", {"",1}}, + { "AR", + { "ar", override.AR } + }, + { + "script", + { "script", override.script } + }, // {"master", {"",1}}, //method + { + "SpeechColor", + { "speech_color", override.SpeechColor } + }, + { + "SpeechFont", + { "speech_font", override.SpeechFont } + }, + { + "RunSpeed", + { "run_speed", 210 } + }, + { + "UseAdjustments", + { "use_adjustments", 0 } + }, + { + "FireResist", + { "resist_fire", override.FireResist } + }, + { + "ColdResist", + { "resist_cold", override.ColdResist } + }, + { + "EnergyResist", + { "resist_energy", override.EnergyResist } + }, + { + "PoisonResist", + { "resist_poison", override.PoisonResist } + }, + { + "PhysicalResist", + { "resist_physical", override.PhysicalResist } + }, + { + "FireDamage", + { "damage_fire", override.FireDamage } + }, + { + "ColdDamage", + { "damage_cold", override.ColdDamage } + }, + { + "EnergyDamage", + { "damage_energy", override.EnergyDamage } + }, + { + "PoisonDamage", + { "damage_poison", override.PoisonDamage } + }, + { + "PhysicalDamage", + { "damage_physical", override.PhysicalDamage } + }, + { + "LowerReagentCost", + { "lower_reagent_cost", override.LowerReagentCost } + }, + { + "SpellDamageIncrease", + { "spell_damage_increase", override.SpellDamageIncrease } + }, + { + "FasterCasting", + { "faster_casting", override.FasterCasting } + }, + { + "FasterCastRecovery", + { "faster_cast_recovery", override.FasterCastRecovery } + }, + { + "DefenceIncrease", + { "defence_increase", override.DefenceIncrease } + }, + { + "DefenceIncreaseCap", + { "defence_increase_cap", override.DefenceIncreaseCap } + }, + { + "LowerManaCost", + { "lower_mana_cost", override.LowerManaCost } + }, + { + "FireResistCap", + { "resist_fire_cap", override.FireResistCap } + }, + { + "ColdResistCap", + { "resist_cold_cap", override.ColdResistCap } + }, + { + "EnergyResistCap", + { "resist_energy_cap", override.EnergyResistCap } + }, + { + "PhysicalResistCap", + { "resist_physical_cap", override.PhysicalResistCap } + }, + { + "PoisonResistCap", + { "resist_poison_cap", override.PoisonResistCap } + }, + { + "Luck", + { "luck", override.Luck } + }, + { + "SwingSpeedIncrease", + { "swing_speed_increase", override.SwingSpeedIncrease } + }, + { + "NoDropException", + { "no_drop_exception", 1 } + } }; + if ( testrun == 1 ) + var npc := CreateNPCFromTemplate( ":testrestart:restart_npc", 49, 50, 0, override, "britannia2" ); + if ( !npc ) + return ret_error( $"failed to create npc {npc}" ); endif - var chr:=createAccountWithChar("restart_test_charnpc_master", "pass"); - setname(npc,"storage_test"); - npc.setmaster(chr); + var chr := createAccountWithChar( "restart_test_charnpc_master", "pass" ); + setname( npc, "storage_test" ); + npc.setmaster( chr ); - SetGlobalProperty("test_storage_npc", npc.serial); + SetGlobalProperty( "test_storage_npc", npc.serial ); else - var serial := GetGlobalProperty("test_storage_npc"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_storage_npc" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var npc := SystemFindObjectBySerial(serial); - if (!npc) - return ret_error($"Npc with serial {serial:#x} does not exists: {npc})"); + var npc := SystemFindObjectBySerial( serial ); + if ( !npc ) + return ret_error( $"Npc with serial {serial:#x} does not exists: {npc})" ); endif foreach prop in props - var val:=npc.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := npc.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - var chr:=FindAccount("restart_test_charnpc_master").getcharacter(1); - if (!chr) - return ret_error("failed to find char"); + var chr := FindAccount( "restart_test_charnpc_master" ).getcharacter( 1 ); + if ( !chr ) + return ret_error( "failed to find char" ); endif - if (npc.master != chr) - return ret_error("master not saved"); + if ( npc.master != chr ) + return ret_error( "master not saved" ); endif - if (getvital(npc,"Mana") != 20000) - return ret_error("Wrong Mana value: "+getvital(npc,"Mana")); + if ( getvital( npc, "Mana" ) != 20000 ) + return ret_error( "Wrong Mana value: " + getvital( npc, "Mana" ) ); endif endif return 1; endfunction exported function test_saveonexit() - if (testrun == 1) - var npc:=CreateNPCFromTemplate(":testrestart:restart_npc",49,50,0); - if (!npc) - return ret_error($"failed to create npc {npc}"); + if ( testrun == 1 ) + var npc := CreateNPCFromTemplate( ":testrestart:restart_npc", 49, 50, 0 ); + if ( !npc ) + return ret_error( $"failed to create npc {npc}" ); endif - npc.saveonexit:=0; - SetGlobalProperty("test_npc_shouldNotExist", npc.serial); + npc.saveonexit := 0; + SetGlobalProperty( "test_npc_shouldNotExist", npc.serial ); else - var serial := GetGlobalProperty("test_npc_shouldNotExist"); - if (!serial) - return ret_error("Global property test_npc_shouldNotExist not found"); + var serial := GetGlobalProperty( "test_npc_shouldNotExist" ); + if ( !serial ) + return ret_error( "Global property test_npc_shouldNotExist not found" ); endif - var npc := SystemFindObjectBySerial(serial); - if (npc) - return ret_error($"Npc with serial {npc.serial:#x} erroneously exists"); + var npc := SystemFindObjectBySerial( serial ); + if ( npc ) + return ret_error( $"Npc with serial {npc.serial:#x} erroneously exists" ); endif endif diff --git a/testsuite/pol/testpkgs/restart/test_party.src b/testsuite/pol/testpkgs/restart/test_party.src index 00897911f..0e01fca0b 100644 --- a/testsuite/pol/testpkgs/restart/test_party.src +++ b/testsuite/pol/testpkgs/restart/test_party.src @@ -3,35 +3,35 @@ use uo; use party; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_party() return 1; endprogram exported function load_save_party() - if (testrun == 1) - var chr1:=createAccountWithChar("restart_test_party1", "pass"); - var chr2:=createAccountWithChar("restart_test_party2", "pass"); - var res:=CreateParty(chr1,chr2); - if (!chr1 || !chr2 || !res) - return ret_error($"create failed {chr1} {chr2} {res}"); + if ( testrun == 1 ) + var chr1 := createAccountWithChar( "restart_test_party1", "pass" ); + var chr2 := createAccountWithChar( "restart_test_party2", "pass" ); + var res := CreateParty( chr1, chr2 ); + if ( !chr1 || !chr2 || !res ) + return ret_error( $"create failed {chr1} {chr2} {res}" ); endif - chr1.party.setprop("name","test"); + chr1.party.setprop( "name", "test" ); else - var chr1:=FindAccount("restart_test_party1").getcharacter(1); - var chr2:=FindAccount("restart_test_party2").getcharacter(1); - if (!chr1.party || !chr2.party) - return ret_error("lost party"); + var chr1 := FindAccount( "restart_test_party1" ).getcharacter( 1 ); + var chr2 := FindAccount( "restart_test_party2" ).getcharacter( 1 ); + if ( !chr1.party || !chr2.party ) + return ret_error( "lost party" ); endif - if (chr2.party.leader != chr1) - return ret_error($"leader {chr2.party.leader.serial : #x} != {chr1.serial : #x}"); + if ( chr2.party.leader != chr1 ) + return ret_error( $"leader {chr2.party.leader.serial: #x} != {chr1.serial: #x}" ); endif - if (chr1.party.members[2] != chr2) - return ret_error($"member {chr1.party.members[2].serial : #x} != {chr2.serial : #x}"); + if ( chr1.party.members[2] != chr2 ) + return ret_error( $"member {chr1.party.members[2].serial: #x} != {chr2.serial: #x}" ); endif - if (chr1.party.getprop("name")!="test") - return ret_error("failed to load cprop: "+chr1.party.getprop("name")); + if ( chr1.party.getprop( "name" ) != "test" ) + return ret_error( "failed to load cprop: " + chr1.party.getprop( "name" ) ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_realm.src b/testsuite/pol/testpkgs/restart/test_realm.src index 029e86222..7c74e1416 100644 --- a/testsuite/pol/testpkgs/restart/test_realm.src +++ b/testsuite/pol/testpkgs/restart/test_realm.src @@ -3,22 +3,22 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_realm() return 1; endprogram exported function load_save_shadowrealm() - if (testrun == 1) - var r:= addrealm("savetest_realm", "britannia2"); - if (!r) - return ret_error($"failed to add: {r}"); + if ( testrun == 1 ) + var r := addrealm( "savetest_realm", "britannia2" ); + if ( !r ) + return ret_error( $"failed to add: {r}" ); endif else - var r:=Realms("savetest_realm"); - if (!r || r.mapid!=1) - return ret_error("failed to load realm"); + var r := Realms( "savetest_realm" ); + if ( !r || r.mapid != 1 ) + return ret_error( "failed to load realm" ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_resource.src b/testsuite/pol/testpkgs/restart/test_resource.src index 03cb610e1..37e2fa296 100644 --- a/testsuite/pol/testpkgs/restart/test_resource.src +++ b/testsuite/pol/testpkgs/restart/test_resource.src @@ -2,7 +2,7 @@ use os; use uo; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); // nothing really to test // only an otherwise unused variable gets stored?? diff --git a/testsuite/pol/testpkgs/restart/test_spellbook.src b/testsuite/pol/testpkgs/restart/test_spellbook.src index 6f0f75ed4..49244666d 100644 --- a/testsuite/pol/testpkgs/restart/test_spellbook.src +++ b/testsuite/pol/testpkgs/restart/test_spellbook.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_spellbook() return 1; @@ -11,28 +11,28 @@ endprogram // save/load test for things in SpellBook class exported function load_save_spellbook() - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, "restart_test_spellbook",1,"britannia2"); - item.name:="load_save_spellbook"; - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, "restart_test_spellbook", 1, "britannia2" ); + item.name := "load_save_spellbook"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_spellbook", item.serial); - item.addspell(50); - item.addspell(3); + SetGlobalProperty( "test_item_storage_spellbook", item.serial ); + item.addspell( 50 ); + item.addspell( 3 ); else - var serial := GetGlobalProperty("test_item_storage_spellbook"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_spellbook" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif - if (!item.hasspell(50) || !item.hasspell(3)) - return ret_error("Spellbook does not have 3&50 spell: +"+item.spells()); + if ( !item.hasspell( 50 ) || !item.hasspell( 3 ) ) + return ret_error( "Spellbook does not have 3&50 spell: +" + item.spells() ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_storage.src b/testsuite/pol/testpkgs/restart/test_storage.src index c60c8a970..37f1e267e 100644 --- a/testsuite/pol/testpkgs/restart/test_storage.src +++ b/testsuite/pol/testpkgs/restart/test_storage.src @@ -3,37 +3,37 @@ use uo; use storage; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_storage() return 1; endprogram exported function load_save_storage() - if (testrun == 1) - var storage:=CreateStorageArea("restart_storage"); - if (!storage) - return ret_error($"Failed to create storage: {storage}"); + if ( testrun == 1 ) + var storage := CreateStorageArea( "restart_storage" ); + if ( !storage ) + return ret_error( $"Failed to create storage: {storage}" ); endif - var root:=CreateRootItemInStorageArea(storage,"restart_root",0xe75); - if (!root) - return ret_error($"Failed to create root cnt: {root}"); + var root := CreateRootItemInStorageArea( storage, "restart_root", 0xe75 ); + if ( !root ) + return ret_error( $"Failed to create root cnt: {root}" ); endif - var item:=CreateItemInContainer(root, 0x3e3f); - if (!item) - return ret_error($"Failed to create item: {item}"); + var item := CreateItemInContainer( root, 0x3e3f ); + if ( !item ) + return ret_error( $"Failed to create item: {item}" ); endif else - var storage:=FindStorageArea("restart_storage"); - if (!storage) - return ret_error($"Didnt found storage {storage}"); + var storage := FindStorageArea( "restart_storage" ); + if ( !storage ) + return ret_error( $"Didnt found storage {storage}" ); endif - var root:=FindRootItemInStorageArea(storage, "restart_root"); - if (!root) - return ret_error($"Didnt found root {root}"); + var root := FindRootItemInStorageArea( storage, "restart_root" ); + if ( !root ) + return ret_error( $"Didnt found root {root}" ); endif - if (storage.count != 1 || storage.totalcount != 2) - return ret_error($"Count missmatch {storage.count} != 1 || {storage.totalcount} != 2"); + if ( storage.count != 1 || storage.totalcount != 2 ) + return ret_error( $"Count missmatch {storage.count} != 1 || {storage.totalcount} != 2" ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_uobject.src b/testsuite/pol/testpkgs/restart/test_uobject.src index cf7a7b931..3ac5e900b 100644 --- a/testsuite/pol/testpkgs/restart/test_uobject.src +++ b/testsuite/pol/testpkgs/restart/test_uobject.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_uobject() return 1; @@ -11,74 +11,158 @@ endprogram // save/load test for things in UObject (uses Item) exported function load_save_uobject() - var props:={ - {"Name", {"name","load_save_uobject"}}, - {"Graphic", {"graphic",0x1234}}, - {"Color", {"color",0xff0}}, - {"Facing", {"facing",6}}, // after graphic or it gets resetted + var props := { { "Name", + { "name", "load_save_uobject" } + }, + { + "Graphic", + { "graphic", 0x1234 } + }, + { + "Color", + { "color", 0xff0 } + }, + { + "Facing", + { "facing", 6 } + }, // after graphic or it gets resetted // {"Revision", {"",1}}, - {"FireResistMod", {"resist_fire_mod",1}}, - {"ColdResistMod", {"resist_cold_mod",2}}, - {"EnergyResistMod", {"resist_energy_mod",3}}, - {"PoisonResistMod", {"resist_poison_mod",4}}, - {"PhysicalResistMod", {"resist_physical_mod",5}}, - {"FireDamageMod", {"damage_fire_mod",6}}, - {"ColdDamageMod", {"damage_cold_mod",7}}, - {"EnergyDamageMod", {"damage_energy_mod",8}}, - {"PoisonDamageMod", {"damage_poison_mod",9}}, - {"PhysicalDamageMod", {"damage_physical_mod",10}}, - {"LowerReagentCostMod", {"lower_reagent_cost_mod",11}}, - {"DefenceIncreaseMod", {"defence_increase_mod",12}}, - {"DefenceIncreaseCapMod", {"defence_increase_cap_mod",13}}, - {"LowerManaCostMod", {"lower_mana_cost_mod",14}}, - {"HitChanceMod", {"hit_chance_mod",15}}, - {"FireResistCapMod", {"resist_fire_cap_mod",16}}, - {"ColdResistCapMod", {"resist_cold_cap_mod",17}}, - {"EnergyResistCapMod", {"resist_energy_cap_mod",18}}, - {"PhysicalResistCapMod", {"resist_physical_cap_mod",19}}, - {"PoisonResistCapMod", {"resist_poison_cap_mod",20}}, - {"SpellDamageIncreaseMod", {"spell_damage_increase_mod",21}}, - {"FasterCastingMod", {"faster_casting_mod",22}}, - {"FasterCastRecoveryMod", {"faster_cast_recovery_mod",23}}, - {"LuckMod", {"luck_mod",24}}, - {"SwingSpeedIncreaseMod", {"swing_speed_increase_mod",25}} - }; + { + "FireResistMod", + { "resist_fire_mod", 1 } + }, + { + "ColdResistMod", + { "resist_cold_mod", 2 } + }, + { + "EnergyResistMod", + { "resist_energy_mod", 3 } + }, + { + "PoisonResistMod", + { "resist_poison_mod", 4 } + }, + { + "PhysicalResistMod", + { "resist_physical_mod", 5 } + }, + { + "FireDamageMod", + { "damage_fire_mod", 6 } + }, + { + "ColdDamageMod", + { "damage_cold_mod", 7 } + }, + { + "EnergyDamageMod", + { "damage_energy_mod", 8 } + }, + { + "PoisonDamageMod", + { "damage_poison_mod", 9 } + }, + { + "PhysicalDamageMod", + { "damage_physical_mod", 10 } + }, + { + "LowerReagentCostMod", + { "lower_reagent_cost_mod", 11 } + }, + { + "DefenceIncreaseMod", + { "defence_increase_mod", 12 } + }, + { + "DefenceIncreaseCapMod", + { "defence_increase_cap_mod", 13 } + }, + { + "LowerManaCostMod", + { "lower_mana_cost_mod", 14 } + }, + { + "HitChanceMod", + { "hit_chance_mod", 15 } + }, + { + "FireResistCapMod", + { "resist_fire_cap_mod", 16 } + }, + { + "ColdResistCapMod", + { "resist_cold_cap_mod", 17 } + }, + { + "EnergyResistCapMod", + { "resist_energy_cap_mod", 18 } + }, + { + "PhysicalResistCapMod", + { "resist_physical_cap_mod", 19 } + }, + { + "PoisonResistCapMod", + { "resist_poison_cap_mod", 20 } + }, + { + "SpellDamageIncreaseMod", + { "spell_damage_increase_mod", 21 } + }, + { + "FasterCastingMod", + { "faster_casting_mod", 22 } + }, + { + "FasterCastRecoveryMod", + { "faster_cast_recovery_mod", 23 } + }, + { + "LuckMod", + { "luck_mod", 24 } + }, + { + "SwingSpeedIncreaseMod", + { "swing_speed_increase_mod", 25 } + } }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, 0xeed,1,"britannia2"); - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, 0xeed, 1, "britannia2" ); + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_uobject", item.serial); + SetGlobalProperty( "test_item_storage_uobject", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach - item.setprop("test","testcprop"); + item.setprop( "test", "testcprop" ); else - var serial := GetGlobalProperty("test_item_storage_uobject"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_uobject" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach - if (item.objtype != 0xeed) - return ret_error($"wrong objtype {item.objtype:#x} != 0xeed"); + if ( item.objtype != 0xeed ) + return ret_error( $"wrong objtype {item.objtype:#x} != 0xeed" ); endif - if (item.x != 10 || item.y != 11 || item.z != -5 || item.realm != "britannia2") - return ret_error($"wrong pos {item.x},{item.y},{item.z},{item.realm} != 10,11,-5,britannia2"); + if ( item.x != 10 || item.y != 11 || item.z != -5 || item.realm != "britannia2" ) + return ret_error( $"wrong pos {item.x},{item.y},{item.z},{item.realm} != 10,11,-5,britannia2" ); endif - if (item.getprop("test") != "testcprop") - return ret_error("failed to load cprop: "+item.getprop("test")); + if ( item.getprop( "test" ) != "testcprop" ) + return ret_error( "failed to load cprop: " + item.getprop( "test" ) ); endif endif return 1; diff --git a/testsuite/pol/testpkgs/restart/test_weapon.src b/testsuite/pol/testpkgs/restart/test_weapon.src index 8b649d387..7a608a933 100644 --- a/testsuite/pol/testpkgs/restart/test_weapon.src +++ b/testsuite/pol/testpkgs/restart/test_weapon.src @@ -3,7 +3,7 @@ use uo; use polsys; include "testutil"; -var testrun:=CInt(GetEnvironmentVariable("POLCORE_TEST_RUN")); +var testrun := CInt( GetEnvironmentVariable( "POLCORE_TEST_RUN" ) ); program test_weapon() return 1; @@ -11,37 +11,43 @@ endprogram // save/load test for things in Weapon class exported function load_save_weapon() - var props:={ - {"dmg_mod", {"dmg_mod",1}}, - {"speed_mod", {"speed_mod",2}}, - {"HitScript", {"hitscript",":testrestart:myhitscript"}} - }; + var props := { { "dmg_mod", + { "dmg_mod", 1 } + }, + { + "speed_mod", + { "speed_mod", 2 } + }, + { + "HitScript", + { "hitscript", ":testrestart:myhitscript" } + } }; - if (testrun == 1) - var item := CreateItemAtLocation(10,11,-5, "restart_test_weapon",1,"britannia2"); - item.name:="load_save_weapon"; - if (!item) - return ret_error($"failed to create item {item}"); + if ( testrun == 1 ) + var item := CreateItemAtLocation( 10, 11, -5, "restart_test_weapon", 1, "britannia2" ); + item.name := "load_save_weapon"; + if ( !item ) + return ret_error( $"failed to create item {item}" ); endif - SetGlobalProperty("test_item_storage_weapon", item.serial); + SetGlobalProperty( "test_item_storage_weapon", item.serial ); foreach prop in props - item.set_member(prop[2][1],prop[2][2]); + item.set_member( prop[2][1], prop[2][2] ); endforeach else - var serial := GetGlobalProperty("test_item_storage_weapon"); - if (!serial) - return ret_error("Global property not found"); + var serial := GetGlobalProperty( "test_item_storage_weapon" ); + if ( !serial ) + return ret_error( "Global property not found" ); endif - var item := SystemFindObjectBySerial(serial); - if (!item) - return ret_error($"Item with serial {serial:#x} does not exists: {item})"); + var item := SystemFindObjectBySerial( serial ); + if ( !item ) + return ret_error( $"Item with serial {serial:#x} does not exists: {item})" ); endif foreach prop in props - var val:=item.get_member(prop[2][1]); - if (val != prop[2][2]) - return ret_error($"Member {prop[2][1]} {prop[2][2]} != {val}"); + var val := item.get_member( prop[2][1] ); + if ( val != prop[2][2] ) + return ret_error( $"Member {prop[2][1]} {prop[2][2]} != {val}" ); endif endforeach endif diff --git a/testsuite/pol/testpkgs/scheduler/exported.src b/testsuite/pol/testpkgs/scheduler/exported.src index 10925f8b5..ca130d34a 100644 --- a/testsuite/pol/testpkgs/scheduler/exported.src +++ b/testsuite/pol/testpkgs/scheduler/exported.src @@ -1,5 +1,5 @@ use os; -var calls:=0; +var calls := 0; program exportedscript() return ++calls; endprogram @@ -14,7 +14,7 @@ endfunction exported function longrunning() for i := 1 to 4 - Sleepms(10); + Sleepms( 10 ); endfor return 1; endfunction diff --git a/testsuite/pol/testpkgs/scheduler/exportedargs.src b/testsuite/pol/testpkgs/scheduler/exportedargs.src index 52dd4c729..8b552f3f2 100644 --- a/testsuite/pol/testpkgs/scheduler/exportedargs.src +++ b/testsuite/pol/testpkgs/scheduler/exportedargs.src @@ -1,17 +1,17 @@ -program exportedscript(a1, a2) - a1+="_"; - a2+="_"; - return a1+a2; +program exportedscript( a1, a2 ) + a1 += "_"; + a2 += "_"; + return a1 + a2; endprogram -exported function func(a1,a2) - a1+="_"; - a2+="_"; - return a1+a2; +exported function func( a1, a2 ) + a1 += "_"; + a2 += "_"; + return a1 + a2; endfunction -exported function funcbyref(byref a1,a2) - a1+="_"; - a2+="_"; - return a1+a2; +exported function funcbyref( byref a1, a2 ) + a1 += "_"; + a2 += "_"; + return a1 + a2; endfunction diff --git a/testsuite/pol/testpkgs/scheduler/simultaneous_loadexported.src b/testsuite/pol/testpkgs/scheduler/simultaneous_loadexported.src index cf539448e..928528618 100644 --- a/testsuite/pol/testpkgs/scheduler/simultaneous_loadexported.src +++ b/testsuite/pol/testpkgs/scheduler/simultaneous_loadexported.src @@ -1,11 +1,11 @@ use uo; -program caller(params) +program caller( params ) var exported_script := params[1]; var id := params[2]; - var res:=exported_script.call("longrunning", {}); - if (res) - setglobalproperty("#sim_loadexported{}".format(id),1); + var res := exported_script.call( "longrunning", {} ); + if ( res ) + setglobalproperty( "#sim_loadexported{}".format( id ), 1 ); else - setglobalproperty("#sim_loadexported{}".format(id),2); + setglobalproperty( "#sim_loadexported{}".format( id ), 2 ); endif endprogram diff --git a/testsuite/pol/testpkgs/scheduler/test_loadexported.src b/testsuite/pol/testpkgs/scheduler/test_loadexported.src index 729ae65f3..4046fdd98 100644 --- a/testsuite/pol/testpkgs/scheduler/test_loadexported.src +++ b/testsuite/pol/testpkgs/scheduler/test_loadexported.src @@ -7,146 +7,144 @@ program testloadexported() endprogram exported function loadexported_basic() - var script:=LoadExportedScript("exported.ecl"); - if (script[2]!=1) - return ret_error("Program did not load"); + var script := LoadExportedScript( "exported.ecl" ); + if ( script[2] != 1 ) + return ret_error( "Program did not load" ); endif - if (len(script[1].exported_functions)!=3) - return ret_error("didnt found 2 functions"); + if ( len( script[1].exported_functions ) != 3 ) + return ret_error( "didnt found 2 functions" ); endif - var res:=script[1].call("func1"); - if (res !=2) - return ret_error("func1 failed {}".format(res)); + var res := script[1].call( "func1" ); + if ( res != 2 ) + return ret_error( "func1 failed {}".format( res ) ); endif - res:=script[1].call("func2"); - if (res !=3) - return ret_error("func2 failed {}".format(res)); + res := script[1].call( "func2" ); + if ( res != 3 ) + return ret_error( "func2 failed {}".format( res ) ); endif return 1; endfunction -function copy_exported(script) - var res:=script[1].call("func1"); - if (res !=2) - return ret_error("func1 failed {}".format(res)); +function copy_exported( script ) + var res := script[1].call( "func1" ); + if ( res != 2 ) + return ret_error( "func1 failed {}".format( res ) ); endif return res; endfunction exported function loadexported_copy() - var script:=LoadExportedScript("exported.ecl"); - if (script[2]!=1) - return ret_error("Program did not load"); + var script := LoadExportedScript( "exported.ecl" ); + if ( script[2] != 1 ) + return ret_error( "Program did not load" ); endif - var res:=copy_exported(script[1]); - if (!res) + var res := copy_exported( script[1] ); + if ( !res ) return res; endif - res:=script[1].call("func2"); - if (res !=3) - return ret_error("func2 failed {}".format(res)); + res := script[1].call( "func2" ); + if ( res != 3 ) + return ret_error( "func2 failed {}".format( res ) ); endif - return 1; + return 1; endfunction exported function loadexported_critical() - set_critical(1); - var script:=LoadExportedScript("exported.ecl"); - if (script[2]!=1) - set_critical(0); - return ret_error("Program did not load"); + set_critical( 1 ); + var script := LoadExportedScript( "exported.ecl" ); + if ( script[2] != 1 ) + set_critical( 0 ); + return ret_error( "Program did not load" ); endif - if (len(script[1].exported_functions)!=3) - set_critical(0); - return ret_error("didnt found 2 functions"); + if ( len( script[1].exported_functions ) != 3 ) + set_critical( 0 ); + return ret_error( "didnt found 2 functions" ); endif - var res:=script[1].call("func1"); - if (res !=2) - set_critical(0); - return ret_error("func1 failed {}".format(res)); + var res := script[1].call( "func1" ); + if ( res != 2 ) + set_critical( 0 ); + return ret_error( "func1 failed {}".format( res ) ); endif - res:=script[1].call("func2"); - if (res !=3) - set_critical(0); - return ret_error("func2 failed {}".format(res)); + res := script[1].call( "func2" ); + if ( res != 3 ) + set_critical( 0 ); + return ret_error( "func2 failed {}".format( res ) ); endif - set_critical(0); + set_critical( 0 ); return 1; endfunction exported function loadexported_args() - var args:={"te","st"}; - var script:=LoadExportedScript("exportedargs.ecl",args); - if (script[2]!="te_st_") - return ret_error("Program did not accepted args: {}".format(script[2])); + var args := { "te", "st" }; + var script := LoadExportedScript( "exportedargs.ecl", args ); + if ( script[2] != "te_st_" ) + return ret_error( "Program did not accepted args: {}".format( script[2] ) ); endif - if (args[1]!="te" || args[2]!="st") - return ret_error("program modified args {}".format(args)); + if ( args[1] != "te" || args[2] != "st" ) + return ret_error( "program modified args {}".format( args ) ); endif - var res:=script[1].call("func",args); - if (res !="te_st_") - return ret_error("func failed {}".format(res)); + var res := script[1].call( "func", args ); + if ( res != "te_st_" ) + return ret_error( "func failed {}".format( res ) ); endif - if (args[1]!="te" || args[2]!="st") - return ret_error("func modified args {}".format(args)); + if ( args[1] != "te" || args[2] != "st" ) + return ret_error( "func modified args {}".format( args ) ); endif - res:=script[1].call("funcbyref",args); - if (res !="te_st_") - return ret_error("funcbyref failed {}".format(res)); + res := script[1].call( "funcbyref", args ); + if ( res != "te_st_" ) + return ret_error( "funcbyref failed {}".format( res ) ); endif - if (args[1]!="te_" || args[2]!="st") - return ret_error("funcbyref did not modified args {}".format(args)); + if ( args[1] != "te_" || args[2] != "st" ) + return ret_error( "funcbyref did not modified args {}".format( args ) ); endif return 1; endfunction exported function loadexported_critical_load() - set_critical(1); - var script:=LoadExportedScript("exported.ecl"); - if (script[2]!=1) - set_critical(0); - return ret_error("Program did not load"); + set_critical( 1 ); + var script := LoadExportedScript( "exported.ecl" ); + if ( script[2] != 1 ) + set_critical( 0 ); + return ret_error( "Program did not load" ); endif - set_critical(0); - var res:=script[1].call("func1"); - if (res !=2) - return ret_error("func1 failed {}".format(res)); + set_critical( 0 ); + var res := script[1].call( "func1" ); + if ( res != 2 ) + return ret_error( "func1 failed {}".format( res ) ); endif return 1; endfunction exported function loadexported_critical_call() - var script:=LoadExportedScript("exported.ecl"); - if (script[2]!=1) - return ret_error("Program did not load"); + var script := LoadExportedScript( "exported.ecl" ); + if ( script[2] != 1 ) + return ret_error( "Program did not load" ); endif - set_critical(1); - var res:=script[1].call("func1"); - if (res !=2) - set_critical(0); - return ret_error("func1 failed {}".format(res)); + set_critical( 1 ); + var res := script[1].call( "func1" ); + if ( res != 2 ) + set_critical( 0 ); + return ret_error( "func1 failed {}".format( res ) ); endif - script:=0; // gc script - set_critical(0); + script := 0; // gc script + set_critical( 0 ); return 1; endfunction exported function loadexported_simultaneous() // one of the scripts should fail to call the function, crashes otherwise - var script:=LoadExportedScript("exported.ecl"); - if (script[2]!=1) - return ret_error("Program did not load"); + var script := LoadExportedScript( "exported.ecl" ); + if ( script[2] != 1 ) + return ret_error( "Program did not load" ); endif for i := 1 to 2 - start_script("simultaneous_loadexported", { script[1], i }); + start_script( "simultaneous_loadexported", { script[1], i } ); endfor - while (!getglobalproperty("#sim_loadexported1") - || !getglobalproperty("#sim_loadexported2")) - sleepms(10); + while ( !getglobalproperty( "#sim_loadexported1" ) || !getglobalproperty( "#sim_loadexported2" ) ) + sleepms( 10 ); endwhile - if (getglobalproperty("#sim_loadexported1") + - getglobalproperty("#sim_loadexported2")!=3) - return ret_error("one call did not fail, or both failed"); + if ( getglobalproperty( "#sim_loadexported1" ) + getglobalproperty( "#sim_loadexported2" ) != 3 ) + return ret_error( "one call did not fail, or both failed" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/scheduler/test_run_script.src b/testsuite/pol/testpkgs/scheduler/test_run_script.src index 257f1cbc5..3e4527415 100644 --- a/testsuite/pol/testpkgs/scheduler/test_run_script.src +++ b/testsuite/pol/testpkgs/scheduler/test_run_script.src @@ -7,8 +7,8 @@ program test_runscript() endprogram exported function run() - if (run_script("test_run_script",{})!=1) - return ret_error("failed to run script"); + if ( run_script( "test_run_script", {} ) != 1 ) + return ret_error( "failed to run script" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/sql/setup.src b/testsuite/pol/testpkgs/sql/setup.src index edd769f77..f7595bf8a 100644 --- a/testsuite/pol/testpkgs/sql/setup.src +++ b/testsuite/pol/testpkgs/sql/setup.src @@ -7,4 +7,4 @@ if ( res != "1" ) return IGNORE_TEST; else return 1; -endif \ No newline at end of file +endif diff --git a/testsuite/pol/testpkgs/sql/test_sql.src b/testsuite/pol/testpkgs/sql/test_sql.src index 4ea581289..aebfaad4a 100644 --- a/testsuite/pol/testpkgs/sql/test_sql.src +++ b/testsuite/pol/testpkgs/sql/test_sql.src @@ -16,7 +16,9 @@ program testsql() return ret_error( $"failed to select db: {db}" ); endif - var query := mysql_query( conn, "CREATE TABLE IF NOT EXISTS db_test (`key` int(11) NOT NULL, `val` varchar(128) NOT NULL, PRIMARY KEY (`key`))" ); + var query := mysql_query( conn, + "CREATE TABLE IF NOT EXISTS db_test (`key` int(11) NOT NULL, `val` varchar(128) NOT NULL, PRIMARY KEY (`key`))" + ); if ( !query ) mysql_close( conn ); return ret_error( $"failed to create table {query}" ); @@ -47,8 +49,7 @@ exported function sqlquery() endfunction exported function sqlquery_param() - var query := mysql_query( conn, "INSERT INTO db_test VALUES (3,?), (4,?);", - { "three", "four" } ); + var query := mysql_query( conn, "INSERT INTO db_test VALUES (3,?), (4,?);", { "three", "four" } ); if ( !query ) return ret_error( $"failed to add values {query}" ); endif @@ -73,9 +74,9 @@ exported function sqlquery_param() endfunction exported function sql_escape_string() - var text:=mysql_escape_string(conn,"blubb'"); - if (text != "blubb\\'") - return ret_error( $"wrong value: {text}!=blubb\\'"); + var text := mysql_escape_string( conn, "blubb'" ); + if ( text != "blubb\\'" ) + return ret_error( $"wrong value: {text}!=blubb\\'" ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/storage/test_storage.src b/testsuite/pol/testpkgs/storage/test_storage.src index c28b3a59f..f1f74940a 100644 --- a/testsuite/pol/testpkgs/storage/test_storage.src +++ b/testsuite/pol/testpkgs/storage/test_storage.src @@ -6,127 +6,127 @@ include "testutil"; var storage; program teststorage() - storage:=CreateStorageArea("teststorage"); - CreateStorageArea("teststorage2"); - if (!storage) - return ret_error("Failed to create storage: "+storage); + storage := CreateStorageArea( "teststorage" ); + CreateStorageArea( "teststorage2" ); + if ( !storage ) + return ret_error( "Failed to create storage: " + storage ); endif - var root:=CreateRootItemInStorageArea(storage,"cnt",0xe75); - if (!root) - return ret_error("Failed to create root cnt: "+root); + var root := CreateRootItemInStorageArea( storage, "cnt", 0xe75 ); + if ( !root ) + return ret_error( "Failed to create root cnt: " + root ); endif return 1; endprogram exported function list_storage() - var r:=StorageAreas(); - if (r.count != 2) - return ret_error("Didnt found 2 storage "+r.count); + var r := StorageAreas(); + if ( r.count != 2 ) + return ret_error( "Didnt found 2 storage " + r.count ); endif return 1; endfunction exported function find_storage() - var r:=FindStorageArea("teststorage"); - if (!r) - return ret_error("Didnt found storage "+r); + var r := FindStorageArea( "teststorage" ); + if ( !r ) + return ret_error( "Didnt found storage " + r ); endif return 1; endfunction exported function find_root() - var r:=FindRootItemInStorageArea(storage, "cnt"); - if (!r) - return ret_error("Didnt found root "+r); + var r := FindRootItemInStorageArea( storage, "cnt" ); + if ( !r ) + return ret_error( "Didnt found root " + r ); endif return 1; endfunction exported function destroy_root() - var s:=findstoragearea("teststorage2"); - var root:=CreateRootItemInStorageArea(s,"cnt",0xe75); - if (!root) - return ret_error("Failed to create root cnt: "+root); + var s := findstoragearea( "teststorage2" ); + var root := CreateRootItemInStorageArea( s, "cnt", 0xe75 ); + if ( !root ) + return ret_error( "Failed to create root cnt: " + root ); endif - var r:=DestroyRootItemInStorageArea(s,"cnt"); - if (s.count !=0) - return ret_error("Storage count not 0 after destroy root: "+r+" "+s.count); + var r := DestroyRootItemInStorageArea( s, "cnt" ); + if ( s.count != 0 ) + return ret_error( "Storage count not 0 after destroy root: " + r + " " + s.count ); endif return 1; endfunction exported function add_item() - var r:=FindRootItemInStorageArea(storage, "cnt"); - if (!r) - return ret_error("Didnt found root "+r); + var r := FindRootItemInStorageArea( storage, "cnt" ); + if ( !r ) + return ret_error( "Didnt found root " + r ); endif - var oldc:=storage.totalcount; - var item:=CreateItemInContainer(r, 0x3e3f); - if (storage.totalcount!=oldc+1) - return ret_error("total count did not increase "+item); + var oldc := storage.totalcount; + var item := CreateItemInContainer( r, 0x3e3f ); + if ( storage.totalcount != oldc + 1 ) + return ret_error( "total count did not increase " + item ); endif return 1; endfunction exported function add_item_loc() - var r:=FindRootItemInStorageArea(storage, "cnt"); - if (!r) - return ret_error("Didnt found root "+r); + var r := FindRootItemInStorageArea( storage, "cnt" ); + if ( !r ) + return ret_error( "Didnt found root " + r ); endif - var oldc:=storage.totalcount; - var item := CreateItemInInventory(r, 0xf3f, 1, 80, 90); - if (!item) - return ret_error($"Could not create item: {item}"); - elseif (item.x != 80 || item.y != 90) + var oldc := storage.totalcount; + var item := CreateItemInInventory( r, 0xf3f, 1, 80, 90 ); + if ( !item ) + return ret_error( $"Could not create item: {item}" ); + elseif ( item.x != 80 || item.y != 90 ) var msg := $"Item not in expected location: item.x ({item.x}) != 80 or item.y ({item.y}) != 90"; - DestroyItem(item); - return ret_error(msg); + DestroyItem( item ); + return ret_error( msg ); endif return 1; endfunction exported function move_item() - var r:=FindRootItemInStorageArea(storage, "cnt"); - if (!r) - return ret_error("Didnt found root "+r); + var r := FindRootItemInStorageArea( storage, "cnt" ); + if ( !r ) + return ret_error( "Didnt found root " + r ); endif - var oldc:=storage.totalcount; - var item:=CreateItemAtLocation(0,0,0, 0x3e3f); - item.movable:=1; - var res:=MoveItemToContainer(item,r); - if (!res) - return ret_error("failed to move "+res); + var oldc := storage.totalcount; + var item := CreateItemAtLocation( 0, 0, 0, 0x3e3f ); + item.movable := 1; + var res := MoveItemToContainer( item, r ); + if ( !res ) + return ret_error( "failed to move " + res ); endif - if (storage.totalcount!=oldc+1) - return ret_error("total count did not increase "+res); + if ( storage.totalcount != oldc + 1 ) + return ret_error( "total count did not increase " + res ); endif return 1; endfunction exported function move_item_realm() - var r:=FindRootItemInStorageArea(storage, "cnt"); - if (!r) - return ret_error("Didnt found root "+r); + var r := FindRootItemInStorageArea( storage, "cnt" ); + if ( !r ) + return ret_error( "Didnt found root " + r ); endif - var item:=CreateItemAtLocation(0,0,0, 0x3e3f); - item.movable:=1; - if (item.realm != "britannia") - return ret_error("wrong realm "+item.realm); + var item := CreateItemAtLocation( 0, 0, 0, 0x3e3f ); + item.movable := 1; + if ( item.realm != "britannia" ) + return ret_error( "wrong realm " + item.realm ); endif - var res:=MoveItemToContainer(item,r); - if (!res) - return ret_error("failed to move "+res); + var res := MoveItemToContainer( item, r ); + if ( !res ) + return ret_error( "failed to move " + res ); endif - if (item.realm != "britannia") // TODO vector_classes will fail here on purpose - return ret_error("wrong realm in storage "+item.realm); + if ( item.realm != "britannia" ) // TODO vector_classes will fail here on purpose + return ret_error( "wrong realm in storage " + item.realm ); endif // TODO vector_classes: check some list*Location with this realm nullptr - res:=MoveObjectToLocation(item,0,0,0,flags:=MOVEOBJECT_FORCELOCATION); - if (!res) - return ret_error("failed to move back to world: "+res); + res := MoveObjectToLocation( item, 0, 0, 0, flags := MOVEOBJECT_FORCELOCATION ); + if ( !res ) + return ret_error( "failed to move back to world: " + res ); endif - if (item.realm != "britannia") - return ret_error("wrong realm back in world "+item.realm); + if ( item.realm != "britannia" ) + return ret_error( "wrong realm back in world " + item.realm ); endif return 1; endfunction diff --git a/testsuite/pol/testpkgs/webserver/www/test.src b/testsuite/pol/testpkgs/webserver/www/test.src index 948b25d2a..a667be304 100644 --- a/testsuite/pol/testpkgs/webserver/www/test.src +++ b/testsuite/pol/testpkgs/webserver/www/test.src @@ -2,36 +2,36 @@ use os; use http; program HTMLPage() - var testPid := QueryParam("testPid"); - var headers := QueryParam("headers"); - var status := QueryParam("status"); - var statusText := QueryParam("statusText"); - var body := QueryParam("body"); - var order := QueryParam("order") ?: "status,headers,body"; + var testPid := QueryParam( "testPid" ); + var headers := QueryParam( "headers" ); + var status := QueryParam( "status" ); + var statusText := QueryParam( "statusText" ); + var body := QueryParam( "body" ); + var order := QueryParam( "order" ) ?: "status,headers,body"; - var scriptResponse := struct{}; + var scriptResponse := struct{}; - foreach what in (SplitWords(order, ",")) - case(what) - "status": - if (status) - scriptResponse.status := WriteStatus(CInt(status), statusText ?: ""); - endif - "headers": - if (headers) - headers := UnpackJSON(headers); - foreach header in headers - scriptResponse.headers := WriteHeader(header.name, header.value); - endforeach - endif - "body": - if (body) - scriptResponse.body := WriteHtmlRaw(CStr(body)); - endif - endcase - endforeach + foreach what in ( SplitWords( order, "," ) ) + case ( what ) + "status": + if ( status ) + scriptResponse.status := WriteStatus( CInt( status ), statusText ?: "" ); + endif + "headers": + if ( headers ) + headers := UnpackJSON( headers ); + foreach header in headers + scriptResponse.headers := WriteHeader( header.name, header.value ); + endforeach + endif + "body": + if ( body ) + scriptResponse.body := WriteHtmlRaw( CStr( body ) ); + endif + endcase + endforeach - if (testPid) - GetProcess(CInt(testPid)).SendEvent(scriptResponse); - endif + if ( testPid ) + GetProcess( CInt( testPid ) ).SendEvent( scriptResponse ); + endif endprogram