From 79b0bda0d336c5b367083673fd6110a1051321e1 Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 23 Aug 2024 04:20:44 +0300 Subject: [PATCH] =?UTF-8?q?fix=20=E2=80=A2file.MapBytes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 2 +- src/core/arrFns.h | 6 +++--- test/cases/system.bqn | 3 ++- test/cases/usz32.bqn | 12 ++++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index b7868404..8007f2a3 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -830,7 +830,7 @@ B select_rows_direct(B x, ux csz, ux cam, void* inds, ux indn, u8 ie) { // ⥊ ( generic_int:; assert(ie!=el_bit && generic_allowed); - B indo = taga(arr_shVec(m_tyslice(inds, a(emptyIVec()), ie, indn))); + B indo = taga(arr_shVec(m_tyslice(inds, a(emptyIVec()), t_i8arr + ie-el_i8, indn))); return select_cells_base(indo, x, csz, cam); decG_ret:; diff --git a/src/core/arrFns.h b/src/core/arrFns.h index 2f278781..01857975 100644 --- a/src/core/arrFns.h +++ b/src/core/arrFns.h @@ -96,9 +96,9 @@ SHOULD_INLINE u8 kCellWidthLog(B x, ur k) { } SHOULD_INLINE u8 cellWidthLog(B x) { return kCellWidthLog(x, 1); } -static Arr* m_tyslice(void* data, Arr* parent, u8 eltype, ux ia) { - assert(eltype!=el_bit && eltype!=el_B); - Arr* a = m_arr(sizeof(TySlice), t_i8slice + eltype-el_i8, ia); +static Arr* m_tyslice(void* data, Arr* parent, u8 type, ux ia) { + assert(IS_ANY_ARR(type) && IS_SLICE(type)); + Arr* a = m_arr(sizeof(TySlice), type, ia); ((TySlice*) a)->p = parent; ((TySlice*) a)->a = data; return a; diff --git a/test/cases/system.bqn b/test/cases/system.bqn index a08d6ff4..a01d4408 100644 --- a/test/cases/system.bqn +++ b/test/cases/system.bqn @@ -1,4 +1,4 @@ -# not tested here: •Out •Show •Exit •GetLine •Cmp •CurrentError •FFI •internal.HeapDump •file.MapBytes +# not tested here: •Out •Show •Exit •GetLine •Cmp •CurrentError •FFI •internal.HeapDump %DEF var V←•internal.Variation ⋄ LV←•internal.ListVariations ⋄ CLR←•internal.ClearRefs %DEF tvar %USE var ⋄ _tvar ← {F _𝕣 x: (CLR@) ⊢ {F 𝕩 V x}¨ LV 𝕩; w F _𝕣 x: (CLR@) ⊢ (LV 𝕨) {(𝕨 V w) F 𝕩 V x}⌜ LV 𝕩} @@ -129,6 +129,7 @@ f←•ReBQN{primitives⇐⋈'÷'‿- ⋄ system⇐⟨"primitives", "foo"‿⋈, •FChars "testfile.bqn" %% "abc"∾(@+10)∾"def𝕩" •FBytes "testfile.bqn" %% @+97‿98‿99‿10‿100‿101‿102‿240‿157‿149‿169 •FLines "testfile.bqn" %% "abc"‿"def𝕩" +! 97‿98‿99‿10‿100‿101‿102‿240‿157‿149‿169 ≡ @-˜ •file.MapBytes "testfile.bqn" •file.Name "testfile3B.bqn" •file.Rename "testfile3.bqn" %% "testfile3B.bqn" !"•file.Rename: Failed to rename file" % "testfile3B.bqn" •file.Rename "testfile.bqn" diff --git a/test/cases/usz32.bqn b/test/cases/usz32.bqn index c7411d4f..47b75e5b 100644 --- a/test/cases/usz32.bqn +++ b/test/cases/usz32.bqn @@ -1,6 +1,6 @@ -!"Out of memory" % a←(2⋆20) ⥊ 1e9 ⋄ {𝕊: a}˘ a -!"⥊: 𝕨 too large" % a←(2⋆20) ⥊ 1e9 ⋄ a˘ a -!"Out of memory" % (2⋆25)/(2⋆10)⥊10 -!"Out of memory" % k←16384 ⋄ n←k÷˜2⋆32 ⋄ (n⥊k) / n⥊1 -!"Out of memory" % k←64 ⋄ n←k÷˜2⋆32 ⋄ (n⥊k) / n⥊1 # %SLOW -!"Out of memory" % ∾˜⍟31 ↕2 # %SLOW +!"Out of memory" % a←(2⋆20) ⥊ 1e9 ⋄ ≠•internal.Keep {𝕊: a}˘ a +!"⥊: 𝕨 too large" % a←(2⋆20) ⥊ 1e9 ⋄ ≠•internal.Keep a˘ a +!"Out of memory" % ≠•internal.Keep (2⋆25)/(2⋆10)⥊10 +!"Out of memory" % k←16384 ⋄ n←k÷˜2⋆32 ⋄ ≠•internal.Keep (n⥊k) / n⥊1 +!"Out of memory" % k←64 ⋄ n←k÷˜2⋆32 ⋄ ≠•internal.Keep (n⥊k) / n⥊1 # %SLOW +!"Out of memory" % ≠•internal.Keep ∾˜⍟31 ↕2 # %SLOW