summaryrefslogtreecommitdiffstats
path: root/tests/017
Commit message (Collapse)AuthorAgeFilesLines
* printer: improve object formatting.Kaz Kylheku2018-04-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is an issue with the printer in that it produces output whereby objects continue on the same line after a multi-line object, e.g: (foo (foobly bar xyzzy quux) (oops same line)) rather than: (foo (foobly bar xyzzy quux) (oops same line)) There is a simple fix for this: set a flag to force a line break on the next width-check operation whenever an object has been broken into multiple lines. width-check can return a Boolean indication whether it generated a line break, and so aggregate object printing routines can tell whether their object has been broken into lines, and set the flag. * stream.h (struct strm_base): New member, force_break. (force_break): Declared. * stream.c (strm_base_init): Extent initializer to cover force_break flag. (put_string, put_char): Clear the force_break flag whenever we hit column zero. (width_check): If indent mode is on, and force_break is true, generate a break. Clear force_break. (force_break): New function. (stream_init): Register force-break intrinsic. * buf.c (buf_print): Set the force break flag if the buffer was broken into multiple lines. * hash.c (hash_print_op): Set the force break flag if the hash was broken into multiple lines. * lib.c (obj_print_impl): Same logic for lists. * struct.c (struct_inst_print): Same logic for structs. * tests/009/json.expected, tests/011/macros-2.expected, tests/012/struct.tl, tests/017/glob-zarray.expected: Update expected textual output to reflect new formatting.
* ffi: glob test: struct size on Linux and Cygwin.Kaz Kylheku2017-05-212-22/+40
| | | | | | | | | * tests/017/glob-carray.tl (glob-t): Restructure to case statement. Add padding to struct based on looking at the glibc definition. Add FFI definition based on Cygwin header. * tests/017/glob-zarray.tl (glob-t): Likewise.
* ffi: port glob tests to Darwin.Kaz Kylheku2017-05-212-10/+28
| | | | | | | | | * tests/017/glob-carray.tl (glob-t): Initialize reserve member to 0. Since it doesn't exist on Darwin, it will stay nil, and change the the test output. A Darwin variant of the corresponding FFI type is provided. * tests/017/glob-zarray.tl (glob-t): Likewise.
* ffi: add two tests based on realpath.Kaz Kylheku2017-05-202-0/+14
| | | | | | | | | | | | | | | | | The realpath function is called using FFI. One approach passes a null pointer, so that the function dynamically allocates. The return value is str-d, causing FFI to take ownership of the pointer, freeing it. The other approach is to pass a pointer to a large null-terminated character array, marked for ownership transfer to the function. FFI allocates it and puts the argument into it, which is just a dummy empty string. The function fills that buffer and returns it. The return is captured as a str-d, so FFI takes ownership back, and frees the buffer. * tests/017/realpath.tl: New function. * tests/017/realpath.expected: Likewise.
* ffi: add two tests based on glob function.Kaz Kylheku2017-05-204-0/+45
| | | | | | | | | | | | | | | | | | | One approach captures the paths as a carray of strings, and explicitly frees it with globfree. The other approach uses a zarray, taking advantage of null termination. globfree is elided because TXR FFI does the freeing; the types used declare to it that it is taking ownership of a dynamically allocated vector of dynamically allocated strings, and so it performs the equivalent of globfree. * tests/017/glob-carray.expected: New file. * tests/017/glob-carray.tl: Likewise. * tests/017/glob-zarray.expected: Likewise. * tests/017/glob-zarray.tl: Likewise.
* tests: first FFI regression test case.Kaz Kylheku2017-05-132-0/+48
* tests/017/qsort.expected: New file. * tests/017/qsort.tl: New file. * tests/common.tl (libc): New function. * Makefile (tst/tests/017/%): Clear TXR_DBG_OPTS so the GC stress test isn't applied to tests in this directory.