gschem: Add comment
[geda-gaf.git] / xorn / tests / cpython / snippets / guile.py
blob3f44a8f81dac2cb10ae0e17857eca89b1dc7ae70
1 # Copyright (C) 2013-2018 Roland Lutz
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 import xorn.guile
19 ## [guile]
20 def add(x, y):
21 return x + y
23 xorn.guile.define('add', add)
24 xorn.guile.eval_string('(add 1 2)') # => 3
25 xorn.guile.eval_string('(add 1.0 2.0)') # => 3.0
26 ## [guile]
28 assert xorn.guile.eval_string('(add 1 2)') == 3
29 assert xorn.guile.eval_string('(add 1.0 2.0)') == 3.0
31 assert type(xorn.guile.eval_string('(add 1 2)')) == int
32 assert type(xorn.guile.eval_string('(add 1.0 2.0)')) == float