mirror of
https://github.com/janet-lang/janet
synced 2025-01-24 14:16:52 +00:00
Address #23
This commit is contained in:
parent
8ee2f0a1d6
commit
e755f98300
@ -192,10 +192,10 @@ static Janet cfun_buffer_word(int32_t argc, Janet *argv) {
|
||||
janet_arity(argc, 1, -1);
|
||||
JanetBuffer *buffer = janet_getbuffer(argv, 0);
|
||||
for (i = 1; i < argc; i++) {
|
||||
double number = janet_getnumber(argv, 0);
|
||||
double number = janet_getnumber(argv, i);
|
||||
uint32_t word = (uint32_t) number;
|
||||
if (word != number)
|
||||
janet_panicf("cannot convert %v to machine word", argv[0]);
|
||||
janet_panicf("cannot convert %v to machine word", argv[i]);
|
||||
janet_buffer_push_u32(buffer, word);
|
||||
}
|
||||
return argv[0];
|
||||
|
@ -159,6 +159,17 @@
|
||||
(buffer/blit b2 "abcdefg" 5 6)
|
||||
(assert (= (string b2) "joytogjoyto") "buffer/blit 3")
|
||||
|
||||
# Buffer push word
|
||||
|
||||
(def b3 @"")
|
||||
(buffer/push-word b3 0xFF 0x11)
|
||||
(assert (= 8 (length b3)) "buffer/push-word 1")
|
||||
(assert (= "\xFF\0\0\0\x11\0\0\0" (string b3)) "buffer/push-word 2")
|
||||
(buffer/clear b3)
|
||||
(buffer/push-word b3 0xFFFFFFFF 0x1100)
|
||||
(assert (= 8 (length b3)) "buffer/push-word 3")
|
||||
(assert (= "\xFF\xFF\xFF\xFF\0\x11\0\0" (string b3)) "buffer/push-word 4")
|
||||
|
||||
# Peg
|
||||
|
||||
(defn check-match
|
||||
|
Loading…
Reference in New Issue
Block a user