diff options
author | Omer Zak <w1@zak.co.il> | 2016-05-22 11:03:43 +0300 |
---|---|---|
committer | Omer Zak <w1@zak.co.il> | 2016-05-22 11:03:43 +0300 |
commit | c26aec892f26ee21067a0beb9dd79a8c834e6dba (patch) | |
tree | e06cc2a5e207b089fa324faaf9114267edaa0e3a /t/08_eval.t | |
parent | 7abc0d1d0b05198e10f5207aa17f1c14e37c0fa7 (diff) | |
download | pyguile-c26aec892f26ee21067a0beb9dd79a8c834e6dba.tar pyguile-c26aec892f26ee21067a0beb9dd79a8c834e6dba.tar.gz |
Added all old files of interest to version control.
Diffstat (limited to 't/08_eval.t')
-rw-r--r-- | t/08_eval.t | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/t/08_eval.t b/t/08_eval.t new file mode 100644 index 0000000..96d1dcb --- /dev/null +++ b/t/08_eval.t @@ -0,0 +1,69 @@ +#!/usr/bin/guile -s +!# +; python-eval tests. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; Copyright (C) 2008 Omer Zak. +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with this library, in a file named COPYING; if not, write to the +; Free Software Foundation, Inc., 59 Temple Place, Suite 330, +; Boston, MA 02111-1307 USA +; +; For licensing issues, contact <w1@zak.co.il>. +; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +(use-modules (guiletap)) +(use-modules (pyguile)) + +(plan 7) + +(is-ok 1 "regular python-eval" + 42 + (python-eval "7*3*2" #t)) + + +; Run python-eval under catch harness. +(define catch-test-eval + (lambda (txt retval) + (catch #t + (lambda () (python-eval txt retval)) + (lambda (key . args) (object->string (list key args)))))) + +(is-ok 2 "trying to run python-eval on non-string" + "(wrong-type-arg (\"python-eval\" \"Wrong type argument in position ~A: ~S\" (1 -42) #f))" + (catch-test-eval -42 #t)) + +(is-ok 3 "trying to run python-eval with non-boolean/non-P2G_SMOB argument" + "(misc-error (\"p2g_apply\" \"bad template item ~S\" (42) #f))" + (catch-test-eval "7*3*2" 42)) + +(like 4 "Raising exception inside python-eval f" + "\\(misc-error \\(\"python-eval\" \"Python exception: ~A\" \\(\"<class exceptions.ImportError at 0x[0-9a-f]{8}>\"\\) #f\\)\\)" + (catch-test-eval "import t7except\nraiser('xyzzy')\n" #f)) + +(python-eval "import sys;sys.path = ['']+sys.path\n") +(python-eval "from t.scripts.t7except import raiser") +(like 5 "Raising exception inside python-eval t" + "^\\(misc-error \\(\"python-eval\" \"Python exception: ~A\" \\(\"<class t.scripts.t7except.myexception at 0x[0-9a-f]{8}>\"\\) #f\\)\\)$" + (catch-test-eval "1+raiser('foo fee dom')" #t)) + +(like 6 "code does not return requested result" + "^\\(misc-error \\(\"python-eval\" \"Python exception: ~A\" \\(\"<class exceptions.SyntaxError at 0x[0-9a-f]{8}>\"\\) #f\\)\\)$" + (catch-test-eval "print '# no value was returned'\n" #t)) + +(is-ok 7 "code returns unsolicited result" + "#<unspecified>" + (object->string (python-eval "99+101" #f))) + +; End of 08_eval.t |