From 860e596b8a656e270efb7ce70b15363fd608f1ef Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Fri, 3 Mar 2017 07:57:50 -0800 Subject: [PATCH] Test wrenSetSlotNull(). --- test/api/slots.c | 8 ++++---- test/api/slots.wren | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/api/slots.c b/test/api/slots.c index c82b61c2..09064638 100644 --- a/test/api/slots.c +++ b/test/api/slots.c @@ -12,7 +12,6 @@ static void getSlots(WrenVM* vm) { bool result = true; if (wrenGetSlotBool(vm, 1) != true) result = false; - // TODO: Test wrenGetSlotForeign(). int length; const char* bytes = wrenGetSlotBytes(vm, 2, &length); @@ -46,8 +45,7 @@ static void setSlots(WrenVM* vm) wrenSetSlotBytes(vm, 2, "by\0te", 5); wrenSetSlotDouble(vm, 3, 1.5); wrenSetSlotString(vm, 4, "str"); - - // TODO: wrenSetSlotNull(). + wrenSetSlotNull(vm, 5); // Read the slots back to make sure they were set correctly. @@ -62,6 +60,8 @@ static void setSlots(WrenVM* vm) if (wrenGetSlotDouble(vm, 3) != 1.5) result = false; if (strcmp(wrenGetSlotString(vm, 4), "str") != 0) result = false; + if (wrenGetSlotType(vm, 5) != WREN_TYPE_NULL) result = false; + if (result) { // Move the value into the return position. @@ -170,7 +170,7 @@ WrenForeignMethodFn slotsBindMethod(const char* signature) { if (strcmp(signature, "static Slots.noSet") == 0) return noSet; if (strcmp(signature, "static Slots.getSlots(_,_,_,_,_)") == 0) return getSlots; - if (strcmp(signature, "static Slots.setSlots(_,_,_,_)") == 0) return setSlots; + if (strcmp(signature, "static Slots.setSlots(_,_,_,_,_)") == 0) return setSlots; if (strcmp(signature, "static Slots.slotTypes(_,_,_,_,_,_,_)") == 0) return slotTypes; if (strcmp(signature, "static Slots.ensure()") == 0) return ensure; if (strcmp(signature, "static Slots.ensureOutsideForeign()") == 0) return ensureOutsideForeign; diff --git a/test/api/slots.wren b/test/api/slots.wren index 2a8c7219..24767898 100644 --- a/test/api/slots.wren +++ b/test/api/slots.wren @@ -1,7 +1,7 @@ class Slots { foreign static noSet foreign static getSlots(bool, num, string, bytes, value) - foreign static setSlots(a, b, c, d) + foreign static setSlots(a, b, c, d, e) foreign static slotTypes(bool, foreignObj, list, nullObj, num, string, unknown) foreign static ensure() foreign static ensureOutsideForeign() @@ -21,7 +21,7 @@ var value = ["value"] System.print(Slots.getSlots(true, "by\0te", 1.5, "str", value) == value) // expect: true -System.print(Slots.setSlots(value, 0, 0, 0) == value) +System.print(Slots.setSlots(value, 0, 0, 0, 0) == value) // expect: true System.print(Slots.slotTypes(false, ForeignType.new(), [], null, 1.2, "str", 1..2))