style: 自动格式化
This commit is contained in:
@@ -37,7 +37,10 @@ fn eval_val(source: &str) -> (Vm, Result<JsValue, String>) {
|
||||
|
||||
fn to_str(vm: &Vm, val: JsValue) -> String {
|
||||
if val.is_string() {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
format!("{}", val)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<JsValue, String> {
|
||||
}
|
||||
|
||||
fn str_val(vm: &Vm, val: JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// -- direct native fn tests --
|
||||
|
||||
@@ -9,7 +9,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<oxide_types::value::JsValue, String
|
||||
}
|
||||
|
||||
fn str_val(vm: &Vm, val: oxide_types::value::JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// -- static methods --
|
||||
|
||||
@@ -34,7 +34,11 @@ fn function_bind_creates_wrapper() {
|
||||
fn function_constructor_is_global() {
|
||||
let mut vm = Vm::new();
|
||||
let result = eval(&mut vm, "typeof Function").unwrap();
|
||||
let rendered = vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let rendered = vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(rendered, "function");
|
||||
}
|
||||
|
||||
@@ -82,7 +86,11 @@ fn function_to_string_includes_function() {
|
||||
let mut vm = Vm::new();
|
||||
let result = eval(&mut vm, "Math.max.toString()").unwrap();
|
||||
assert!(result.is_string());
|
||||
let rendered = vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let rendered = vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(rendered, "function max() { [native code] }");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<JsValue, String> {
|
||||
}
|
||||
|
||||
fn str_val(vm: &Vm, val: JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// -- direct native fn tests --
|
||||
|
||||
@@ -76,7 +76,11 @@ fn number_constructor() {
|
||||
fn to_string_of_number() {
|
||||
let mut vm = Vm::new();
|
||||
let result = eval(&mut vm, "var n = 42; n.toString()").unwrap();
|
||||
let s = vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let s = vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(s, "42");
|
||||
}
|
||||
|
||||
@@ -84,7 +88,11 @@ fn to_string_of_number() {
|
||||
fn to_fixed_of_number() {
|
||||
let mut vm = Vm::new();
|
||||
let result = eval(&mut vm, "var n = 3.14159; n.toFixed(2)").unwrap();
|
||||
let s = vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let s = vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(s, "3.14");
|
||||
}
|
||||
|
||||
@@ -113,7 +121,11 @@ fn number_epsilon_is_positive() {
|
||||
fn number_to_exponential() {
|
||||
let mut vm = Vm::new();
|
||||
let result = eval(&mut vm, "var n = 123.456; n.toExponential(2)").unwrap();
|
||||
let s = vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let s = vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(s, "1.23e2");
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,11 @@ fn object_assign_copies() {
|
||||
fn object_assign_boxes_primitive_target() {
|
||||
let (_vm, result) = eval("var result = Object.assign('a'); result.valueOf()").unwrap();
|
||||
assert!(result.is_string());
|
||||
let rendered = _vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let rendered = _vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(rendered, "a");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<JsValue, String> {
|
||||
}
|
||||
|
||||
fn to_str(vm: &Vm, val: JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// --- RegExp constructor ---
|
||||
|
||||
@@ -10,7 +10,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<JsValue, String> {
|
||||
}
|
||||
|
||||
fn to_str(vm: &Vm, val: JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -10,7 +10,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<JsValue, String> {
|
||||
}
|
||||
|
||||
fn to_str(vm: &Vm, val: JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// --- Symbol constructor ---
|
||||
|
||||
@@ -204,6 +204,10 @@ fn function_default_prototype_accepts_member_assignment() {
|
||||
"function Test262Error(message) { this.message = message || ''; } Test262Error.prototype.toString = function () { return this.message; }; new Test262Error('ok').toString()",
|
||||
)
|
||||
.unwrap();
|
||||
let rendered = vm.kernel_core().string_forge().lookup(result.as_string_index()).unwrap_or_default();
|
||||
let rendered = vm
|
||||
.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(result.as_string_index())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(rendered, "ok");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ fn eval(vm: &mut Vm, source: &str) -> Result<JsValue, String> {
|
||||
}
|
||||
|
||||
fn string_value(vm: &Vm, val: JsValue) -> String {
|
||||
vm.kernel_core().string_forge().lookup(val.as_string_index()).unwrap_or_default()
|
||||
vm.kernel_core()
|
||||
.string_forge()
|
||||
.lookup(val.as_string_index())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// -- JSON.parse --
|
||||
|
||||
Reference in New Issue
Block a user