diff options
Diffstat (limited to 'tiger-compiler/tcsh/python/tests/common.ipynb')
| -rw-r--r-- | tiger-compiler/tcsh/python/tests/common.ipynb | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/tiger-compiler/tcsh/python/tests/common.ipynb b/tiger-compiler/tcsh/python/tests/common.ipynb new file mode 100644 index 0000000..a2ee8ac --- /dev/null +++ b/tiger-compiler/tcsh/python/tests/common.ipynb @@ -0,0 +1,154 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3f7f66b6", + "metadata": {}, + "source": [ + "# Import Tiger and Common" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "9cb3bce5", + "metadata": {}, + "outputs": [], + "source": [ + "import tc" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "be38c5fe", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tc.has(\"common\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "9fe09a20", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import tiger_common\n", + "tiger_common == tc.common" + ] + }, + { + "cell_type": "markdown", + "id": "3b3a7285", + "metadata": {}, + "source": [ + "# Common Library" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "2be2f25d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Ofstream', 'cvar', 'get_cerr', 'get_cout']" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(filter(lambda e: not e.startswith(\"_\"), dir(tc.common)))" + ] + }, + { + "cell_type": "markdown", + "id": "c2ffa10b", + "metadata": {}, + "source": [ + "# Common Ofstrem" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "0ee4cd72", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "<Swig Object of type 'std::ostream *' at 0x7f812c0f0750>\n" + ] + } + ], + "source": [ + "import os\n", + "import tempfile\n", + "\n", + "# Create file\n", + "f = tempfile.NamedTemporaryFile(delete=False)\n", + "f.write(b\"let in end\")\n", + "f.close()\n", + "\n", + "# Open a C++ ostream\n", + "ostream = tc.common.Ofstream(f.name)\n", + "print(ostream.to())\n", + "\n", + "# Delete file\n", + "os.unlink(f.name)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} |
