diff --git a/contrib/lib_mir/test/fixtures/factorial.tzt b/contrib/lib_mir/test/fixtures/factorial.tzt new file mode 100644 index 0000000000000000000000000000000000000000..2f1f604d3fdebfb11b8e00940f07200dd2882d0d --- /dev/null +++ b/contrib/lib_mir/test/fixtures/factorial.tzt @@ -0,0 +1,32 @@ +############################################################################## +# +# MIT License +# Copyright (c) 2023 Serokell +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################## + +code { INT; DUP; LE; + IF { DROP; PUSH int 1 } + { DUP; PUSH int -1; ADD; DUP; GT; + LOOP { DUP; DIP { MUL }; PUSH int -1; ADD; DUP; GT } ; + DROP } }; +input { Stack_elt nat 30 } ; +output { Stack_elt int 265252859812191058636308480000000 } ; diff --git a/contrib/lib_mir/test/fixtures/fibonacci.tzt b/contrib/lib_mir/test/fixtures/fibonacci.tzt new file mode 100644 index 0000000000000000000000000000000000000000..e9e4a44cfeae94327aeb511fc0572b2a1743f539 --- /dev/null +++ b/contrib/lib_mir/test/fixtures/fibonacci.tzt @@ -0,0 +1,35 @@ +############################################################################## +# +# MIT License +# Copyright (c) 2023 Serokell +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +############################################################################## + +code { INT ; PUSH int 0 ; DUP 2 ; GT ; + IF { DIP { PUSH int -1 ; ADD } ; + PUSH int 1 ; + DUP 3 ; + GT ; + LOOP { SWAP ; DUP 2 ; ADD ; DIP 2 { PUSH int -1 ; ADD } ; DUP 3 ; GT } ; + DIP { DROP 2 } } + { DIP { DROP } } } ; +input { Stack_elt nat 100 } ; +output { Stack_elt int 354224848179261915075 } ;