From c819a36db68d5f028dbed683723db4c9167478ce Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sat, 24 Aug 2024 09:34:32 +0900 Subject: [PATCH] fix index of str.ends_with --- src/interpreter/primitive_props.rs | 6 +++--- tests/test.rs | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/interpreter/primitive_props.rs b/src/interpreter/primitive_props.rs index 560440d..0bb0028 100644 --- a/src/interpreter/primitive_props.rs +++ b/src/interpreter/primitive_props.rs @@ -277,14 +277,14 @@ pub fn get_prim_prop(target: Value, name: String) -> Result= 0 { - target_len - raw_index + raw_index } else { - -raw_index + target_len + raw_index } as usize; Ok(Value::bool( diff --git a/tests/test.rs b/tests/test.rs index 54a7d49..2a1c0b7 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -3964,9 +3964,9 @@ mod primitive_props { let str = "hello" let empty = "" <: [ - // str.ends_with("", 3), str.ends_with("lo", 5), - // str.ends_with("ll", 4), str.ends_with("he", 2), - // str.ends_with("ll", -1), str.ends_with("he", -3), + str.ends_with("", 3), str.ends_with("lo", 5), + str.ends_with("ll", 4), str.ends_with("he", 2), + str.ends_with("ll", -1), str.ends_with("he", -3), str.ends_with("he", 5), str.ends_with("lo", 3), str.ends_with("lo", -6), str.ends_with("", -7), str.ends_with("lo", 6), str.ends_with("", 7), @@ -3977,12 +3977,12 @@ mod primitive_props { assert_eq!( res, arr([ - // bool(true), - // bool(true), - // bool(true), - // bool(true), - // bool(true), - // bool(true), + bool(true), + bool(true), + bool(true), + bool(true), + bool(true), + bool(true), bool(false), bool(false), bool(false),