| 1 | module scheme |
| 2 | |
| 3 | fn test_library_driver_counts_keep_sequential_positions_wider_than_operands() { |
| 4 | // The largest library constant operand is representable although its driver |
| 5 | // instruction positions exceed signed32. Count validation allocates nothing. |
| 6 | assert library_instruction_count(2147483647, 3, 2) or { panic(err.msg()) } == 6442450943 |
| 7 | assert library_instruction_count(1073741824, 2, 4) or { panic(err.msg()) } == 2147483652 |
| 8 | assert library_instruction_count(0, 3, 2) or { panic(err.msg()) } == 2 |
| 9 | for args in [[int(-1), 3, 2], [int(1), 0, 2], [int(1), 3, -1], [int(9223372036854775807), 3, |
| 10 | 2]] { |
| 11 | if _ := library_instruction_count(args[0], args[1], args[2]) { |
| 12 | assert false |
| 13 | } |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | fn test_library_export_storage_preserves_variable_and_transformer_bindings() { |
| 18 | mut vm := new() |
| 19 | value := vm.eval('(define-library (storage test) |
| 20 | (export payload make-packet get-text) |
| 21 | (import (vile base)) |
| 22 | (begin |
| 23 | (define payload #u8(65 66)) |
| 24 | (define-record-type packet (fields bytes)) |
| 25 | (define-syntax get-text |
| 26 | (syntax-rules () ((_ object) |
| 27 | (bytevector->string (packet-bytes object) |
| 28 | (make-transcoder (utf-8-codec) (eol-style none) (error-handling-mode raise)))))))) |
| 29 | (import (prefix (storage test) s:)) |
| 30 | (s:get-text (s:make-packet s:payload))') or { panic(err.msg()) } |
| 31 | assert value.as_string() or { panic(err.msg()) } == 'AB' |
| 32 | } |
| 33 | |