Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
StavromulaBeta committed Aug 27, 2024
2 parents b06405c + fdad033 commit 6e160aa
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
{.name="floor", .calltype=call, .argc=1, .args={number}, .returns=true, .rettype=number},
{.name="round", .calltype=call, .argc=1, .args={number}, .returns=true, .rettype=number},
{.name="ceiling", .calltype=call, .argc=1, .args={number}, .returns=true, .rettype=number},
{.name="abs", .calltype=call, .argc=1, .args={number}, .returns=true, .rettype=number},
{.name="error", .calltype=call, .argc=1, .args={string}},
{.name="list", .calltype=call, .argc=1, .args={block}, .returns=true, .rettype=list},
{.name="number", .calltype=call, .argc=1, .args={string}, .returns=true, .rettype=number},
Expand Down
12 changes: 9 additions & 3 deletions src/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ static STRING ___character(NUMBER);
static NUMBER ___floor(NUMBER);
static NUMBER ___round(NUMBER);
static NUMBER ___ceiling(NUMBER);
static NUMBER ___abs(NUMBER);
static void ___error(STRING);
//static BLOCK ___precompute(BLOCK);
static void ___wait(NUMBER);
Expand Down Expand Up @@ -1564,6 +1565,11 @@ static NUMBER ___ceiling(NUMBER a)
return ceil(a);
}

static NUMBER ___abs(NUMBER a)
{
return fabs(a);
}

static void ___error(STRING str)
{
throw_error(str);
Expand Down Expand Up @@ -1839,17 +1845,17 @@ static NUMBER ___atan(NUMBER a)

static NUMBER ___sinhd(NUMBER a)
{
return radians_to_degrees(sinh(a));
return sinh(degrees_to_radians(a));
}

static NUMBER ___coshd(NUMBER a)
{
return radians_to_degrees(cosh(a));
return cosh(degrees_to_radians(a));
}

static NUMBER ___tanhd(NUMBER a)
{
return radians_to_degrees(tanh(a));
return tanh(degrees_to_radians(a));
}

static NUMBER ___sinh(NUMBER a)
Expand Down
14 changes: 14 additions & 0 deletions tests/begin.cog
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Let reached UnreachableCode Box False;
Let reached ReachableCode Box False;

Begin (
Def Exit;
Set reached ReachableCode to True;
Exit;
Set reached UnreachableCode to True;
);

Print If And reached Unbox ReachableCode and Not reached Unbox UnreachableCode
"PASS: Begin"
else
"FAIL: Begin";
5 changes: 5 additions & 0 deletions tests/maths.cog
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Print If == 5 Round 4.7
else
"FAIL: Round";

Print If And == 5 Abs -5 == 2.17 Abs Abs -2.17
"PASS: Abs"
else
"FAIL: Abs";

Print If == 0.3 + 0.1 0.2
"PASS: Floating point error"
else
Expand Down
12 changes: 6 additions & 6 deletions tests/trig.cog
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,32 @@ Print If == 10 Tan Atan 10
else
"FAIL: Radian arctan";

Print If == 0 Sinhd 0
Print If == 0.17542037193601015 Sinhd 10
"PASS: Degree hyperbolic sin"
else
"FAIL: Degree hyperbolic sin";

Print If == 88.412007823281300034068408422172 Coshd 1
Print If == 1.0001523125762564 Coshd 1
"PASS: Degree hyperbolic cos"
else
"FAIL: Degree hyperbolic cos";

Print If == 0 Tanhd 0
Print If == 0.17278206351636377 Tanhd 10
"PASS: Degree hyperbolic tan"
else
"FAIL: Degree hyperbolic tan";

Print If == 0 Sinh 0
Print If == 74.20321057778875 Sinh 5
"PASS: Radian hyperbolic sin"
else
"FAIL: Radian hyperbolic sin";

Print If == 1 Cosh 0
Print If == 74.20994852478785 Cosh 5
"PASS: Radian hyperbolic cos"
else
"FAIL: Radian hyperbolic cos";

Print If == 0 Tanh 0
Print If == Tanh 8 / Cosh 8 Sinh 8
"PASS: Radian hyperbolic tan"
else
"FAIL: Radian hyperbolic tan";

0 comments on commit 6e160aa

Please sign in to comment.