From 7e51bf3804e50ea063fcc97b2682a32a8505902f Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 24 Oct 2014 22:22:26 +0000 Subject: added Function, Property and Object classes; added CMakeLists entries for the mozjs-24 library (the Firefox JavaScript engine which is available as Package on Fedora); added Doxygen target to makefile git-svn-id: file:///var/local/svn/basicwriter@75 daaaf23c-2e50-4459-9457-1e69db5a47bf --- test/core/script/Variant.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/core/script/Variant.cpp') diff --git a/test/core/script/Variant.cpp b/test/core/script/Variant.cpp index cf8f3c7..f229e3a 100644 --- a/test/core/script/Variant.cpp +++ b/test/core/script/Variant.cpp @@ -19,6 +19,8 @@ #include #include +#include +#include namespace ousia { namespace script { @@ -81,6 +83,21 @@ TEST(Variant, getMapValue) ASSERT_EQ("entry2", (*map.find("key2")).second.getStringValue()); } +TEST(Variant, getFunctionValue) +{ + int64_t i = 0; + HostFunction f{[](const std::vector &args, void *data) { + *((int64_t*)data) = args[0].getIntegerValue(); + return Variant{"Hello World"}; + }, &i}; + + Variant v{&f}; + ASSERT_TRUE(v.getFunctionValue() != nullptr); + ASSERT_EQ("Hello World", v.getFunctionValue()->call({{(int64_t)42}}).getStringValue()); + ASSERT_EQ(42, i); +} + + } } -- cgit v1.2.3