1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
guile/test-suite/tests/lua-eval-3.test
Phil f4c44a3ba7 Add some documentation. Function calls now properly handle multiple
values resulting from a function call as the last argument.

doc/ref/api-languages.texi: Add a small blurb about Lua.

module/language/lua/compile-tree-il.scm: Function calls now properly
handle multiple values resulting from a function call as the last
argument.
2013-09-09 17:01:24 +01:00

59 lines
2.2 KiB
Scheme

;;;; lua-eval-3.test --- basic tests for builtin lua constructs, act III -*- mode: scheme -*-
;;;;
;;;; Copyright (C) 2010 Free Software Foundation, Inc.
;;;;
;;;; 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 3 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; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-lua)
#:use-module (ice-9 format)
#:use-module (system base compile)
#:use-module (test-suite lib)
#:use-module (language lua parser)
)
(with-test-prefix "lua-eval"
(define (from-string string)
(compile ((make-parser (open-input-string string)))
#:from 'lua
#:to 'value))
(letrec-syntax
((test
(syntax-rules ()
((_ string expect)
(pass-if (format #f "~S => ~S" string expect) (equal? (from-string string) expect)))
((_ string)
(test string #t)))))
#|
;; make sure logical expressions don't evaluate expressions twice
;;; y will equal 2 in case of extra eval
(test "y = 0 function tmp() y = y + 1 return true end assert(tmp() or tmp()) return y == 1")
;;; y will equal 4 in case of extra eval
(test "y = 0 function void(x) end function tmp() y = y + 2 return false end; function tmp2() y = y + 1 return true end; void(tmp() and tmp2()) return y == 2")
|#
1
))
(define (from-string string)
(compile ((make-parser (open-input-string string)))
#:from 'lua
#:to 'value))
;(format #t "~a\n" (from-string "function tmp() return 4,5 end print(1,2,3,tmp())"))
(format #t "~a\n" (from-string "function tmp(...) print(1,2,3,...) end tmp(4,5)"))