Ruby support #1
8 changed files with 25 additions and 25 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
def test_func
|
def test_func
|
||||||
print("abc" + 5)
|
print('abc' + 5)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
STATE = {
|
$state = {
|
||||||
"called_with" => nil
|
'called_with' => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_func(x)
|
def test_func(val)
|
||||||
called_with = x
|
$state['called_with'] = val
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
STATE = {
|
$state = {
|
||||||
'x' => nil
|
'x' => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_func
|
def test_func
|
||||||
rust_func.and_then do |x|
|
# rust_func.and_then do |x|
|
||||||
STATE['x'] = x
|
# $state['x'] = x
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
def test_func
|
def test_func
|
||||||
rust_func(5, "test")
|
rust_func(5, 'test')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
STATE = {
|
$state = {
|
||||||
"times_called" => 0
|
'times_called' => 0
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_func
|
def test_func
|
||||||
STATE["times_called"] += 1
|
$state['times_called'] += 1
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
STATE = {
|
$state = {
|
||||||
'a_value' => nil,
|
'a_value' => nil,
|
||||||
'b_value' => nil
|
'b_value' => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_func(a, b)
|
def test_func(a, b)
|
||||||
STATE['a_value'] = a
|
$state['a_value'] = a
|
||||||
STATE['b_value'] = b
|
$state['b_value'] = b
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
STATE = {
|
$state = {
|
||||||
"a_value" => nil
|
'a_value' => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_func(a)
|
def test_func(a)
|
||||||
STATE["a_value"] = a
|
$state['a_value'] = a
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ mod lua_tests {
|
||||||
mod ruby_tests {
|
mod ruby_tests {
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::runtimes::ruby::{prelude::*, RubyScriptData};
|
use bevy_scriptum::runtimes::ruby::{prelude::*, RubyScriptData};
|
||||||
use magnus::{value::ReprValue, Module};
|
use magnus::{value::ReprValue, Module, Object};
|
||||||
|
|
||||||
impl AssertStateKeyValue for RubyRuntime {
|
impl AssertStateKeyValue for RubyRuntime {
|
||||||
type ScriptData = RubyScriptData;
|
type ScriptData = RubyScriptData;
|
||||||
|
|
@ -496,7 +496,7 @@ mod ruby_tests {
|
||||||
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
||||||
let key = key.to_string();
|
let key = key.to_string();
|
||||||
runtime.with_engine_thread(move |engine| {
|
runtime.with_engine_thread(move |engine| {
|
||||||
let state: magnus::value::Value = engine.class_object().const_get("STATE").unwrap();
|
let state: magnus::value::Value = engine.eval("$state").unwrap();
|
||||||
let res: i64 = state.funcall_public("[]", (key,)).unwrap();
|
let res: i64 = state.funcall_public("[]", (key,)).unwrap();
|
||||||
assert_eq!(res, value)
|
assert_eq!(res, value)
|
||||||
})
|
})
|
||||||
|
|
@ -506,7 +506,7 @@ mod ruby_tests {
|
||||||
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
||||||
let key = key.to_string();
|
let key = key.to_string();
|
||||||
runtime.with_engine_thread(move |engine| {
|
runtime.with_engine_thread(move |engine| {
|
||||||
let state: magnus::value::Value = engine.class_object().const_get("STATE").unwrap();
|
let state: magnus::value::Value = engine.eval("$state").unwrap();
|
||||||
let res: i32 = state.funcall_public("[]", (key,)).unwrap();
|
let res: i32 = state.funcall_public("[]", (key,)).unwrap();
|
||||||
assert_eq!(res, value)
|
assert_eq!(res, value)
|
||||||
})
|
})
|
||||||
|
|
@ -520,7 +520,7 @@ mod ruby_tests {
|
||||||
) {
|
) {
|
||||||
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
||||||
runtime.with_engine(|engine| {
|
runtime.with_engine(|engine| {
|
||||||
let state: magnus::value::Value = engine.class_object().const_get("STATE").unwrap();
|
let state: magnus::value::Value = engine.eval("$state").unwrap();
|
||||||
let res: String = state.funcall_public("[]", (key,)).unwrap();
|
let res: String = state.funcall_public("[]", (key,)).unwrap();
|
||||||
assert_eq!(res, value);
|
assert_eq!(res, value);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue