diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-10-24 22:22:26 +0000 |
---|---|---|
committer | andreas <andreas@daaaf23c-2e50-4459-9457-1e69db5a47bf> | 2014-10-24 22:22:26 +0000 |
commit | 7e51bf3804e50ea063fcc97b2682a32a8505902f (patch) | |
tree | 6a6097216708049b5dd7a4c43020c85aafb046a1 /test/core/script/Variant.cpp | |
parent | 4a9912f516bf096c6f8c6259b3fc6ba4b95b8d69 (diff) |
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
Diffstat (limited to 'test/core/script/Variant.cpp')
-rw-r--r-- | test/core/script/Variant.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 <gtest/gtest.h> #include <core/script/Variant.hpp> +#include <core/script/Function.hpp> +#include <core/script/Object.hpp> 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<Variant> &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); +} + + } } |