refactor ruby
This commit is contained in:
parent
0e5257e98c
commit
763550b63a
8 changed files with 25 additions and 25 deletions
|
|
@ -1,3 +1,3 @@
|
|||
def test_func
|
||||
print("abc" + 5)
|
||||
print('abc' + 5)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
STATE = {
|
||||
"called_with" => nil
|
||||
$state = {
|
||||
'called_with' => nil
|
||||
}
|
||||
|
||||
def test_func(x)
|
||||
called_with = x
|
||||
def test_func(val)
|
||||
$state['called_with'] = val
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
STATE = {
|
||||
$state = {
|
||||
'x' => nil
|
||||
}
|
||||
|
||||
def test_func
|
||||
rust_func.and_then do |x|
|
||||
STATE['x'] = x
|
||||
end
|
||||
# rust_func.and_then do |x|
|
||||
# $state['x'] = x
|
||||
# end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
def test_func
|
||||
rust_func(5, "test")
|
||||
rust_func(5, 'test')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
STATE = {
|
||||
"times_called" => 0
|
||||
$state = {
|
||||
'times_called' => 0
|
||||
}
|
||||
|
||||
def test_func
|
||||
STATE["times_called"] += 1
|
||||
$state['times_called'] += 1
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
STATE = {
|
||||
'a_value' => nil,
|
||||
'b_value' => nil
|
||||
$state = {
|
||||
'a_value' => nil,
|
||||
'b_value' => nil
|
||||
}
|
||||
|
||||
def test_func(a, b)
|
||||
STATE['a_value'] = a
|
||||
STATE['b_value'] = b
|
||||
$state['a_value'] = a
|
||||
$state['b_value'] = b
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
STATE = {
|
||||
"a_value" => nil
|
||||
$state = {
|
||||
'a_value' => nil
|
||||
}
|
||||
|
||||
def test_func(a)
|
||||
STATE["a_value"] = a
|
||||
$state['a_value'] = a
|
||||
end
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ mod lua_tests {
|
|||
mod ruby_tests {
|
||||
use bevy::prelude::*;
|
||||
use bevy_scriptum::runtimes::ruby::{prelude::*, RubyScriptData};
|
||||
use magnus::{value::ReprValue, Module};
|
||||
use magnus::{value::ReprValue, Module, Object};
|
||||
|
||||
impl AssertStateKeyValue for RubyRuntime {
|
||||
type ScriptData = RubyScriptData;
|
||||
|
|
@ -496,7 +496,7 @@ mod ruby_tests {
|
|||
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
||||
let key = key.to_string();
|
||||
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();
|
||||
assert_eq!(res, value)
|
||||
})
|
||||
|
|
@ -506,7 +506,7 @@ mod ruby_tests {
|
|||
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
||||
let key = key.to_string();
|
||||
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();
|
||||
assert_eq!(res, value)
|
||||
})
|
||||
|
|
@ -520,7 +520,7 @@ mod ruby_tests {
|
|||
) {
|
||||
let runtime = world.get_resource::<RubyRuntime>().unwrap();
|
||||
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();
|
||||
assert_eq!(res, value);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue