mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-05 19:50:23 +02:00
* module/rnrs/bytevectors.scm: Rename to (rnrs bytevectors), from (rnrs bytevector), to match the name from the R6RS. * benchmark-suite/benchmarks/bytevectors.bm: * doc/ref/api-data.texi: * doc/ref/api-foreign.texi: * libguile/bytevectors.c: * module/6/rnrs.scm: * module/language/assembly.scm: * module/language/assembly/compile-bytecode.scm: * module/language/assembly/decompile-bytecode.scm: * module/language/glil/compile-assembly.scm: * module/language/tree-il/primitives.scm: * module/srfi/srfi-4.scm: * module/srfi/srfi-4/gnu.scm: * module/system/foreign.scm: * test-suite/standalone/test-ffi: * test-suite/tests/asm-to-bytecode.test: * test-suite/tests/bytevectors.test: * test-suite/tests/foreign.test: * test-suite/tests/r6rs-ports.test: Update all referrers.
57 lines
2 KiB
Scheme
57 lines
2 KiB
Scheme
;;;; foreign.test --- FFI. -*- mode: scheme; coding: utf-8; -*-
|
||
;;;;
|
||
;;;; 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
|
||
|
||
;;;
|
||
;;; See also ../standalone/test-ffi for FFI tests.
|
||
;;;
|
||
|
||
(define-module (test-foreign)
|
||
#:use-module (system foreign)
|
||
#:use-module (rnrs bytevectors)
|
||
#:use-module (test-suite lib))
|
||
|
||
|
||
(with-test-prefix "null pointer"
|
||
|
||
(pass-if "zero"
|
||
(= 0 (foreign-ref %null-pointer)))
|
||
|
||
(pass-if-exception "foreign-set! %null-pointer"
|
||
exception:null-pointer-error
|
||
(foreign-set! %null-pointer 2))
|
||
|
||
(pass-if "foreign-set! other-null-pointer"
|
||
(let ((f (bytevector->foreign (make-bytevector 2))))
|
||
(and (not (= 0 (foreign-ref f)))
|
||
(begin
|
||
(foreign-set! f 0)
|
||
(= 0 (foreign-ref f)))
|
||
(begin
|
||
;; Here changing the pointer value of F is perfectly valid.
|
||
(foreign-set! f 777)
|
||
(= 777 (foreign-ref f))))))
|
||
|
||
(pass-if-exception "foreign->bytevector %null-pointer"
|
||
exception:null-pointer-error
|
||
(foreign->bytevector %null-pointer))
|
||
|
||
(pass-if-exception "foreign->bytevector other-null-pointer"
|
||
exception:null-pointer-error
|
||
(let ((f (bytevector->foreign (make-bytevector 2))))
|
||
(foreign-set! f 0)
|
||
(foreign->bytevector f))))
|