1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

1263 commits

Author SHA1 Message Date
Andy Wingo
89f9dd7065 speed up compile-bytecode
* module/language/assembly/compile-bytecode.scm (compile-bytecode):
  Rewrite to fill a bytevector directly, instead of using bytevector
  ports.  `write-bytecode' itself is still present and almost the same
  as before; it's just that `write-byte' et al now inline the effect of
  writing a byte to a binary port.

* test-suite/tests/asm-to-bytecode.test (comp-test): Refactor to use
  public interfaces.
2011-05-05 11:43:12 +02:00
Ludovic Courtès
e6e286bb58 Automatically generate `peek-char' decoding error tests.
* test-suite/tests/ports.test ("string ports")[make-peek+read-checks]:
  New macro.
  [test-decoding-error]: Change to take a list of expected characters or
  conditions.  Use `make-peek+read-checks' to generate a `peek-char'
  test.
  [(#xc2 #x41 #x42), (#xe0 #xa0 #x41 #x42)]: New tests.
2011-05-04 23:52:53 +02:00
Andy Wingo
1903eae4c9 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
2011-04-28 15:53:35 +02:00
Andy Wingo
91956a94fe allow while as an expression
* module/ice-9/boot-9.scm (while): Specify the return value as #f under
  normal conditions, #t under (break), and arg... under (break arg...).
* test-suite/tests/syntax.test ("while"): Test.
* doc/ref/api-control.texi (while do): Document.
2011-04-28 15:48:35 +02:00
Andy Wingo
18e444b40e add reset and shift
* module/ice-9/control.scm (reset, shift): Add implementations of these
  operators from Wolfgang J Moeller, derived from implementations by
  Oleg Kiselyov.
  (reset*, shift*): Procedural variants.

* test-suite/tests/control.test ("shift and reset"): Add tests,
  originally from Oleg Kiselyov.
2011-04-28 15:48:28 +02:00
Ludovic Courtès
4cadf64f9a Add tests for UTF-8 ill-formed sequence handling.
* test-suite/tests/ports.test ("string ports"): Add for
  `test-decoding-error' tests for ill-formed UTF-8 sequences.  Thanks
  to Mark H Weaver <mhw@netris.org> for pointing this out.
2011-04-27 21:55:42 +02:00
Ludovic Courtès
a42d79711b Gracefully handle unterminated UTF-8 sequences instead of hitting an `assert'.
* libguile/ports.c (get_codepoint): Return EILSEQ when OUTPUT_SIZE == 0.

* test-suite/tests/ports.test ("string ports"): Add 2 tests for
  unterminated sequences.
2011-04-27 20:34:08 +02:00
Ludovic Courtès
d84783a80c Add a couple more Unicode I/O tests.
* test-suite/tests/ports.test ("string ports")["%default-port-encoding
  is honored"]: Make sure `(port-encoding p)' is as expected.
  ["peek-char [utf-16]"]: New test.
2011-04-27 16:28:32 +02:00
Ludovic Courtès
9a201881e6 Rewrite port decoding error tests using a mini DSL.
* test-suite/tests/ports.test ("string ports")[test-decoding-error]: New
  macro.
  ["read-char, wrong encoding, error", "read-char, wrong encoding,
  escape", "read-char, wrong encoding, substitute", "peek-char, wrong
  encoding, error"]: Rewrite using `test-decoding-error'.
2011-04-27 16:28:29 +02:00
Ludovic Courtès
d20912e67d Move {total,current}-processor-count' outside of posix.c'.
* libguile/posix.c (scm_total_processor_count,
  scm_current_processor_count): Move to...
* libguile/threads.c: ... here.

* libguile/posix.h (scm_total_processor_count,
  scm_current_processor_count): Move declarations to...
* libguile/threads.h: ... here.

* test-suite/tests/posix.test ("nproc"): Move tests to...
* test-suite/tests/threads.test: ... here.
2011-04-25 22:41:58 +02:00
Ludovic Courtès
96128014bf Make sure binary ports pass `binary-port?' regardless of the locale.
* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop):
  Set `c_port->encoding' to NULL.

* test-suite/tests/r6rs-ports.test ("7.2.7 Input
  Ports")["bytevector-input-port is binary"]: New test.
  ("7.2.7 Input Ports")["make-custom-binary-input-port"]: Make sure PORT
  passes `binary-port?' and `input-port?'.
  ("8.2.10 Output ports")["bytevector-output-port is binary"]: New test.
  ["make-custom-binary-output"]: Rename to...
  ["make-custom-binary-output-port"]: ... this.

* test-suite/tests/ports.test ("string ports")["read-char, wrong
  encoding, error", "read-char, wrong encoding, escape", "read-char,
  wrong encoding, substitute", "peek-char, wrong encoding, error"]: Use
  `set-port-encoding!' instead of `%default-port-encoding' to set the
  encoding of bytevector input ports.

* test-suite/tests/rdelim.test ("read-line")["decoding error", "decoding
  error, substitute"]: Likewise.

* doc/ref/api-io.texi (R6RS Port Manipulation): Document `binary-port?'
  and `textual-port?'.

* doc/ref/r6rs.texi (R6RS Incompatibilities): Mention the soft
  distinction between textual and binary ports.
2011-04-22 23:58:00 +02:00
Ludovic Courtès
ed756f7817 Increase the timeout of timing-sensitive thread tests.
* test-suite/tests/threads.test ("timed locking succeeds if mutex
  unlocked within timeout", "timed unlocking returns #t if condition
  signaled", "timed joining succeeds if thread exits within timeout"):
  Increase the timeout.  Reported by Dale P. Smith <dsmich@roadrunner.com>.
2011-04-22 16:59:05 +02:00
Ludovic Courtès
022ae742d1 Add tests for `-Wformat' and gettext.
* test-suite/tests/tree-il.test ("warnings")["non-literal format string
  using gettext", "one missing argument, gettext"]: New tests.
2011-04-14 23:14:14 +02:00
Andy Wingo
21c05db45b Merge remote branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	test-suite/tests/srfi-4.test
2011-04-11 23:30:52 +02:00
Ian Price
c89b452993 Fix fencepost error in bip_seek
* libguile/r6rs-ports.c (bip_seek): Fix to allow seeking to end of port.

* test-suite/tests/r6rs-ports.test ("bytevector input port can seek to
  very end"): Add tests.
2011-04-11 18:14:18 +02:00
Ian Price
15993bce1c fix assert to return true value.
* module/rnrs/base.scm (assert): returns value instead of void.

* test-suite/tests/r6rs-base.test ("assert"): add test cases.
2011-04-11 18:00:36 +02:00
Ian Price
cf9d4a8214 Added optional second arg to R6RS log function
* module/rnrs/base.scm (log): now takes a base argument, using the
  change of base formula for logs.
* test-suite/tests/r6rs-base.test ("log (2nd arg)"): Add test cases.
2011-04-11 17:58:12 +02:00
Andy Wingo
62ef23cbb8 fix reader.test for --disable-deprecated
* test-suite/tests/reader.test: Fix deprecated tests; begin-deprecated
  was splicing in expression context before, which is a no-no.
2011-04-11 17:21:20 +02:00
Andy Wingo
2e9fc9fc73 symbols with odd characters print better in #{}#
* libguile/print.c (symbol_has_extended_read_syntax): Use a more
  general, unicode-appropriate algorithm.  Hopefully doesn't cause
  any current #{}# cases to be unescaped.
  (print_extended_symbol): Use more appropriate unicode algorithm, and
  emit unicode hex escapes instead of our own lame escapes.

* test-suite/tests/symbols.test: Add tests.
2011-04-11 13:48:11 +02:00
Andy Wingo
d9527cfafd read-extended-symbol handles backslash better, including r6rs hex escapes
* libguile/read.c (scm_read_extended_symbol): Interpret '\' as an escape
  character.  Due to some historical oddities we have to support '\'
  before any character, but since we never emitted '\' in front of
  "normal" characters like 'x' we can interpret "\x..;" to be an R6RS
  hex escape.

* test-suite/tests/reader.test ("#{}#"): Add tests.
2011-04-11 12:48:06 +02:00
Mark H Weaver
882c89636a Fix the R6RS exact-integer-sqrt and import into core guile
* libguile/numbers.c (scm_exact_integer_sqrt): New C procedure to
  compute exact integer square root and remainder.
  (scm_i_exact_integer_sqrt): New Scheme procedure `exact-integer-sqrt'
  from the R6RS, imported into core guile.

* libguile/numbers.h: Add prototypes.

* module/rnrs/base.scm: Remove broken stub implementation, which would
  fail badly when applied to large integers.

* doc/ref/api-data.texi: Add documentation.

* doc/ref/r6rs.texi: Change documentation for `exact-integer-sqrt' to a
  stub that xrefs the core docs, as is done for other operations
  available in core.

* test-suite/tests/numbers.test: Add tests.

* NEWS: Add news entries.
2011-04-09 16:11:49 -04:00
Mark H Weaver
6ebecdeb7d Fix parsing of exact numbers with negative exponents
* libguile/numbers.c (mem2decimal_from_point): Use scm_divide instead of
  scm_divide2real when applying a negative exponent, to preserve
  exactness in case the "#e" forced exactness specifier is present.
  This fixes a bug where numeric literals such as "#e1e-5" yielded
  incorrect fractions.
2011-04-06 18:24:40 -04:00
Andy Wingo
39bed56f67 fix c32vector-set!, c64vector-set!
* module/srfi/srfi-4/gnu.scm (bytevector-c32-native-set!):
  (bytevector-c64-native-set!): Fix to actually allow complex numbers.

* test-suite/tests/srfi-4.test: Add tests.
2011-04-01 16:45:58 +02:00
Andy Wingo
c6b08d2194 string->pointer and pointer->string have optional encoding arg
* test-suite/tests/foreign.test ("pointer<->string"): Add test cases.

* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): Add
  optional encoding, and in the pointer->string case, length arguments.

* libguile/foreign.h: Update prototypes of internal functions.
  Shouldn't affect ABI as they are internal.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Update
  docs.
2011-04-01 13:31:26 +02:00
Andy Wingo
8a12aeb919 fix problems detecting coding: in block comments
* libguile/read.c (scm_i_scan_for_encoding): Fix for coding on first
  line #! and for !# immediately following the coding.

* test-suite/Makefile.am:
* test-suite/tests/coding.test: Add tests.
2011-03-31 14:46:21 +02:00
Andy Wingo
f929b9e5ec allow definitions in with-syntax body
* module/ice-9/psyntax.scm (with-syntax): Allow definitions in the body,
  as seems to be suggested by the R6RS.

* test-suite/tests/syncase.test ("with-syntax"): Add test.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-03-31 13:23:27 +02:00
Michael Gran
0f1fd214f1 More descriptive error for dynamic-pointer
* libguile/dynl.c (sysdep_dynl_value): Failure to find a symbol is not
  an error, so raise our own, more appropriate error.

* test-suite/tests/foreign.test ("dynamic-pointer"): Add a test.
2011-03-31 12:34:47 +02:00
Andy Wingo
e309f3bf9e with-continuation-barrier calls exit(3) _after_ unwinding
* libguile/continuations.c (scm_handler, c_handler)
  (scm_c_with_continuation_barrier, scm_with_continuation_barrier):
  Instead of calling scm_handle_by_message_noexit in the pre-unwind
  handler, roll our own exception printing in the pre-unwind, and do to
  exit()-on-quit in the post-unwind handler.  This lets the stack unwind
  at exit-time so that pending dynwinds run.

* test-suite/tests/continuations.test ("continuations"): Add a test.
2011-03-30 12:43:50 +02:00
Ludovic Courtès
443f25dcff Fix procedure->pointer' for functions returning void'.
* libguile/foreign.c (unpack): Handle `FFI_TYPE_VOID'.

* test-suite/tests/foreign.test ("procedure->pointer")["procedures
  returning void"]: New test.  Reported by
  Tristan Colgate <tcolgate@gmail.com>.
2011-03-29 23:35:24 +02:00
Andy Wingo
9dadfa47b0 fix prompt in fix in single-value context compilation
* module/language/tree-il/compile-glil.scm (flatten): When compiling a
  <prompt> in push context with an RA, after the body returns normally,
  jump to that RA instead of to our POST label (which in that case does
  not need to be emitted).  Fixes a tail <prompt> in a push <fix>.

* test-suite/tests/control.test ("prompt in different contexts"): Add
  more test cases.
2011-03-27 15:00:18 +02:00
Andy Wingo
2a6f90e524 Revert "with-continuation-barrier carps, calls exit(3) _after_ unwinding"
This reverts commit ecba00af65.
2011-03-25 10:47:10 +01:00
Andy Wingo
ecba00af65 with-continuation-barrier carps, calls exit(3) _after_ unwinding
* libguile/continuations.c (scm_handler, c_handler)
  (scm_c_with_continuation_barrier, scm_with_continuation_barrier): Call
  scm_handle_by_message_noexit in the post-unwind handler, so that
  dynwinds

* test-suite/tests/continuations.test ("continuations"): Add a test.
2011-03-24 20:20:18 +01:00
Ludovic Courtès
190d4b0d93 Make VM string literals immutable.
* libguile/strings.c (scm_i_make_string, scm_i_make_wide_string): Add
  `read_only_p' parameter.  All callers updated.

* libguile/vm-i-loader.c (load_string, load_wide_string): Push read-only
  strings.

* test-suite/tests/strings.test ("literals"): New test prefix.
2011-03-20 23:34:42 +01:00
Ludovic Courtès
60582b7c2a Fix `i18n.test' when the German or Greek locales aren't available.
* test-suite/tests/i18n.test (%german-utf8-locale, %greek-utf8-locale):
  New variables.
  (under-german-utf8-locale-or-unresolved,
  under-greek-utf8-locale-or-unresolved): Use them.
2011-03-18 11:24:51 +01:00
Ludovic Courtès
e4612ff642 i18n: Add case mapping and case-insensitive string comparison tests.
Thanks to Mark H Weaver <mhw@netris.org> for coming up with most of the
examples.

* test-suite/tests/i18n.test (%german-utf8-locale-name,
  %greek-utf8-locale-name): New variables.
  (under-german-utf8-locale-or-unresolved,
  under-greek-utf8-locale-or-unresolved): New procedures.
  ("text collation (German)", "text collation (Greek)"): New tests
  prefixes.
  ("string mapping")["string-locale-upcase German",
  "string-locale-upcase Greek", "string-locale-upcase Greek (two
  sigmas)", "string-locale-downcase Greek", "string-locale-downcase
  Greek (two sigmas)"]: New tests.
2011-03-17 22:45:36 +01:00
Ludovic Courtès
c428d33d32 i18n: Re-enable tests with the Turkish locale.
* test-suite/tests/i18n.test ("character mapping")["char-locale-upcase
  Turkish", "char-locale-downcase Turkish"]: Re-enable.  Passes with
  GNU libc 2.12.1.
  ("string mapping")["string-locale-upcase Turkish",
  "string-locale-downcase Turkish"]: Likewise.
2011-03-17 22:45:07 +01:00
Andy Wingo
148c331769 add pointer->scm, scm->pointer
* libguile/foreign.c (scm_pointer_to_scm, scm_scm_to_pointer): New
  functions, useful to pass and receive SCM values to and from foreign
  functions.

* module/system/foreign.scm: Export the new functions.

* doc/ref/api-foreign.texi (Foreign Variables): Add docs.

* test-suite/tests/foreign.test ("pointer<->scm"): Tests.
2011-03-17 10:39:02 +01:00
Andy Wingo
f5fc7e5710 add more prompt/abort tests
* test-suite/tests/control.test: Use c&e tests for most test blocks.
  Note that this did not catch the recent bug.
  ("reified continuations"): Add a new test for capturing partial
  continuations containing pending call frames.  Before these would
  contain dynamic links pointing out of the continuation segment, which
  would not be relocated; now, the dynamic links are only made when the
  frames are activated.

  Thanks to Wolfgang J Moeller for the bug report and test case.
2011-03-15 23:54:06 +01:00
Andreas Rottmann
ead04a04cd Enhance transcoder-related functionality of `(rnrs io ports)'
* module/rnrs/io/ports.scm (transcoder-eol-style)
  (transcoder-error-handling-mode): Export these.
  (textual-port?): Implement this procedure and export it.
* module/rnrs.scm: Export these here as well.

* module/rnrs/io/ports.scm (port-transcoder): Implement this procedure.
  (binary-port?): Treat only ports without an encoding as binary ports,
  add docstring.
  (standard-input-port, standard-output-port, standard-error-port):
  Ensure these are created without an encoding.
  (eol-style): Add `none' as enumeration member.
  (native-eol-style): Switch to `none' from `lf'.

* test-suite/tests/r6rs-ports.test (7.2.7 Input ports)
  (8.2.10 Output ports): Test binary-ness of `standard-input-port',
  `standard-output-port' and `standard-error-port'.
  (8.2.6 Input and output ports): Add test for `port-transcoder'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-03-13 23:14:43 +01:00
Andreas Rottmann
a6c377f7d8 Add get-string-n' and get-string-n!' for R6RS ports
* libguile/r6rs-ports.c (scm_get_string_n_x): Implement `get-string-n!'
  in C for efficiency.
* libguile/r6rs-ports.h: Add prototype for this function.
* module/ice-9/binary-ports.scm: Export `get-string-n!'.

* module/rnrs/io/ports.scm (get-string-n): Implement based on
  `get-string-n!'.
  Export both `get-string-n!' and `get-string-n'.
* module/rnrs.scm: Also export these.

* test-suite/tests/r6rs-ports.test (8.2.9 Textual input): Add a few
  tests for `get-string-n' and `get-string-n!'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-03-13 22:39:14 +01:00
Ludovic Courtès
b075a6d766 Fix `define-inlinable' in SRFI-9 so that arguments are evaluated only once.
* module/srfi/srfi-9.scm (define-inlinable): When inlining, evaluate the
  arguments only once.  Reported by Andreas Rottmann; thanks to Andy
  Wingo for the elegant solution.

* test-suite/tests/srfi-9.test ("side-effecting arguments"): New test
  prefix.
2011-03-11 21:02:30 +01:00
Ludovic Courtès
d82f8518b9 FFI: Return the right alignment for structures.
* libguile/foreign.c (scm_alignof): Fix handling of structure alignment.
  Reported by Aidan Gauland <aidalgol@no8wireless.co.nz>.

* test-suite/tests/foreign.test ("structs")["alignof { int8, double,
  int8 }", "int8, { int8, double, int8 }, int16"]: New tests.
2011-03-10 22:24:23 +01:00
Andreas Rottmann
531c9f1dc5 Don't mix definitions and expressions in SRFI-9
The expansion of `define-inlinable' contained an expression, which made
SRFI-9's `define-record-type' fail in non-toplevel contexts ("definition
used in expression context").

* module/srfi/srfi-9.scm (define-inlinable): Get rid of apparently
  useless expression in the expansion, so the expansion yields only
  definitions.  At the same time, use a space in the generated names to
  lessen the chances of name conflicts, also avoiding -Wunused-toplevel
  warnings.
* test-suite/tests/srfi-9.test (non-toplevel): New test verifying that
  `define-record-type' works in non-toplevel context as well.
* doc/ref/srfi-modules.texi (SRFI-9 - define-record-type): Add
  subsubsection noting that Guile does not enforce top-levelness.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-03-09 21:36:54 +01:00
Mark H Weaver
0748e3f3f0 Quotient, remainder and modulo accept inexact integers
* libguile/numbers.c (scm_quotient, scm_remainder, scm_modulo): Accept
  inexact integers as well as exact ones, as required by the R5RS.

* test-suite/tests/numbers.test (quotient, remainder, modulo): Add tests.
2011-03-08 18:20:11 -05:00
Mark H Weaver
495a39c40f Quotient, remainder and modulo accept inexact integers
* libguile/numbers.c (scm_quotient, scm_remainder, scm_modulo): Accept
  inexact integers as well as exact ones, as required by the R5RS.

* test-suite/tests/numbers.test (quotient, remainder, modulo): Add tests.
2011-03-08 18:18:31 -05:00
Mark H Weaver
ae255d65c3 Fix bytevectors VALIDATE_REAL to test for reals, not rationals
Reported and fixed by Daniel Llorens <dll@bluewin.ch>.

* libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals.

* test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests.
2011-03-08 17:52:52 -05:00
Mark H Weaver
73ea546c51 Fix bytevectors VALIDATE_REAL to test for reals, not rationals
Reported and fixed by Daniel Llorens <dll@bluewin.ch>.

* libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals.

* test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests.
2011-03-08 17:50:47 -05:00
Andy Wingo
534491d0b7 fix scm_setter
* libguile/procs.c (scm_setter): Only get at the setter slot if the pure
  generic actually has a setter.  Needs test.

* test-suite/tests/goops.test ("defining generics"):
  ("defining accessors"): Add `setter' tests.
2011-03-08 20:53:17 +01:00
Ludovic Courtès
65ea26c582 Handle letrec*' like letrec' in simple cases.
* module/language/tree-il/fix-letrec.scm (fix-letrec!): When X is a
  `letrec*' with only lambdas and simple expressions, analyze it as if
  it were a `letrec'.
* test-suite/tests/tree-il.test ("letrec"): Add test for
  `(letrec* (x y) (xx yy) ((const 1) (const 2)) (lexical y yy))'.
2011-03-06 23:05:01 +01:00
Andy Wingo
d59dd06eb9 add ice-9 eval-string
* module/Makefile.am:
* module/ice-9/eval-string.scm: New module, for use in implementing the
  scm_c_eval_string_from_file_line suggestion.

* test-suite/Makefile.am:
* test-suite/tests/eval-string.test: New tests.
2011-03-05 23:16:11 +01:00