add num
This commit is contained in:
32
tests/num_setter_test.ce
Normal file
32
tests/num_setter_test.ce
Normal file
@@ -0,0 +1,32 @@
|
||||
// Test setter functionality for num.Array
|
||||
var num = use('num');
|
||||
|
||||
// Create an array
|
||||
var arr = new num.Array([1, 2, 3, 4, 5]);
|
||||
|
||||
log.console("Original values:");
|
||||
log.console("arr[0] =", arr[0], "arr[1] =", arr[1], "arr[2] =", arr[2]);
|
||||
|
||||
// Test setting values
|
||||
arr[0] = 100;
|
||||
arr[1] = 200;
|
||||
arr[2] = 300.5;
|
||||
|
||||
log.console("After setting:");
|
||||
log.console("arr[0] =", arr[0], "arr[1] =", arr[1], "arr[2] =", arr[2]);
|
||||
|
||||
// Test setting with different types
|
||||
arr[3] = "123.7"; // Should convert string to number
|
||||
arr[4] = true; // Should convert boolean to number
|
||||
|
||||
log.console("After type conversion:");
|
||||
log.console("arr[3] =", arr[3], "(from string)");
|
||||
log.console("arr[4] =", arr[4], "(from boolean)");
|
||||
|
||||
// Test bounds checking - this should fail silently
|
||||
arr[10] = 999;
|
||||
log.console("arr[10] after out-of-bounds set =", arr[10]);
|
||||
|
||||
log.console("Final array:", arr.toArray());
|
||||
|
||||
$_.stop();
|
||||
Reference in New Issue
Block a user