33 | { $i = $i + 1; endwhile }
34 | { pit.include($__htmldir__ + '/other.html') }
35 | { pit.include($__htmldir__ + '/other.html', \{'foo': 'bar'\}) }
36 |
37 |
--------------------------------------------------------------------------------
/doc/11_advance/07_shutdown_event.md:
--------------------------------------------------------------------------------
1 | # Shutdown event
2 | Shutdown event is a system to set some functions to be runed in end of program.
3 |
4 | For example:
5 |
6 | ```bash
7 | # this function will be runed in the end of program
8 | func the_end
9 | println('The end')
10 | endfunc
11 |
12 | # register this function to shutdown event
13 | register_shutdown(the_end)
14 |
15 | println('hello')
16 | println('world')
17 | ```
18 |
19 | output:
20 |
21 | ```
22 | hello
23 | world
24 | the end
25 | ```
26 |
27 | In the above example, we used `register_shutdown` function to set function `the_end` as shutdown event. this function will be runed in the end of program.
28 |
29 | Also you can set more than 1 function:
30 |
31 | ```bash
32 | func end1
33 | println('first end')
34 | endfunc
35 |
36 | func end2
37 | println('second end')
38 | endfunc
39 |
40 | register_shutdown(end1)
41 | register_shutdown(end2)
42 | ```
43 |
44 | output:
45 |
46 | ```
47 | first end
48 | second end
49 | ```
50 |
--------------------------------------------------------------------------------
/doc/10_modules/17_python_standard_modules.md:
--------------------------------------------------------------------------------
1 | # Python standard modules
2 | you can use this python standard modules in pashmak directly in your code:
3 |
4 | - `os`
5 | - `sys`
6 | - `time`
7 | - `hashlib`
8 | - `random`
9 | - `datetime`
10 | - `json`
11 | - `http`
12 | - `base64`
13 | - `socket`
14 | - `socketserver`
15 | - `math`
16 | - `pprint`
17 | - `subprocess`
18 | - `sqlite3`
19 | - `urllib`
20 | - `platform`
21 | - `mimetypes`
22 | - `re`
23 | - `pickle`
24 |
25 | for example:
26 |
27 | ```bash
28 | println(os.getuid())
29 | println(random.random())
30 | println('hash is ' + hashlib.sha256('hello'.encode()).hexdigest())
31 | $cwd = os.getcwd()
32 | $time = time.time() - 100
33 | # ...
34 | ```
35 |
36 | this is very useful!
37 |
38 | Also you can use `py_load_module` function.
39 | if you want to import a module that not imported by default, you can use this function.
40 |
41 | Example:
42 |
43 | ```bash
44 | $module = py_load_module('module_name')
45 | $module->func_1()
46 | # ...
47 | ```
48 |
49 |
--------------------------------------------------------------------------------
/src/helloworld/__init__.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # __init__.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | if $__ismain__
24 | println('Hello world!')
25 | endif
26 |
--------------------------------------------------------------------------------
/src/serve/__init__.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # __init__.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | if $__ismain__
24 | import_run @web.server
25 | endfunc
26 |
27 |
--------------------------------------------------------------------------------
/doc/11_advance/12_cloning_objects.md:
--------------------------------------------------------------------------------
1 | # Cloning objects
2 | If you put a object into other variables, that will be pointer to original variable.
3 |
4 | Look at this example:
5 |
6 | ```bash
7 | $a = {'foo': 'bar'} # a dictionary
8 | $b = $a
9 |
10 | println($a['foo']) # `bar`
11 | println($b['foo']) # `bar`
12 |
13 | # we change `$b`:
14 | $b['foo'] = 'new'
15 |
16 | println($b['foo']) # `new`
17 |
18 | println($a['foo']) # `new`!
19 | ```
20 |
21 | In the above example, why after changing `$b`, also `$a` was changed? Because we put `$a` into `$b`. now, `$b` points to real `$a`.(means it is not a copy).
22 |
23 | But how to clone objects? We should use `clone` function:
24 |
25 |
26 | ```bash
27 | $a = {'foo': 'bar'} # a dictionary
28 |
29 | # using clone function
30 | $b = clone($a)
31 |
32 | println($a['foo']) # `bar`
33 | println($b['foo']) # `bar`
34 |
35 | # we change `$b`:
36 | $b['foo'] = 'new'
37 |
38 | println($b['foo']) # `new`
39 |
40 | println($a['foo']) # `bar` (the old value)
41 | ```
42 |
43 |
--------------------------------------------------------------------------------
/examples/ask_name.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # ask_name.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | print('what is your name? ')
24 | $name = read()
25 | println('hello ' + $name)
26 |
--------------------------------------------------------------------------------
/doc/10_modules/01_hash.md:
--------------------------------------------------------------------------------
1 | # hash module
2 | with hash module, you can calculate hash sum of values:
3 |
4 | ```bash
5 | import @hash
6 |
7 | hash.sha256("hello") # also you can use hash.md5 and...
8 | println(^) # output: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
9 | # OR
10 | println(hash.sha256("hello"))
11 | ```
12 |
13 | ### how it works?
14 | first, we call `hash.sha256` and pass `hello` string as argument (or put it in mem) to calculate sha256 hash. then, this function calculates hash sum of mem value and puts that into the mem. now you can access sum of that from mem.
15 |
16 | ### another hash algos
17 | - hash.blake2b(string)
18 | - hash.blake2s(string)
19 | - hash.md5(string)
20 | - hash.sha1(string)
21 | - hash.sha224(string)
22 | - hash.sha256(string)
23 | - hash.sha384(string)
24 | - hash.sha3_224(string)
25 | - hash.sha3_256(string)
26 | - hash.sha3_384(string)
27 | - hash.sha3_512(string)
28 | - hash.sha512(string)
29 | - hash.shake_128(string, length)
30 | - hash.shake_256(string, length)
31 |
--------------------------------------------------------------------------------
/tests/stdlib/assert/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | assert function raises error when value is False
25 | --file--
26 | assert 2 == 3
27 | --with-error--
28 | 'AssertError'
--------------------------------------------------------------------------------
/tests/sys/001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # sys.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | sys module works
25 |
26 | --file--
27 | import @sys
28 |
29 | println(sys.path.list())
30 |
31 | sys.path.add('/tmp')
32 |
--------------------------------------------------------------------------------
/tests/eval/eval.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # eval.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | eval command working
25 |
26 | --file--
27 | eval 'print "hello from eval"'
28 |
29 | --output--
30 | 'hello from eval'
31 |
--------------------------------------------------------------------------------
/tests/module/import/bug001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import command with () and @module without quotes
25 |
26 | --file--
27 | import (@sys,@test, @hash ,@time)
28 |
--------------------------------------------------------------------------------
/tests/stdlib/assert/1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | assert function raises error when value is False (2)
25 | --file--
26 | assert 1 > 10
27 | --with-error--
28 | 'AssertError'
--------------------------------------------------------------------------------
/tests/stdlib/assert/2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | assert function raises error when value is False (3)
25 | --file--
26 | assert False
27 | --with-error--
28 | 'AssertError'
--------------------------------------------------------------------------------
/tests/core/syntax006.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax006.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | endtry without opened block raises error
25 |
26 | --file--
27 | endtry
28 |
29 | --with-error--
30 | "SyntaxError"
31 |
--------------------------------------------------------------------------------
/tests/io/print.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # print.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | print functions working
25 |
26 | --file--
27 | println 'hello'
28 | print 'hello'
29 |
30 | --output--
31 | 'hello\nhello'
32 |
--------------------------------------------------------------------------------
/tests/stdlib/exit1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # exit1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib exit function exits with default exit code
25 |
26 | --file--
27 |
28 | exit
29 |
30 | --exit-code--
31 |
32 | 0
33 |
--------------------------------------------------------------------------------
/tests/core/syntax0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | syntax space handling working
25 | --file--
26 |
27 | print 'hello world'
28 |
29 | --output--
30 |
31 | "hello world"
32 |
--------------------------------------------------------------------------------
/tests/core/syntax003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | endfunc without opened block raises error
25 |
26 | --file--
27 | endfunc
28 |
29 | --with-error--
30 | "SyntaxError"
31 |
--------------------------------------------------------------------------------
/tests/core/syntax004.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax004.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | endclass without opened block raises error
25 |
26 | --file--
27 | endclass
28 |
29 | --with-error--
30 | "SyntaxError"
31 |
--------------------------------------------------------------------------------
/tests/io/read/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | read command working without argument
25 |
26 | --file--
27 | read
28 |
29 | --stdin--
30 | ['test']
31 |
32 | --mem--
33 | 'test'
34 |
--------------------------------------------------------------------------------
/tests/io/read/5.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 5.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | read command can read value on mem
25 |
26 | --file--
27 | read
28 |
29 | --stdin--
30 | ['pashmak']
31 |
32 | --mem--
33 | 'pashmak'
34 |
--------------------------------------------------------------------------------
/tests/stdlib/example1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # example1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | Example test for stdlib (2)
25 |
26 | --file--
27 |
28 | print 'hello ' + $name
29 |
30 | --with-error--
31 | 'VariableError'
--------------------------------------------------------------------------------
/tests/stdlib/exit0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # exit0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib exit function exits with specify exit code
25 |
26 | --file--
27 |
28 | exit 5
29 |
30 | --exit-code--
31 |
32 | 5
33 |
--------------------------------------------------------------------------------
/tests/examples/array.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # array.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | Test array example
25 | --file--
26 | import 'examples/array.pashm'
27 |
28 | --output--
29 |
30 | 'parsa\npashmak\nsomething\n'
31 |
--------------------------------------------------------------------------------
/doc/08_class_and_oop/05_complicated_declaration.md:
--------------------------------------------------------------------------------
1 | # Complicated class declaration
2 | You can declare class-in-class (like functions).
3 |
4 | Look at this example:
5 |
6 | ```bash
7 | class Foo
8 | $name = 'the foo'
9 |
10 | class Bar
11 | $name = 'the bar'
12 | endclass
13 | endclass
14 |
15 | println(Foo()->name)
16 | println(Bar()->name)
17 | ```
18 |
19 | output:
20 |
21 | ```
22 | the foo
23 | the bar
24 | ```
25 |
26 | Also look at this example:
27 |
28 | ```bash
29 | class First
30 | $name = 'first'
31 | class Second
32 | $name = 'second'
33 |
34 | class Last
35 | $name = 'last'
36 | endclass
37 |
38 | class Person
39 | $name = 'person'
40 | endclass
41 | endclass
42 |
43 | $the_second = Second()
44 | endclass
45 |
46 | println(First()->name)
47 | println(Second()->name)
48 | println(Last()->name)
49 | println(Person()->name)
50 |
51 | println(First()->the_second->name)
52 | ```
53 |
54 | output:
55 |
56 | ```
57 | first
58 | second
59 | last
60 | person
61 | second
62 | ```
63 |
--------------------------------------------------------------------------------
/tests/core/syntax005.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax005.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | endnamespace without opened block raises error
25 |
26 | --file--
27 | endnamespace
28 |
29 | --with-error--
30 | "SyntaxError"
31 |
--------------------------------------------------------------------------------
/tests/function/undefined_func.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # undefined_func.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | program raises error while calling undefined function
25 | --file--
26 | undefined_func
27 | --with-error--
28 | 'NameError'
--------------------------------------------------------------------------------
/tests/section/error2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | section system raises error while trying to goto not founded section
25 | --file--
26 | goto not_found
27 | --with-error--
28 | 'SectionError'
--------------------------------------------------------------------------------
/tests/stdlib/assert/3.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 3.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | assert function raises error when value is False (4)
25 | --file--
26 | $age = 18
27 | assert $age > 30
28 | --with-error--
29 | 'AssertError'
--------------------------------------------------------------------------------
/tests/stdlib/eval.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # eval.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib eval function working
25 | --file--
26 |
27 | eval "print 'output from eval'"
28 |
29 | --output--
30 |
31 | 'output from eval'
32 |
--------------------------------------------------------------------------------
/tests/tryendtry/error2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | try command raises syntax error correctly
25 |
26 | --file--
27 | try; gfdhghgfhf; endtry
28 |
29 | --with-error--
30 | 'ArgumentError'
--------------------------------------------------------------------------------
/tests/array/pop.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # pop.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | $array->pop() works
25 | --file--
26 | $names = ['pashmak', 'parsa']
27 | $names->pop(1)
28 | println($names)
29 | --output--
30 | "['pashmak']\n"
31 |
--------------------------------------------------------------------------------
/tests/module/import/error_2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error_2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import command raises error when variable not found
25 | --file--
26 | import $not_found
27 | --with-error--
28 | 'VariableError'
29 |
--------------------------------------------------------------------------------
/tests/section/error3.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error3.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | section system raises error while trying to gotoif not founded section
25 | --file--
26 | gotoif not_found
27 | --with-error--
28 | 'SectionError'
--------------------------------------------------------------------------------
/examples/will_be_include.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # will_be_include.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | println('i am included')
24 |
25 | $included_var = 'included value'
26 |
27 | func testfunc()
28 | println('i am included func')
29 | endfunc
30 |
--------------------------------------------------------------------------------
/tests/module/import/error_3.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error_3.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import command raises error when argument syntax is not valid
25 | --file--
26 | import hhghgjghj
27 | --with-error--
28 | 'NameError'
29 |
--------------------------------------------------------------------------------
/tests/stdlib/die-bug-001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # die-bug-001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | die() message can be non string
25 |
26 | --file--
27 |
28 | die([
29 | 'a', 'b'
30 | ])
31 |
32 | --output--'
33 | "['a', 'b']"
34 |
--------------------------------------------------------------------------------
/tests/stdlib/raise.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # raise.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib raise function raises error
25 |
26 | --file--
27 |
28 | raise(Error('SomeError', 'this is error'))
29 |
30 | --with-error--
31 | 'SomeError'
--------------------------------------------------------------------------------
/tests/core/null.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # null.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | keyword `null` working correct
25 |
26 | --file--
27 |
28 | println(null == None)
29 | println(null is None)
30 |
31 | --output--
32 | """True
33 | True
34 | """
--------------------------------------------------------------------------------
/tests/module/import/bug002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | parser parses import_once command like import command
25 |
26 | --file--
27 |
28 | import_once @hash, @time
29 | import_once(@random ,@stdlib)
30 |
--------------------------------------------------------------------------------
/tests/stdlib/import.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # import.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib import function working
25 |
26 | --file--
27 |
28 | import "examples/will_be_include.pashm"
29 |
30 | --output--
31 |
32 | 'i am included\n'
33 |
--------------------------------------------------------------------------------
/tests/tryendtry/error3.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error3.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | try command raises error when argment section is not found
25 | --file--
26 | try somesection; gfdhghgfhf; endtry
27 | --with-error--
28 | 'SectionError'
--------------------------------------------------------------------------------
/tests/io/read/3.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 3.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | read command can read data and put it in a variable
25 | --file--
26 | $input = read(); print $input
27 | --stdin--
28 | ['pashmak']
29 | --output--
30 | 'pashmak'
31 |
--------------------------------------------------------------------------------
/tests/core/runtime_error.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # runtime_error.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | runtime error is raising when there is syntax error
25 |
26 | --file--
27 |
28 | mem 'hello world; print ^
29 |
30 | --with-error--
31 | 'SyntaxError'
--------------------------------------------------------------------------------
/tests/core/syntax1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | syntax comments working
25 |
26 | --file--
27 |
28 | # some comment
29 | print 'hello world' # another comment
30 |
31 | --output--
32 |
33 | "hello world"
34 |
--------------------------------------------------------------------------------
/tests/function/bug001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | using empty () while declaring function bug
25 |
26 | --file--
27 | func hi()
28 | println 'hello'
29 | endfunc
30 |
31 | hi()
32 |
33 | --output--
34 | "hello\n"
--------------------------------------------------------------------------------
/tests/stdlib/eval-bug001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # eval-bug001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | eval command frame bug is fixed
25 |
26 | --file--
27 | $name = 'parsa'
28 | eval 'println "hello " + $name'
29 |
30 | --output--
31 | 'hello parsa\n'
32 |
--------------------------------------------------------------------------------
/tests/test-module/1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | test module assertTrue function raises error when value is False
25 | --file--
26 | import '@test'
27 | test.assertTrue 3 == 7
28 | --with-error--
29 | 'AssertError'
30 |
--------------------------------------------------------------------------------
/tests/test-module/2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | test module assertFalse function raises error when value is True
25 | --file--
26 | import '@test'
27 | test.assertFalse 2 == 2
28 | --with-error--
29 | 'AssertError'
30 |
--------------------------------------------------------------------------------
/src/sys/__init__.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # sys.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | import @sys.path
24 |
25 | namespace sys
26 | $pashmakinfo = {"version": version.version, "pythoninfo": sys.version.replace("\\n", "")}
27 | $pashmakexe = sys.argv[0]
28 | endns
29 |
--------------------------------------------------------------------------------
/tests/test-module/3.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 3.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | test module assertEquals function raises error when condition is False
25 | --file--
26 | import '@test'
27 | test.assertEquals 2, 8
28 | --with-error--
29 | 'AssertError'
30 |
--------------------------------------------------------------------------------
/tests/module/import/module_not_found_error.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # module_not_found_error.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | include command raises error when module not found
25 | --file--
26 | import '@notfound233445'
27 | --with-error--
28 | 'ModuleError'
29 |
--------------------------------------------------------------------------------
/tests/module/import/multi-import-2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # multi-import-2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | multi import syntax works
25 | --file--
26 | import @sys,@time ,@test, @hash
27 | import @sys,@time,@test,@hash
28 | import @sys,@time ,@test, @hash
29 |
--------------------------------------------------------------------------------
/tests/test-module/4.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 4.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | test module assertNotEquals function raises error when condition is True
25 | --file--
26 | import '@test'
27 | test.assertNotEquals 2, 2
28 | --with-error--
29 | 'AssertError'
30 |
--------------------------------------------------------------------------------
/tests/module/import/bug006.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug006.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import command () syntax bug is fixed
25 |
26 | --file--
27 |
28 | func hello()
29 | return '@os'
30 | endfunc
31 |
32 | import hello()
33 | import(hello())
34 |
35 |
--------------------------------------------------------------------------------
/tests/classes/004-syntax-error.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 004-syntax-error.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | class raises error when body codes has syntax error
25 | --file--
26 | class Foo
27 | $name
28 | gdfghfjh
29 | endclass
30 | --with-error--
31 | 'NameError'
--------------------------------------------------------------------------------
/tests/consts/002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | consts working with namespaces
25 | --file--
26 | namespace app
27 | $&thevar = 'hello world'
28 | endns
29 |
30 | $app.&thevar = 'new value'
31 |
32 | --with-error--
33 | 'ConstError'
--------------------------------------------------------------------------------
/tests/core/literals-error-in-names002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # literals-error-in-names002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | class name cannot have literal chars
25 |
26 | --file--
27 | class Pe[rs)o*n
28 |
29 | endclass
30 |
31 | --with-error--
32 | "SyntaxError"
33 |
--------------------------------------------------------------------------------
/tests/core/literals-error-in-names003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # literals-error-in-names003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function name cannot have literal chars
25 |
26 | --file--
27 | func myf.u{nc
28 |
29 | endfunc
30 |
31 | --with-error--
32 | "SyntaxError"
33 |
--------------------------------------------------------------------------------
/tests/module/import/1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import command is working with variable as argument
25 |
26 | --file--
27 | $path = 'examples/will_be_include.pashm'
28 | import $path;
29 |
30 | --output--
31 | 'i am included\n'
32 |
--------------------------------------------------------------------------------
/tests/stdlib/die001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # die001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function die() works (1)
25 |
26 | --file--
27 |
28 | println('A')
29 |
30 | die()
31 |
32 | println('B')
33 |
34 | --output--
35 | """A
36 | """
37 |
38 | --exit-code--
39 | 1
40 |
--------------------------------------------------------------------------------
/tests/time/001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # time.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | ime module is working
25 | --file--
26 | import '@time'
27 | time.time
28 | time.sleep 0.01
29 | time.ctime
30 | time.gmtime
31 | time.localtime
32 | # ONLY NEEDS TO BE RUNED WITHOUT ERROR
33 |
--------------------------------------------------------------------------------
/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
21 |
--------------------------------------------------------------------------------
/tests/array/append.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # append.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | $array->append() works
25 |
26 | --file--
27 | $names = ['pashmak', 'parsa']
28 | $names->append('newname')
29 | println($names)
30 | --output--
31 | "['pashmak', 'parsa', 'newname']\n"
32 |
--------------------------------------------------------------------------------
/tests/core/literals-error-in-names001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # literals-error-in-names001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | namespace name cannot have literal chars
25 |
26 | --file--
27 | namespace Hel.%h{lo
28 |
29 | endns
30 |
31 | --with-error--
32 | "SyntaxError"
33 |
--------------------------------------------------------------------------------
/tests/if/003-without-endif.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 003-without-endif.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | program will not be crashed when if block is not close
25 |
26 | --file--
27 | if True
28 | print 'yes'
29 | else
30 | print 'no'
31 |
32 | --output--
33 | 'yes'
--------------------------------------------------------------------------------
/tests/module/import/bug003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | directory import bug is fixed
25 |
26 | --file--
27 |
28 | import $__dir__ + '/tests/test-module-path/somedir'
29 |
30 | --output--
31 | """I am a imported directory
32 | """
33 |
--------------------------------------------------------------------------------
/tests/module/path/error0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # error0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | module path system without any path working
25 | --pyinit--
26 | import os
27 | os.environ['PASHMAKINFO'] = ''
28 | --file--
29 | import '@testdir1'
30 | --with-error--
31 | 'ModuleError'
--------------------------------------------------------------------------------
/src/core/version.py:
--------------------------------------------------------------------------------
1 | #
2 | # version.py
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | """ Version of pashmak """
24 |
25 | # pashmak version
26 | # while you are releasing new version,
27 | # you should bump it
28 | # also this will put version into $sys.pashmakinfo['version']
29 | version = 'v0.7.3'
30 |
--------------------------------------------------------------------------------
/tests/cli_args/argv.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # argv.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | The $argv variable has correct value
25 |
26 | --file--
27 | print($argv[0])
28 | print($argv[1])
29 | print($argc)
30 |
31 | --cliargs--
32 | ['hi', 'bye']
33 |
34 | --output--
35 | 'hibye2'
36 |
--------------------------------------------------------------------------------
/tests/test-module-path/foo.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # foo.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | script returned value will be returned by import()
25 |
26 | --file--
27 |
28 | println import_once($__dir__ + '/tests/test-module-path/bar.pashm')
29 |
30 | --output--
31 | "parsa\n"
32 |
--------------------------------------------------------------------------------
/doc/12_web/02_env_vars.md:
--------------------------------------------------------------------------------
1 | # Environment variables in web
2 | There is some environment variables in web system that will be passed to your script.
3 |
4 | This envvars contain some informations.
5 |
6 | | Name | Description | Example value |
7 | |------|-------------|---------------|
8 | | `REQUEST_URI` | The requested uri | `/foo/bar` |
9 | | `REQUEST_METHOD` | The http request method | `GET` or `POST` |
10 | | `REMOTE_ADDR` | The remote(client) address(ip) | `1.2.3.4` |
11 | | `REMOTE_PORT` | The remote port | `5674` |
12 | | `SERVER_ADDR` | Address of the server | `127.0.0.1` |
13 | | `SERVER_PORT` | The server port | `80` or `8000` |
14 | | `SERVER_PROTOCOL` | The server protocol | `HTTP/1.0` |
15 | | `DOCUMENT_ROOT` | The root of directory that web server serves that | `/var/www/html` |
16 | | `SCRIPT_FILENAME` | Real path of the current running Pashmak script | `/var/www/html/app.pashm` |
17 | | `SCRIPT_NAME` | Script name (not full path) | `/app.pashm` |
18 | | `QUERY_STRING` | Part of URL after `?` (The get data raw query string. use `$web.get`) | `foo=bar&hi=bye` |
19 | | `POST_RAW_DATA` | The raw post data (use `$web.post`) | `foo=bar&hi=bye` |
20 |
--------------------------------------------------------------------------------
/tests/classes/inheritance002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # inheritance002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | undefined class error will be raised when parent class not found
25 |
26 | --file--
27 |
28 | class Test < Undefined
29 | endclass
30 |
31 | --with-error--
32 | "ClassError"
33 |
--------------------------------------------------------------------------------
/tests/module/import/bug003-2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug003-2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | directory without `__init__.pashm` cannot be imported
25 |
26 | --file--
27 |
28 | import $__dir__ + '/tests/test-module-path/somedir/dir2'
29 |
30 | --with-error--
31 | "FileError"
32 |
--------------------------------------------------------------------------------
/tests/variables/isset.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # isset.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | isset command is working
25 |
26 | --file--
27 |
28 | println(isset('name'))
29 |
30 | $name = 'parsa'
31 |
32 | println(isset('name'))
33 |
34 | --output--
35 | """False
36 | True
37 | """
38 |
--------------------------------------------------------------------------------
/examples/handle_error.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # handle_error.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | try handle_error
24 | println('A')
25 | fghgfhg
26 | println('B')
27 | endtry
28 |
29 | goto after_handle_error; section handle_error
30 | println('the error!')
31 | section after_handle_error
32 |
--------------------------------------------------------------------------------
/tests/classes/super-functions-002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # super-functions-002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | func.delete function raises error when function not found
25 |
26 | --file--
27 |
28 | func.delete('test_not_found_function')
29 |
30 | --with-error--
31 | "FunctionNotFound"
--------------------------------------------------------------------------------
/tests/function/super-functions-002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # super-functions-002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | func.delete function raises error when function not found
25 |
26 | --file--
27 |
28 | func.delete('test_not_found_function')
29 |
30 | --with-error--
31 | "FunctionNotFound"
--------------------------------------------------------------------------------
/tests/stdlib/example0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # example0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | Example test for stdlib for printing
25 |
26 | --file--
27 |
28 | $name = 'parsa'
29 | print 'hello ' + $name
30 | print str(2*2) + ' is sum'
31 |
32 | --output--
33 |
34 | 'hello parsa4 is sum'
35 |
--------------------------------------------------------------------------------
/doc/00_basics/03_constants.md:
--------------------------------------------------------------------------------
1 | # Constants
2 | Constants (consts) are even like variables, but one thing is different in constants, **Constant value cannot be changed**.
3 |
4 | for example:
5 |
6 | ```bash
7 | # declare the const
8 | $&name = 'the value'
9 |
10 | println($&name)
11 | ```
12 |
13 | output:
14 |
15 | ```
16 | the value
17 | ```
18 |
19 | To declare consts, you only need to put a `&` in the name of variable(location of that is not important).
20 |
21 | ```bash
22 | $&const1 = 123
23 | $&const2 = 'fsgdf'
24 | # ...
25 | ```
26 |
27 | When we try to change value of the const, we will get error:
28 |
29 | ```bash
30 | $&name = 'the name'
31 |
32 | $&name = 'new value'
33 | ```
34 |
35 | output:
36 |
37 | ```
38 | ConstError: "$&name" is const and cannot be changed...
39 | ```
40 |
41 | also you can **declare** a constant, but set value of that later.
42 |
43 | for example:
44 |
45 | ```bash
46 | $&name # only declare constant, default value is `None`
47 |
48 | # set value
49 | $&name = 'parsa'
50 |
51 | println($&name)
52 | ```
53 |
54 | output:
55 |
56 | ```
57 | parsa
58 | ```
59 |
60 | But in the second time, error will be raised.
61 |
--------------------------------------------------------------------------------
/doc/07_files/00_working_with_files.md:
--------------------------------------------------------------------------------
1 | # Working with files
2 | working with files in Pashmak is so easy.
3 |
4 | we have 4 main operations on files: Open, Read, Write, Close
5 |
6 | look at this example for reading content of a file:
7 |
8 | ```bash
9 | $my_file = open('/path/to/some/file.txt', 'r')
10 | println($my_file->read())
11 | $my_file->close()
12 | ```
13 |
14 | In above example, we opened our file, read content and then we closed that.
15 |
16 | the `$file->read()`, the `read` method reads content of file and returns that.
17 |
18 | you can put that in a variable:
19 |
20 | ```bash
21 | $content = $file->read()
22 | ```
23 |
24 | to write content of a file, we can use `write` method:
25 |
26 | ```bash
27 | $my_file = open('/path/to/some/file.txt', 'w')
28 | $my_file->write('new content')
29 | $my_file->close()
30 | ```
31 |
32 | The second argument for opening file is type of opening. `r` means Read and `w` means write.
33 |
34 | Also you can use `fopen` function instead of `open`. this is not different, just is an alias.
35 |
36 | The file objects in Pashmak are handled by python you can use all of python file features in Pashmak like python.
37 |
--------------------------------------------------------------------------------
/doc/10_modules/02_time.md:
--------------------------------------------------------------------------------
1 | # time module
2 | with this module, you can work with time.
3 |
4 | ### time.time
5 | this function gives you current UNIX timestamp:
6 |
7 | ```bash
8 | import @time
9 |
10 | println(time.time()) # output is some thing like this: `1600416438.687201`
11 | ```
12 |
13 | when you call this function, this function puts the unix timestamp into mem and you can access and use that.
14 |
15 | ### time.sleep
16 | this function sleeps for secounds:
17 |
18 | ```bash
19 | import @time
20 |
21 | time.sleep(2) # sleeps for 2 secounds
22 | # mem 2.4; time.sleep; # sleepss for 2.4 secounds
23 | ```
24 |
25 | when you run this script, program waits for 2 secounds and then will continued
26 |
27 | with this function, you can wait for secounds.
28 |
29 | you have to put a int or float into mem or pass as argument and next call `time.sleep` function, then program will sleep for value of `mem` as secounds
30 |
31 | ### Another time functions
32 | - time.ctime
33 | - time.gmtime
34 | - time.localtime
35 |
36 | ### cli usage
37 | You can use this module in command line to see current UNIX timestamp:
38 |
39 | ```bash
40 | $ pashmak @time
41 | ```
42 |
--------------------------------------------------------------------------------
/tests/classes/method003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # method003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | system raises error when trying to call a method on non-class object
25 |
26 | --file--
27 |
28 | $p = 'some string'
29 |
30 | mem $p->somemethod()
31 |
32 | --with-error--
33 | 'AttributeError'
34 |
--------------------------------------------------------------------------------
/tests/function/func_arg_variable.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # func_arg_variable.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | functions argument variable is working
25 |
26 | --file--
27 | func say_hi($name)
28 | println $name
29 | endfunc
30 |
31 | say_hi 'parsa'
32 |
33 | --output--
34 | 'parsa\n'
35 |
--------------------------------------------------------------------------------
/tests/function/return002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # return002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | return command exits program when is used in main program frame
25 |
26 | --file--
27 | print 'first'
28 | return 100
29 | print 'last'
30 |
31 | --output--
32 | 'first'
33 |
34 | --exit-code--
35 | 100
--------------------------------------------------------------------------------
/tests/module/import/bug004.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug004.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | module variable conflicting bug is fixed
25 |
26 | --file--
27 |
28 | func hello()
29 | import @sys
30 | println($sys.pashmakinfo['version'])
31 | endfunc
32 |
33 | hello()
34 | hello()
35 |
--------------------------------------------------------------------------------
/tests/stdlib/py-load-module-001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # py-load-module-001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function py_load_module() works
25 |
26 | --file--
27 |
28 | $uuid = py_load_module('uuid')
29 |
30 | println $uuid->UUID
31 |
32 | --output--
33 | "\n"
34 |
35 |
--------------------------------------------------------------------------------
/tests/consts/001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | consts working correct
25 |
26 | --file--
27 | $&name = 'hello world'
28 |
29 | println $&name
30 |
31 | $&name = 'new value'
32 |
33 | --output--
34 | """hello world
35 | """
36 |
37 | --with-error--
38 | 'ConstError'
--------------------------------------------------------------------------------
/tests/module/import/example_hash_module.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # example_hash_module.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | modules can be imported
25 | --file--
26 | import @hash
27 | hash.sha256 'hello'; print ^
28 | --output--
29 | '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
30 |
--------------------------------------------------------------------------------
/tests/stdlib/die002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # die002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function die() works (2)
25 |
26 | --file--
27 |
28 | println('A')
29 |
30 | die("Good bye\n")
31 |
32 | println('B')
33 |
34 | --output--
35 | """A
36 | Good bye
37 | """
38 |
39 | --exit-code--
40 | 1
41 |
--------------------------------------------------------------------------------
/tests/stdlib/var_dump-001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # var_dump-001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function var_dump() works correct
25 |
26 | --file--
27 |
28 | $name = 'pashmak'
29 |
30 | var_dump($name)
31 |
32 | var_dump('other value')
33 |
34 | --output--
35 | "'pashmak'\n'other value'\n"
36 |
--------------------------------------------------------------------------------
/tests/classes/014-super-error.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 014-super-error.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | super() raises error when parent not exists
25 |
26 | --file--
27 |
28 | class Test
29 | endclass
30 |
31 | $a = Test()
32 |
33 | $a->super('Something')
34 |
35 | --with-error--
36 | "SuperError"
--------------------------------------------------------------------------------
/tests/classes/method-bug-001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # method-bug-001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | method not found error bug is fixed
25 |
26 | --file--
27 |
28 | class Hello
29 | endclass
30 |
31 | $a = Hello()
32 |
33 | mem $a->ffghfgjghjh()
34 |
35 | --with-error--
36 | "AttributeError"
37 |
--------------------------------------------------------------------------------
/tests/eval/eval2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # eval2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | eval function do not creates new frame and runs on current frame
25 |
26 | --file--
27 | $name = 'hi'
28 | println $name
29 | eval "$name = 'the new'"
30 | println $name
31 |
32 | --output--
33 | """hi
34 | the new
35 | """
--------------------------------------------------------------------------------
/tests/examples/get_password1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # get_password1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | Test get password example with valid password
25 |
26 | --file--
27 | import 'examples/get_password.pashm'
28 |
29 | --stdin--
30 | ['123']
31 |
32 | --output--
33 | 'enter the password: WELCOME!\n'
34 |
--------------------------------------------------------------------------------
/tests/namespace/bug002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | $__dir__, $__file__ and $__ismain__ variables bug in namespace is fixed
25 |
26 | --file--
27 |
28 | func hi()
29 | endfunc
30 |
31 | hi()
32 |
33 | ns app
34 | hi()
35 |
36 | endns
37 |
38 | --vars--
39 | {}
40 |
--------------------------------------------------------------------------------
/tests/section/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | section system is working as If structure
25 | --file--
26 | println 'before start'
27 | goto 10
28 | println 'it will not show'
29 | section 10
30 | println 'this is end'
31 | --output--
32 | 'before start\nthis is end\n'
33 |
--------------------------------------------------------------------------------
/tests/stdlib/die003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # die003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function die() works (2)
25 |
26 | --file--
27 |
28 | println('A')
29 |
30 | die("Good bye\n", 11)
31 |
32 | println('B')
33 |
34 | --output--
35 | """A
36 | Good bye
37 | """
38 |
39 | --exit-code--
40 | 11
41 |
--------------------------------------------------------------------------------
/tests/stdlib/print.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # print.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib print/println/printl functions working
25 | --file--
26 |
27 | print "hello world"
28 | println 'hello world'
29 | printl 'hello world'
30 |
31 | --output--
32 |
33 | "hello worldhello world\nhello world\n"
34 |
--------------------------------------------------------------------------------
/tests/consts/bug003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | bug ignoring const error is fixed
25 | --file--
26 | $&a = 'the var'
27 |
28 | println $&a
29 |
30 | $&a = 'new value'
31 |
32 | println $&a
33 |
34 | --output--
35 | """the var
36 | """
37 | --with-error--
38 | 'ConstError'
--------------------------------------------------------------------------------
/tests/eval/python.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # python.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | python exec system is working
25 |
26 | --file--
27 | python("self.all_vars()['myvar'] = 'the value'")
28 | println($myvar)
29 | python("self.mem = 'the mem'")
30 |
31 | --output--
32 | 'the value\n'
33 | --mem--
34 | 'the mem'
--------------------------------------------------------------------------------
/tests/function/func_multi_call.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # func_multi_call.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | functions can be called more than 1 time
25 | --file--
26 | func myfunc()
27 | println 'func runed'
28 | endfunc
29 |
30 | myfunc
31 | myfunc()
32 |
33 | --output--
34 | 'func runed\nfunc runed\n'
35 |
--------------------------------------------------------------------------------
/tests/module/path/1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | modules are loaded in module path system (2)
25 | --skip--
26 | --file--
27 | import @sys
28 | sys.path.add($__dir__ + '/tests/test-module-path')
29 | import @testdir2
30 | testdir2.run()
31 | --output--
32 | 'hello testdir2\n'
33 |
--------------------------------------------------------------------------------
/tests/consts/bug004.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug004.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | tests const can be declared but get value later
25 |
26 | --file--
27 |
28 | $&name
29 |
30 | println $&name
31 |
32 | $&name = 'hello world'
33 |
34 | println $&name
35 |
36 | --output--
37 | """None
38 | hello world
39 | """
--------------------------------------------------------------------------------
/tests/namespace/ns-alias.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # ns-alias.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | alias ns for namespace works
25 |
26 | --file--
27 |
28 | ns app
29 | func hi()
30 | println 'hello world'
31 | endfunc
32 | endns
33 |
34 | app.hi()
35 |
36 | --output--
37 | "hello world\n"
38 |
39 |
--------------------------------------------------------------------------------
/tests/stdlib/gset.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # gset.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | stdlib gset function working
25 |
26 | --file--
27 | $name = 'parsa'
28 | func myfunc()
29 | println $name
30 | gset 'name', 'pashmak'
31 | endfunc
32 | myfunc()
33 | println $name
34 |
35 | --output--
36 | 'parsa\npashmak\n'
37 |
--------------------------------------------------------------------------------
/tests/classes/007.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 007.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | constant property can be changed
25 |
26 | --file--
27 |
28 | class Person
29 | $name
30 | endclass
31 |
32 | $&p = Person()
33 |
34 | $&p->name = 'hello world'
35 |
36 | println($&p->name)
37 |
38 | --output--
39 | 'hello world\n'
--------------------------------------------------------------------------------
/tests/function/func_error.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # func_error.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function system raises error when function argument syntax is not valid
25 |
26 | --file--
27 |
28 | func myfunc()
29 | print ^
30 | endfunc
31 |
32 | myfunc hello world
33 |
34 | --with-error--
35 | 'SyntaxError'
36 |
--------------------------------------------------------------------------------
/tests/namespace/variable_in_ns.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # variable_in_ns.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | variables in namespaces working
25 | --file--
26 | namespace App
27 | $name = 'parsa'
28 | print $name
29 | print $App.name
30 | endns
31 | print $App.name
32 |
33 | --output--
34 | 'parsaparsaparsa'
35 |
--------------------------------------------------------------------------------
/tests/stdlib/assert/assert_true.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # assert_true.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | assert function is ok when values are True
25 | --file--
26 | assert True
27 | assert 2 == 2
28 | assert 100 > 50
29 | $age = 30
30 | assert $age > 18
31 | println 'success'
32 |
33 | --output--
34 | 'success\n'
35 |
--------------------------------------------------------------------------------
/tests/tryendtry/bug001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | try endtry variable error bug is fixed
25 |
26 | --file--
27 |
28 | try error
29 | mem $not
30 | endtry
31 | goto after_error; section error
32 | println('error')
33 | section after_error
34 |
35 | --output--
36 | "error\n"
37 |
--------------------------------------------------------------------------------
/tests/variables/copy.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # copy.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | copy command is working
25 | --file--
26 | $name; $family; $age
27 | $name = 'parsa'
28 | $family = $name
29 | println($name)
30 | println($family)
31 | println($age)
32 |
33 | --output--
34 | """parsa
35 | parsa
36 | None
37 | """
38 |
--------------------------------------------------------------------------------
/tests/io/read/4.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 4.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | read command can read more that one argument
25 |
26 | --file--
27 | $input = read()
28 | print($input)
29 |
30 | $input_1 = read()
31 | print($input_1)
32 |
33 | --stdin--
34 | ['pashmak', 'parsa']
35 |
36 | --output--
37 | 'pashmakparsa'
38 |
--------------------------------------------------------------------------------
/tests/core/is-main-variable.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # is-main-variable.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | $__ismain__ variable has valid value
25 |
26 | --file--
27 | println $__ismain__
28 | import 'tests/test-module-path/is_main_test.pashm'
29 | println $__ismain__
30 |
31 | --output--
32 | """True
33 | False
34 | True
35 | """
--------------------------------------------------------------------------------
/tests/core/shutdown-event-bug001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # shutdown-event-bug001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | shutdown events will be called while using exit()
25 |
26 | --file--
27 |
28 | func bye()
29 | println 'bye'
30 | endfunc
31 |
32 | register_shutdown(bye)
33 |
34 | exit()
35 |
36 | --output--
37 | "bye\n"
38 |
--------------------------------------------------------------------------------
/tests/module/import/multi_import/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | multiple import is working
25 | --file--
26 | import '@hash', 'examples/will_be_include.pashm'
27 | hash.sha256 'hello'; print ^
28 | --output--
29 | 'i am included\n2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
30 |
--------------------------------------------------------------------------------
/tests/random/001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # random.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | random module is working
25 | --file--
26 | import "@random"
27 | random.randint(5,10)
28 | $rand = ^
29 | assert($rand >= 5 and $rand <= 10)
30 | $r2 = random.random()
31 | assert($r2 < 1)
32 | random.seed(1000)
33 | println(random.getstate())
34 |
--------------------------------------------------------------------------------
/tests/variables/free0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # free0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | free function is working
25 | --file--
26 |
27 | $name = 'parsa'
28 |
29 | println(isset('name'))
30 |
31 | free('name')
32 |
33 | println(isset('name'))
34 |
35 | free('not_found')
36 |
37 | --output--
38 | """True
39 | False
40 | """
41 |
--------------------------------------------------------------------------------
/tests/examples/get_password0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # get_password0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | Test get password example with invalid password
25 |
26 | --file--
27 | import 'examples/get_password.pashm'
28 |
29 | --stdin--
30 | ['the-invalid-password']
31 |
32 | --output--
33 | 'enter the password: invalid password\n'
34 |
--------------------------------------------------------------------------------
/tests/function/return001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # return001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | return command working correct
25 | --file--
26 | func hello()
27 | println 'hello'
28 | return 'good bye'
29 | println 'world'
30 | endfunc
31 |
32 | hello
33 | print ^
34 |
35 | --output--
36 | """hello
37 | good bye"""
38 |
--------------------------------------------------------------------------------
/tests/core/multiline.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # multiline.pashmt
3 | #
4 | #
5 | The Pashmak Project
6 | # Copyright 2020-2021 parsa shahmaleki
7 | #
8 | # This file is part of Pashmak.
9 | #
10 | # Pashmak is free software: you can redistribute it and/or modify
11 | # it under the terms of the GNU General Public License as published by
12 | # the Free Software Foundation, either version 3 of the License, or
13 | # (at your option) any later version.
14 | #
15 | # Pashmak is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License
21 | # along with Pashmak. If not, see .
22 | #########################################################################
23 |
24 | --test--
25 | multiline syntax works
26 |
27 | --file--
28 |
29 | println('hello\
30 | world')
31 |
32 | println(\
33 | 'this is a test\n\
34 | new line'\
35 | )
36 |
37 | --output--
38 | """hello world
39 | this is a test
40 | new line
41 | """
42 |
--------------------------------------------------------------------------------
/tests/function/return003.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # return003.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 |
24 | --test--
25 | return command works when have not argument
26 | --file--
27 | func hello()
28 | print 'first'
29 | return
30 | print 'last'
31 | endfunc
32 |
33 | $r = hello()
34 |
35 | println $r
36 |
37 | --output--
38 | 'firstNone\n'
39 |
--------------------------------------------------------------------------------
/tests/io/read/6.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 6.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | read command can read multiple values in one command
25 |
26 | --file--
27 | $var = read()
28 | $v2 = read()
29 |
30 | println($var)
31 | println($v2)
32 |
33 | --stdin--
34 | ['pashmak', 'hello']
35 |
36 | --output--
37 | """pashmak
38 | hello
39 | """
40 |
--------------------------------------------------------------------------------
/tests/function/func_arg_variable2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # func_arg_variable2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | functions argument variable is working with parentheses
25 |
26 | --file--
27 | func say_hi ($name)
28 | println $name
29 | endfunc
30 | say_hi 'parsa'
31 | say_hi('parsa')
32 |
33 | --output--
34 |
35 | 'parsa\nparsa\n'
36 |
--------------------------------------------------------------------------------
/tests/module/import/multi_import/2.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 2.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | multi import is working with brackets
25 | --file--
26 | import('@hash', 'examples/will_be_include.pashm')
27 | hash.sha256 'hello'; print ^
28 | --output--
29 | 'i am included\n2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
30 |
--------------------------------------------------------------------------------
/tests/module/path/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | modules are loaded in module path system
25 | --pyinit--
26 |
27 | import os
28 | os.environ['PASHMAKPATH'] = os.getcwd() + '/tests/test-module-path'
29 |
30 | --file--
31 | import '@testliba'
32 | testliba.run
33 |
34 | --output--
35 | 'hello testliba\n'
36 |
--------------------------------------------------------------------------------
/tests/namespace/namespace_variable_error.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # namespace_variable_error.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | namespace variable is declared inside namespace and is not accessible from outside
25 | --file--
26 | namespace App
27 | $name = 'parsa'
28 | endns
29 | print $name
30 |
31 | --with-error--
32 | 'VariableError'
33 |
--------------------------------------------------------------------------------
/tests/core/set-get-functions.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # set-get-functions.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | `set()` and `get()` functions working correctly
25 |
26 | --file--
27 |
28 | $name = 'parsa'
29 |
30 | println(get('name'))
31 |
32 | set('name', 'pashmak')
33 |
34 | println($name)
35 |
36 | --output--
37 | """parsa
38 | pashmak
39 | """
--------------------------------------------------------------------------------
/tests/core/syntax-bug-multiline-001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax-bug-multiline-001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | bug whitespace in multiline is fixed
25 |
26 | --file--
27 |
28 | func hello(string $name)
29 | println 'hello ' + $name
30 | endfunc
31 |
32 | hello(
33 | 'parsa'
34 |
35 | )
36 |
37 | --output--
38 | "hello parsa\n"
39 |
--------------------------------------------------------------------------------
/tests/module/import/multi_import/1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | multiple import is working with parentheses
25 | --file--
26 | import ('@hash', 'examples/will_be_include.pashm')
27 | hash.sha256 'hello'; print ^
28 | --output--
29 | 'i am included\n2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
30 |
--------------------------------------------------------------------------------
/tests/section/1.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 1.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | section system is working as Loop structure
25 | --file--
26 | println 'before start'
27 | $i = 0
28 | section 10
29 | print str($i)
30 | $i = $i + 1
31 | mem $i < 10; gotoif 10
32 | println 'after start'
33 | --output--
34 | '''before start
35 | 0123456789after start
36 | '''
--------------------------------------------------------------------------------
/tests/stdlib/py-load-file-001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # py-load-file-001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | py_load_file function is working
25 | --file--
26 |
27 | $pyobj = py_load_file($__dir__ + '/tests/test-module-path/testpyfile.py')
28 | print($pyobj->the_var)
29 | $pyobj->the_func()
30 |
31 | --output--
32 | "The value of python var"
33 |
34 |
--------------------------------------------------------------------------------
/examples/get_password.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # get_password.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | # valid password
24 | $password = '123'
25 |
26 | # ask password from user
27 | print('enter the password: ')
28 | $input = read()
29 |
30 | # check password
31 | if $input == $password
32 | println('WELCOME!')
33 | else
34 | println('invalid password')
35 | endif
36 |
--------------------------------------------------------------------------------
/tests/variables/gget001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # gget001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function gget() is working
25 |
26 | --file--
27 |
28 | func hello()
29 | $name = 'new'
30 | println($name)
31 | println(gget('name'))
32 | endfunc
33 |
34 | $name = 'pashmak'
35 |
36 | hello()
37 |
38 | --output--
39 | """new
40 | pashmak
41 | """
--------------------------------------------------------------------------------
/examples/array.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # array.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | # We have a array from names. we in here print them one by one
24 |
25 | # declare $names array
26 | $names = ['parsa', 'pashmak', 'something']
27 |
28 | # set a counter for loop
29 | $i = 0
30 |
31 | while $i < len($names)
32 | println($names[$i])
33 | $i = $i + 1
34 | endwhile
35 |
--------------------------------------------------------------------------------
/tests/function/func_args.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # func_args.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | functions argument will be set correctly
25 | --file--
26 | func myfunc()
27 | print ^
28 | endfunc
29 | myfunc("hello world")
30 | myfunc(2*3)
31 |
32 | $var = 'test'
33 |
34 | myfunc 'this is ' + $var
35 |
36 | --output--
37 | 'hello world6this is test'
38 |
--------------------------------------------------------------------------------
/examples/loop.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # loop.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | # This is a simple loop printing numbers from 1 to 99
24 |
25 | func myfunc(int $n)
26 | println('starting...')
27 |
28 | $i = 1
29 | while $i < $n
30 | println($i)
31 | $i = $i + 1
32 | endwhile
33 |
34 | println('finished')
35 | endfunc
36 |
37 | myfunc(100)
38 |
--------------------------------------------------------------------------------
/tests/namespace/bug001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | namespace function bug is fixed
25 |
26 | --file--
27 |
28 | namespace App
29 | func foo()
30 | println 'the foo'
31 | endfunc
32 |
33 | func bar()
34 | foo()
35 | endfunc
36 | endns
37 |
38 | App.bar()
39 |
40 | --output--
41 | "the foo\n"
--------------------------------------------------------------------------------
/tests/examples/fib.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # fib.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | Test fibonacci printing example
25 |
26 | --file--
27 | import 'examples/fib.pashm'
28 |
29 | --output--
30 |
31 | '''1
32 | 1
33 | 2
34 | 3
35 | 5
36 | 8
37 | 13
38 | 21
39 | 34
40 | 55
41 | 89
42 | 144
43 | 233
44 | 377
45 | 610
46 | 987
47 | 1597
48 | 2584
49 | 4181
50 | 6765
51 | '''
52 |
--------------------------------------------------------------------------------
/tests/function/func0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # func0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | functions working
25 |
26 | --file--
27 | println 'starting'
28 |
29 | func myfunc()
30 | println 'func runed'
31 | println 'func finished'
32 | endfunc
33 |
34 | myfunc
35 |
36 | println 'finished'
37 |
38 | --output--
39 | 'starting\nfunc runed\nfunc finished\nfinished\n'
40 |
--------------------------------------------------------------------------------
/tests/classes/003-props.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 003-props.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | class properties can be declared
25 | --file--
26 | class Car
27 | $name
28 | $price = 100
29 | endclass
30 |
31 | print(self.classes['Car'].__props__)
32 |
33 | --output--
34 | "{'__parent__': 'Object', '__name__': 'Car', '__docstring__': '', 'name': None, 'price': 100}"
35 |
--------------------------------------------------------------------------------
/tests/tryendtry/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | try endtry is working when code has not any error
25 | --file--
26 | $name = 'pashmak'
27 |
28 | try 10
29 | # a code without error
30 | print 'hello ' + $name
31 | endtry
32 |
33 | goto 20
34 |
35 | section 10
36 |
37 | print 'the Error!'
38 |
39 | section 20
40 | --output--
41 | 'hello pashmak'
--------------------------------------------------------------------------------
/doc/04_os_command/00_os_commands.md:
--------------------------------------------------------------------------------
1 | # OS Commands
2 |
3 | here is some commands about OS.
4 |
5 | ### cwd
6 | get current working directory.
7 |
8 | ```bash
9 | cwd()
10 | println(^)
11 | ```
12 |
13 | output:
14 |
15 | ```
16 | /tmp
17 | ```
18 |
19 | or:
20 |
21 | ```bash
22 | $cwd = cwd()
23 | println('The current working directory is ' + $cwd)
24 | ```
25 |
26 | or:
27 |
28 | ```bash
29 | println(cwd())
30 | ```
31 |
32 | this command puts current working directory path into the mem.
33 |
34 | ### system
35 | you can run shell commands by this command:
36 |
37 | ```bash
38 | system('ls /tmp')
39 | ```
40 |
41 | also after run `system` function, exit code will put in `mem`:
42 |
43 | ```bash
44 | system('ls /')
45 | println(^) # output: 0
46 | ```
47 |
48 | or:
49 |
50 | ```bash
51 | println(system('ls /'))
52 | ```
53 |
54 | ### exit
55 | this command exits program
56 |
57 | look at this example:
58 |
59 | ```bash
60 | println('first print')
61 |
62 | exit()
63 |
64 | println('last print') # this will not print
65 | ```
66 |
67 | output:
68 |
69 | ```
70 | first print
71 | ```
72 |
73 | #### exit with exit code:
74 |
75 | ```bash
76 | println('hello world')
77 | exit(1)
78 | ```
79 |
80 | exit code of program will be `1`
81 |
--------------------------------------------------------------------------------
/doc/10_modules/05_sys.md:
--------------------------------------------------------------------------------
1 | # sys module
2 | this module has some functions to manage pashmak internal envrinonment.
3 |
4 | ### sys.path module
5 | this module is for manage module paths. you can add new module paths and load modules from everywhere at runtime with this module.
6 |
7 | to know about this module, go to next section [Module path system](#module-path-system).
8 |
9 | ### `$sys.pashmakinfo`, access to pashmakinfo
10 |
11 | if you want to access to pashmak interpreter info, `sys` module has a variable named `pashmakinfo`:
12 |
13 | ```bash
14 | import @sys
15 |
16 | println($sys.pashmakinfo)
17 | ```
18 |
19 | output is something like this:
20 |
21 | ```
22 | {'version': 'vx.y.z', 'pythoninfo': 'x.y.z (default, Jul x y, a:b:c) [GCC x.y.x]'}
23 | ```
24 |
25 | this variable is a dictonary.
26 | for example, to access pashmak version:
27 |
28 | ```bash
29 | import @sys
30 |
31 | println($sys.pashmakinfo['version'])
32 | ```
33 |
34 | output:
35 |
36 | ```
37 | v1.x.y
38 | ```
39 |
40 | and `$sys.pashmakinfo['pythoninfo']` shows info of python.
41 |
42 | ### `$sys.pashmakexe`: The pashmak's interpreter exe filename
43 | This variable contains pashmak's interpreter filename.
44 |
45 | ```bash
46 | println($sys.pashmakexe)
47 | ```
48 |
--------------------------------------------------------------------------------
/tests/core/datatype-aliases.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # datatype-aliases.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | datatypes aliases are ok
25 |
26 | --file--
27 |
28 | println(string(12))
29 | println(null)
30 | println(true)
31 | println(false)
32 | println(integer('30'))
33 | println(array())
34 |
35 | --output--
36 | """12
37 | None
38 | True
39 | False
40 | 30
41 | []
42 | """
43 |
44 |
--------------------------------------------------------------------------------
/tests/core/syntax-bug-007.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # syntax-bug-007.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | class property setting syntax bug is fixed
25 |
26 | --file--
27 |
28 | define('NAME', 'hello')
29 |
30 | class Person
31 | $NAME = 'parsa'
32 | endclass
33 |
34 | $a = Person()
35 |
36 | $a->NAME = 'new'
37 |
38 | println $a->NAME
39 |
40 | --output--
41 | """new
42 | """
43 |
--------------------------------------------------------------------------------
/tests/function/arg-type-002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # arg-type-002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | typed arguments with `|` works
25 |
26 | --file--
27 |
28 | func hello(int|string $a)
29 | println($a)
30 | endfunc
31 |
32 | hello(10)
33 | hello('hello')
34 | hello(True)
35 |
36 | --output--
37 | """10
38 | hello
39 | """
40 |
41 | --with-error--
42 | "InvalidArgument"
43 |
--------------------------------------------------------------------------------
/tests/module/import/002-import-once.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 002-import-once.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import_once function works and only imports a file one time
25 |
26 | --file--
27 | import_once 'examples/will_be_include.pashm'
28 | import_once 'examples/will_be_include.pashm'
29 |
30 | testfunc
31 |
32 | --output--
33 | """i am included
34 | i am included func
35 | """
--------------------------------------------------------------------------------
/tests/function/bug002.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug002.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | function argument null value bug while type is defined is fixed
25 |
26 | --file--
27 |
28 | func hello(string $name, string $family=null, int $age = 100)
29 | println $name, $family, $age
30 | endfunc
31 |
32 | hello('parsa')
33 |
34 | --output--
35 | """('parsa', None, 100)
36 | """
37 |
38 |
--------------------------------------------------------------------------------
/tests/module/import/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import command is working
25 |
26 | --file--
27 | println 'before include'
28 | import 'examples/will_be_include.pashm'
29 | println 'after include'
30 | testfunc
31 | println($included_var)
32 |
33 | --output--
34 | 'before include\ni am included\nafter include\ni am included func\nincluded value\n'
35 |
--------------------------------------------------------------------------------
/examples/fib.pashm:
--------------------------------------------------------------------------------
1 | #
2 | # fib.pashm
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | # Printing the fibonacci pattern
24 |
25 | func fib(int $n=1000)
26 | $a = 1
27 | $b = 1
28 |
29 | while $a < $n
30 | println($a)
31 |
32 | $tmp_a = $a
33 | $tmp_b = $b
34 |
35 | $a = $tmp_b
36 |
37 | $b = $tmp_a + $tmp_b
38 | endwhile
39 | endfunc
40 |
41 | fib(10000)
42 |
--------------------------------------------------------------------------------
/tests/classes/001.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 001.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | class can be declared
25 | --file--
26 | class Person
27 | endclass
28 | println(list(self.classes.keys()))
29 | println(self.classes['Person'].__props__)
30 | --output--
31 | """["""+self.default_classes_list_str+""", 'Person']
32 | {'__parent__': 'Object', '__name__': 'Person', '__docstring__': ''}
33 | """
34 |
--------------------------------------------------------------------------------
/tests/namespace/0.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # 0.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | namespaces can be declared and called
25 | --file--
26 | namespace MySpace
27 | func dosomething()
28 | println 'hello world'
29 | endfunc
30 | MySpace.dosomething
31 | dosomething
32 | endnamespace
33 | MySpace.dosomething
34 | --output--
35 | 'hello world\nhello world\nhello world\n'
36 |
--------------------------------------------------------------------------------
/tests/module/import/bug005.pashmt:
--------------------------------------------------------------------------------
1 | #
2 | # bug005.pashmt
3 | #
4 | # The Pashmak Project
5 | # Copyright 2020-2021 parsa shahmaleki
6 | #
7 | # This file is part of Pashmak.
8 | #
9 | # Pashmak is free software: you can redistribute it and/or modify
10 | # it under the terms of the GNU General Public License as published by
11 | # the Free Software Foundation, either version 3 of the License, or
12 | # (at your option) any later version.
13 | #
14 | # Pashmak is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with Pashmak. If not, see .
21 | #########################################################################
22 |
23 | --test--
24 | import frame conflicting bug is fixed
25 |
26 | --file--
27 |
28 | func hello()
29 | import_once $__dir__ + '/examples/will_be_include.pashm'
30 | endfunc
31 |
32 | import $__dir__ + '/examples/will_be_include.pashm'
33 | hello()
34 | hello()
35 |
36 | --output--
37 | """i am included
38 | """
39 |
--------------------------------------------------------------------------------