From 774895418a6b185561a82c0152c77d2a9e769691 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 8 Mar 2016 10:34:15 +0100 Subject: [PATCH] * tests/python/word.ipynb: Add a new test and some comments. --- tests/python/word.ipynb | 176 ++++++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 71 deletions(-) diff --git a/tests/python/word.ipynb b/tests/python/word.ipynb index 5a3f4cd67..09ce3a6c9 100644 --- a/tests/python/word.ipynb +++ b/tests/python/word.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:6461a5fa3f321dac24ae47d88c90f911822e003b658d05d4ef7c102ff64e058e" + "signature": "sha256:a4f8f6e783c38abbf8cce75fb3eb8d9344ece79c11ad5c58556df2db3e40d6a2" }, "nbformat": 3, "nbformat_minor": 0, @@ -139,7 +139,7 @@ "\n" ], "text": [ - " *' at 0x7fdd0c5d9330> >" + " *' at 0x7fcdb40da870> >" ] } ], @@ -295,6 +295,13 @@ ], "prompt_number": 7 }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Words can be created using the `parse_word` function:" + ] + }, { "cell_type": "code", "collapsed": false, @@ -322,81 +329,29 @@ "cell_type": "code", "collapsed": false, "input": [ - "print(spot.parse_word('a; b&!a; b'))" + "# make sure that we can parse a word back after it has been printed\n", + "spot.parse_word(str(spot.parse_word('a;b&a;cycle{!a&!b}')))" ], "language": "python", "metadata": {}, "outputs": [ { - "ename": "SyntaxError", - "evalue": "\n>>> a; b&!a; b\n ^\nA twa_word must contain a cycle\n ()", - "output_type": "pyerr", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; b&!a; b\n ^\nA twa_word must contain a cycle\n\n" + "metadata": {}, + "output_type": "pyout", + "prompt_number": 9, + "text": [ + "a; a & b; cycle{!a & !b}" ] } ], "prompt_number": 9 }, { - "cell_type": "code", - "collapsed": false, - "input": [ - "print(spot.parse_word('a; b; c}'))" - ], - "language": "python", + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "\n>>> a; b; c}\n ^\nExpected ';' delimiter: '}' stands for ending a cycle\n ()", - "output_type": "pyerr", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; b; c}\n ^\nExpected ';' delimiter: '}' stands for ending a cycle\n\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print(spot.parse_word('a; cycle{}'))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "\n>>> a; cycle{}\n ^\nempty input\n\n ()", - "output_type": "pyerr", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; cycle{}\n ^\nempty input\n\n\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print(spot.parse_word('a; cycle{!a}; a'))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "\n>>> a; cycle{!a}; a\n ^\nInput should be finished after cycle\n ()", - "output_type": "pyerr", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; cycle{!a}; a\n ^\nInput should be finished after cycle\n\n" - ] - } - ], - "prompt_number": 12 + "source": [ + "Words can be easily converted as automata" + ] }, { "cell_type": "code", @@ -407,7 +362,7 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 13 + "prompt_number": 10 }, { "cell_type": "code", @@ -421,7 +376,7 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 14, + "prompt_number": 11, "svg": [ "\n", "\n" ], "text": [ - " *' at 0x7fdd0c5d96c0> >" + " *' at 0x7fcdb40da8d0> >" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Test some syntax errors" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print(spot.parse_word('a; b&!a; b'))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "\n>>> a; b&!a; b\n ^\nA twa_word must contain a cycle\n ()", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; b&!a; b\n ^\nA twa_word must contain a cycle\n\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print(spot.parse_word('a; b; c}'))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "\n>>> a; b; c}\n ^\nExpected ';' delimiter: '}' stands for ending a cycle\n ()", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; b; c}\n ^\nExpected ';' delimiter: '}' stands for ending a cycle\n\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print(spot.parse_word('a; cycle{}'))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "\n>>> a; cycle{}\n ^\nempty input\n\n ()", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; cycle{}\n ^\nempty input\n\n\n" ] } ], @@ -508,13 +530,25 @@ { "cell_type": "code", "collapsed": false, - "input": [], + "input": [ + "print(spot.parse_word('a; cycle{!a}; a'))" + ], "language": "python", "metadata": {}, - "outputs": [] + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "\n>>> a; cycle{!a}; a\n ^\nInput should be finished after cycle\n ()", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32munknown\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m \n>>> a; cycle{!a}; a\n ^\nInput should be finished after cycle\n\n" + ] + } + ], + "prompt_number": 15 } ], "metadata": {} } ] -} +} \ No newline at end of file