mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Code clean up
This commit is contained in:
@@ -706,6 +706,7 @@ static int nativeSin(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
|
||||
|
||||
//cleanup
|
||||
Toy_freeLiteral(resultLiteral);
|
||||
Toy_freeLiteral(valueLiteral);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -741,9 +742,9 @@ static int nativeCos(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
|
||||
float power = value;
|
||||
int sign = 1;
|
||||
|
||||
for (int n = 1; n <= 10; n += 2) {
|
||||
result += sign * power / n;
|
||||
power = power * value * value;
|
||||
for (int n = 0; n <= 10; n += 2) {
|
||||
result += sign * power;
|
||||
power = power * value * value / ((n + 1) * (n + 2));
|
||||
sign = -sign;
|
||||
}
|
||||
|
||||
@@ -753,6 +754,7 @@ static int nativeCos(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments)
|
||||
|
||||
//cleanup
|
||||
Toy_freeLiteral(resultLiteral);
|
||||
Toy_freeLiteral(valueLiteral);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ import standard;
|
||||
assert clamp(0.0, 1.0, 5.0) == 1, "clamp(0.0, 1.0, 5.0) failed";
|
||||
assert clamp(10.0, 1.0, 5.0) == 5, "clamp(10.0, 1.0, 5.0) failed";
|
||||
|
||||
// assert typeof clamp(10, 1, 5) == int, "typeof clamp(10, 1, 5) == int failed";
|
||||
// assert typeof clamp(10.0, 1, 5) == int, "typeof clamp(10.0, 1, 5) == int failed";
|
||||
assert typeof clamp(10, 1, 5) == int, "typeof clamp(10, 1, 5) == int failed";
|
||||
assert typeof clamp(10.0, 1, 5) == int, "typeof clamp(10.0, 1, 5) == int failed";
|
||||
assert typeof clamp(10, 1, 5.0) == float, "typeof clamp(10, 1, 5.0) == float failed";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user