Marek Kotewicz
10 years ago
13 changed files with 191 additions and 38 deletions
@ -0,0 +1,25 @@ |
|||
cmake_policy(SET CMP0015 NEW) |
|||
# this policy was introduced in cmake 3.0 |
|||
# remove if, once 3.0 will be used on unix |
|||
if (${CMAKE_MAJOR_VERSION} GREATER 2) |
|||
# old policy do not use MACOSX_RPATH |
|||
cmake_policy(SET CMP0042 OLD) |
|||
endif() |
|||
|
|||
set(CMAKE_AUTOMOC OFF) |
|||
|
|||
aux_source_directory(. SRC_LIST) |
|||
|
|||
include_directories(BEFORE ..) |
|||
include_directories(${V8_INCLUDE_DIRS}) |
|||
|
|||
set(EXECUTABLE jsconsole) |
|||
|
|||
file(GLOB HEADERS "*.h") |
|||
|
|||
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) |
|||
|
|||
target_link_libraries(${EXECUTABLE} jsengine) |
|||
|
|||
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) |
|||
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) |
@ -0,0 +1,5 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 28/04/15.
|
|||
//
|
|||
|
|||
#include "JSConsole.h" |
@ -0,0 +1,19 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 28/04/15.
|
|||
//
|
|||
|
|||
#pragma once |
|||
|
|||
namespace dev |
|||
{ |
|||
namespace eth |
|||
{ |
|||
|
|||
class JSConsole |
|||
{ |
|||
public: |
|||
virtual void repl() const = 0; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 28/04/15.
|
|||
//
|
|||
|
|||
#include <libjsengine/JSV8Engine.h> |
|||
#include <libjsengine/JSV8Printer.h> |
|||
#include "JSV8Console.h" |
|||
|
|||
using namespace dev; |
|||
using namespace dev::eth; |
|||
|
|||
JSV8Console::JSV8Console(): m_engine(), m_printer(m_engine) |
|||
{ |
|||
|
|||
} |
|||
|
|||
void JSV8Console::repl() const |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,29 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 28/04/15.
|
|||
//
|
|||
|
|||
#pragma once |
|||
|
|||
#include "JSConsole.h" |
|||
|
|||
namespace dev |
|||
{ |
|||
namespace eth |
|||
{ |
|||
|
|||
class JSV8Engine; |
|||
class JSV8Printer; |
|||
|
|||
class JSV8Console : public JSConsole |
|||
{ |
|||
public: |
|||
JSV8Console(); |
|||
void repl() const; |
|||
|
|||
private: |
|||
JSV8Engine m_engine; |
|||
JSV8Printer m_printer; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 28/04/15.
|
|||
//
|
|||
|
|||
#include "JSV8Printer.h" |
|||
|
|||
using namespace dev; |
|||
using namespace eth; |
|||
|
|||
JSV8Printer::JSV8Printer(JSV8Engine const& _engine) |
|||
{ |
|||
|
|||
} |
|||
|
|||
const char* JSV8Printer::print(v8::Handle<v8::Value> const& _value) const |
|||
{ |
|||
return ""; |
|||
} |
@ -0,0 +1,23 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 28/04/15.
|
|||
//
|
|||
|
|||
#pragma once |
|||
|
|||
#include "JSV8Engine.h" |
|||
|
|||
|
|||
namespace dev |
|||
{ |
|||
namespace eth |
|||
{ |
|||
|
|||
class JSV8Printer |
|||
{ |
|||
public: |
|||
JSV8Printer(JSV8Engine const& _engine); |
|||
const char* print(v8::Handle<v8::Value> const& _value) const; |
|||
}; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 27/04/15.
|
|||
//
|
|||
|
|||
#include <boost/test/unit_test.hpp> |
|||
#include <libjsengine/JSV8Engine.h> |
|||
|
|||
using namespace std; |
|||
using namespace dev; |
|||
using namespace dev::eth; |
|||
|
|||
BOOST_AUTO_TEST_SUITE(jsv8engine) |
|||
|
|||
BOOST_AUTO_TEST_CASE(evalInteger) |
|||
{ |
|||
JSV8Engine scope; |
|||
string result = scope.evaluate("1 + 1"); |
|||
BOOST_CHECK_EQUAL(result, "2"); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(evalString) |
|||
{ |
|||
JSV8Engine scope; |
|||
string result = scope.evaluate("'hello ' + 'world'"); |
|||
BOOST_CHECK_EQUAL(result, "hello world"); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(evalEmpty) |
|||
{ |
|||
JSV8Engine scope; |
|||
string result = scope.evaluate(""); |
|||
BOOST_CHECK_EQUAL(result, "undefined"); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_SUITE_END() |
@ -1,21 +0,0 @@ |
|||
//
|
|||
// Created by Marek Kotewicz on 27/04/15.
|
|||
//
|
|||
|
|||
#include <boost/test/unit_test.hpp> |
|||
#include <libjsengine/JSV8Engine.h> |
|||
|
|||
using namespace std; |
|||
using namespace dev; |
|||
using namespace dev::eth; |
|||
|
|||
BOOST_AUTO_TEST_SUITE(jsscope) |
|||
|
|||
BOOST_AUTO_TEST_CASE(common) |
|||
{ |
|||
JSV8Engine scope; |
|||
string result = scope.evaluate("1 + 1"); |
|||
BOOST_CHECK_EQUAL(result, "2"); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_SUITE_END() |
Loading…
Reference in new issue