Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test CoffeeScript compiler #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ext/duktape/duktape_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
static VALUE mDuktape;
static VALUE cContext;
static VALUE eContextError;
static void error_handler(duk_context *, int);
static void error_handler(duk_context *, int, const char *);

static void ctx_dealloc(void *ctx)
{
Expand All @@ -22,7 +22,7 @@ static VALUE ctx_stack_to_value(duk_context *ctx, int index)
size_t len;
const char *buf;
int type;

type = duk_get_type(ctx, index);
switch (type) {
case DUK_TYPE_NULL:
Expand Down Expand Up @@ -162,7 +162,7 @@ static VALUE ctx_call_prop(int argc, VALUE* argv, VALUE self)
return res;
}

static void error_handler(duk_context *ctx, int code)
static void error_handler(duk_context *ctx, int code, const char *msg)
{
duk_set_top(ctx, 0);
rb_raise(eContextError, "fatal duktape error: %d", code);
Expand All @@ -181,4 +181,3 @@ void Init_duktape_ext()
rb_define_method(cContext, "get_prop", ctx_get_prop, 1);
rb_define_method(cContext, "call_prop", ctx_call_prop, -1);
}

3 changes: 1 addition & 2 deletions lib/duktape/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module Duktape
VERSION = "0.11.0.0"
VERSION = "1.0.2.0"
end

8 changes: 7 additions & 1 deletion test/test_duktape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'minitest'
require 'minitest/autorun'
require 'duktape'
require 'open-uri'

class TestDuktape < Minitest::Spec
def setup
Expand Down Expand Up @@ -150,6 +151,11 @@ def test_bind_constructor
obj.value;
EOF
end

def test_coffeescript
source = open("http://coffeescript.org/extras/coffee-script.js").read
@ctx.eval_string(source, "coffee-script.js")
@ctx.eval_string("CoffeeScript.compile('square = (x) -> x * x')")
end
end
end