diff --git a/test_array_methods.nyash b/test_array_methods.nyash new file mode 100644 index 00000000..067bf212 --- /dev/null +++ b/test_array_methods.nyash @@ -0,0 +1,65 @@ +// test_array_methods.nyash - ArrayBox改良テスト +// Phase 1: ArrayBox sort(), reverse(), indexOf(), slice() validation + +print("🗂️ Testing ArrayBox improvements...") + +// Create and populate array +local arr +arr = new ArrayBox() +arr.push(3) +arr.push(1) +arr.push(2) + +print("Original: " + arr.toString()) + +// Test sort() method +arr.sort() +print("Sorted: " + arr.toString()) + +// Test reverse() method +arr.reverse() +print("Reversed: " + arr.toString()) + +// Test indexOf() method +local index +index = arr.indexOf(2) +print("Index of 2: " + index.toString()) + +index = arr.indexOf(1) +print("Index of 1: " + index.toString()) + +index = arr.indexOf(99) +print("Index of 99: " + index.toString()) + +// Test slice() method +local slice +slice = arr.slice(0, 2) +print("Slice [0,2): " + slice.toString()) + +slice = arr.slice(1, 3) +print("Slice [1,3): " + slice.toString()) + +// Test with string array +local strArr +strArr = new ArrayBox() +strArr.push("zebra") +strArr.push("apple") +strArr.push("banana") + +print("String array original: " + strArr.toString()) + +strArr.sort() +print("String array sorted: " + strArr.toString()) + +strArr.reverse() +print("String array reversed: " + strArr.toString()) + +// Test indexOf on strings +index = strArr.indexOf("apple") +print("Index of 'apple': " + index.toString()) + +// Test slice on strings +slice = strArr.slice(0, 2) +print("String slice [0,2): " + slice.toString()) + +print("✅ ArrayBox improvements Phase 1 tests completed!") \ No newline at end of file diff --git a/test_cross_type_operators.nyash b/test_cross_type_operators.nyash new file mode 100644 index 00000000..0951eeb5 --- /dev/null +++ b/test_cross_type_operators.nyash @@ -0,0 +1,115 @@ +// test_cross_type_operators.nyash - 演算子システム強化テスト +// Phase 1: Cross-type operations, string concatenation, comparisons validation + +print("🔢 Testing cross-type operators implementation...") + +// Test 1: IntegerBox + FloatBox +print("=== Type Conversion Tests ===") +local i, f, result +i = 10 +f = new FloatBox(3.14) +result = i + f +print("10 + 3.14 = " + result.toString()) + +result = f + i +print("3.14 + 10 = " + result.toString()) + +// Test multiplication +result = i * f +print("10 * 3.14 = " + result.toString()) + +result = f * i +print("3.14 * 10 = " + result.toString()) + +// Test division +result = i / f +print("10 / 3.14 = " + result.toString()) + +result = f / i +print("3.14 / 10 = " + result.toString()) + +// Test subtraction +result = i - f +print("10 - 3.14 = " + result.toString()) + +result = f - i +print("3.14 - 10 = " + result.toString()) + +// Test 2: String concatenation with numbers +print("\n=== String Concatenation Tests ===") +local text, num, boolVal +text = "Value: " +num = 42 +boolVal = true + +result = text + num +print("\"Value: \" + 42 = " + result) + +result = text + f +print("\"Value: \" + 3.14 = " + result) + +result = text + boolVal +print("\"Value: \" + true = " + result) + +// Reverse concatenation +result = num + " items" +print("42 + \" items\" = " + result) + +// Test 3: Cross-type comparisons +print("\n=== Cross-Type Comparison Tests ===") +local comparison + +comparison = f > i +print("3.14 > 10: " + comparison.toString()) + +comparison = i > f +print("10 > 3.14: " + comparison.toString()) + +comparison = f < i +print("3.14 < 10: " + comparison.toString()) + +comparison = i < f +print("10 < 3.14: " + comparison.toString()) + +comparison = f >= i +print("3.14 >= 10: " + comparison.toString()) + +comparison = i <= f +print("10 <= 3.14: " + comparison.toString()) + +comparison = f == i +print("3.14 == 10: " + comparison.toString()) + +comparison = f != i +print("3.14 != 10: " + comparison.toString()) + +// Test 4: Complex expressions +print("\n=== Complex Expression Tests ===") +local complex + +complex = (i + f) > 12 +print("(10 + 3.14) > 12: " + complex.toString()) + +complex = (f * 2) < (i - 3) +print("(3.14 * 2) < (10 - 3): " + complex.toString()) + +complex = (i > 5) and (f > 3) +print("(10 > 5) and (3.14 > 3): " + complex.toString()) + +complex = (i < 5) or (f > 3) +print("(10 < 5) or (3.14 > 3): " + complex.toString()) + +// Test 5: Number to string auto-conversion in concatenation +print("\n=== Auto-Conversion Tests ===") +local auto1, auto2, auto3 + +auto1 = "Result: " + (i + f) +print("\"Result: \" + (10 + 3.14) = " + auto1) + +auto2 = "Boolean: " + (i > f) +print("\"Boolean: \" + (10 > 3.14) = " + auto2) + +auto3 = "Math: " + (f * f) +print("\"Math: \" + (3.14 * 3.14) = " + auto3) + +print("\n✅ Cross-type operators Phase 1 tests completed!") \ No newline at end of file diff --git a/test_datetime_tostring.nyash b/test_datetime_tostring.nyash new file mode 100644 index 00000000..db746198 --- /dev/null +++ b/test_datetime_tostring.nyash @@ -0,0 +1,4 @@ +// test_datetime_tostring.nyash - DateTimeBox toString() test as mentioned in issue +local dt +dt = new DateTimeBox() +print(dt.toString()) \ No newline at end of file diff --git a/test_float_tostring.nyash b/test_float_tostring.nyash new file mode 100644 index 00000000..e6c596c1 --- /dev/null +++ b/test_float_tostring.nyash @@ -0,0 +1,4 @@ +// test_float_tostring.nyash - FloatBox toString() test as mentioned in issue +local f1 +f1 = new FloatBox(3.14) +print(f1.toString()) \ No newline at end of file