From: mike lowis Date: Sat, 10 Apr 2021 00:36:05 +0000 (-0400) Subject: ABS to Abs X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=8bf90b0105632b4adca3667eb9d19d25178a8ce4;p=proto%2Fobnc.git ABS to Abs --- diff --git a/lib/obnc/FilesTest.obn b/lib/obnc/FilesTest.obn index 2388e2c..65e0a75 100644 --- a/lib/obnc/FilesTest.obn +++ b/lib/obnc/FilesTest.obn @@ -272,10 +272,10 @@ module FilesTest; Files.SetPos(r, f, 0); Files.ReadReal(r, x); Assert(~r.eof); - Assert(ABS(x - 3.14) < 1.0E-6); + Assert(Abs(x - 3.14) < 1.0E-6); Files.ReadReal(r, x); Assert(~r.eof); - Assert(ABS(x - (-3.14)) < 1.0E-6); + Assert(Abs(x - (-3.14)) < 1.0E-6); Files.ReadReal(r, x); Assert(r.eof) end TestReadWriteReal; diff --git a/lib/obnc/MathTest.obn b/lib/obnc/MathTest.obn index d192ffd..3058518 100644 --- a/lib/obnc/MathTest.obn +++ b/lib/obnc/MathTest.obn @@ -23,72 +23,72 @@ module MathTest; eps = 0.01; begin - Assert(ABS(Math.sqrt(1.0) - 1.0) < eps); - Assert(ABS(Math.sqrt(4.0) - 2.0) < eps); + Assert(Abs(Math.sqrt(1.0) - 1.0) < eps); + Assert(Abs(Math.sqrt(4.0) - 2.0) < eps); - Assert(ABS(Math.power(0.0, 1.0) - 0.0) < eps); - Assert(ABS(Math.power(1.0, 0.0) - 1.0) < eps); - Assert(ABS(Math.power(2.0, 3.0) - 8.0) < eps); - Assert(ABS(Math.power(2.0, -3.0) - 1.0 / 8.0) < eps); + Assert(Abs(Math.power(0.0, 1.0) - 0.0) < eps); + Assert(Abs(Math.power(1.0, 0.0) - 1.0) < eps); + Assert(Abs(Math.power(2.0, 3.0) - 8.0) < eps); + Assert(Abs(Math.power(2.0, -3.0) - 1.0 / 8.0) < eps); - Assert(ABS(Math.exp(0.0) - 1.0) < eps); - Assert(ABS(Math.exp(1.0) - Math.e) < eps); - Assert(ABS(Math.exp(2.0) - Math.e * Math.e) < eps); - Assert(ABS(Math.exp(-2.0) - 1.0 / Math.e / Math.e) < eps); + Assert(Abs(Math.exp(0.0) - 1.0) < eps); + Assert(Abs(Math.exp(1.0) - Math.e) < eps); + Assert(Abs(Math.exp(2.0) - Math.e * Math.e) < eps); + Assert(Abs(Math.exp(-2.0) - 1.0 / Math.e / Math.e) < eps); - Assert(ABS(Math.ln(1.0) - 0.0) < eps); - Assert(ABS(Math.ln(Math.e) - 1.0) < eps); - Assert(ABS(Math.ln(Math.e * Math.e) - 2.0) < eps); + Assert(Abs(Math.ln(1.0) - 0.0) < eps); + Assert(Abs(Math.ln(Math.e) - 1.0) < eps); + Assert(Abs(Math.ln(Math.e * Math.e) - 2.0) < eps); - Assert(ABS(Math.log(1.0, 2.0) - 0.0) < eps); - Assert(ABS(Math.log(Math.e, Math.e) - 1.0) < eps); - Assert(ABS(Math.log(100.0, 10.0) - 2.0) < eps); + Assert(Abs(Math.log(1.0, 2.0) - 0.0) < eps); + Assert(Abs(Math.log(Math.e, Math.e) - 1.0) < eps); + Assert(Abs(Math.log(100.0, 10.0) - 2.0) < eps); - Assert(ABS(Math.round(0.4) - 0.0) < eps); - Assert(ABS(Math.round(-0.4) - 0.0) < eps); - Assert(ABS(Math.round(0.6) - 1.0) < eps); - Assert(ABS(Math.round(-0.6) - (-1.0)) < eps); + Assert(Abs(Math.round(0.4) - 0.0) < eps); + Assert(Abs(Math.round(-0.4) - 0.0) < eps); + Assert(Abs(Math.round(0.6) - 1.0) < eps); + Assert(Abs(Math.round(-0.6) - (-1.0)) < eps); - Assert(ABS(Math.sin(0.0) - 0.0) < eps); - Assert(ABS(Math.sin(Math.pi / 6.0) - 0.5) < eps); - Assert(ABS(Math.sin(Math.pi / 2.0) - 1.0) < eps); + Assert(Abs(Math.sin(0.0) - 0.0) < eps); + Assert(Abs(Math.sin(Math.pi / 6.0) - 0.5) < eps); + Assert(Abs(Math.sin(Math.pi / 2.0) - 1.0) < eps); - Assert(ABS(Math.cos(0.0) - 1.0) < eps); - Assert(ABS(Math.cos(Math.pi / 3.0) - 0.5) < eps); - Assert(ABS(Math.cos(Math.pi / 2.0) - 0.0) < eps); + Assert(Abs(Math.cos(0.0) - 1.0) < eps); + Assert(Abs(Math.cos(Math.pi / 3.0) - 0.5) < eps); + Assert(Abs(Math.cos(Math.pi / 2.0) - 0.0) < eps); - Assert(ABS(Math.tan(0.0) - 0.0) < eps); - Assert(ABS(Math.tan(Math.pi / 4.0) - 1.0) < eps); + Assert(Abs(Math.tan(0.0) - 0.0) < eps); + Assert(Abs(Math.tan(Math.pi / 4.0) - 1.0) < eps); - Assert(ABS(Math.arcsin(0.0) - 0.0) < eps); - Assert(ABS(Math.arcsin(0.5) - Math.pi / 6.0) < eps); - Assert(ABS(Math.arcsin(1.0) - Math.pi / 2.0) < eps); + Assert(Abs(Math.arcsin(0.0) - 0.0) < eps); + Assert(Abs(Math.arcsin(0.5) - Math.pi / 6.0) < eps); + Assert(Abs(Math.arcsin(1.0) - Math.pi / 2.0) < eps); - Assert(ABS(Math.arccos(1.0) - 0.0) < eps); - Assert(ABS(Math.arccos(0.5) - Math.pi / 3.0) < eps); - Assert(ABS(Math.arccos(0.0) - Math.pi / 2.0) < eps); + Assert(Abs(Math.arccos(1.0) - 0.0) < eps); + Assert(Abs(Math.arccos(0.5) - Math.pi / 3.0) < eps); + Assert(Abs(Math.arccos(0.0) - Math.pi / 2.0) < eps); - Assert(ABS(Math.arctan(0.0) - 0.0) < eps); - Assert(ABS(Math.arctan(1.0) - Math.pi / 4.0) < eps); + Assert(Abs(Math.arctan(0.0) - 0.0) < eps); + Assert(Abs(Math.arctan(1.0) - Math.pi / 4.0) < eps); - Assert(ABS(Math.arctan2(0.0, 2.0) - 0.0) < eps); - Assert(ABS(Math.arctan2(2.0, 2.0) - Math.pi / 4.0) < eps); + Assert(Abs(Math.arctan2(0.0, 2.0) - 0.0) < eps); + Assert(Abs(Math.arctan2(2.0, 2.0) - Math.pi / 4.0) < eps); - Assert(ABS(Math.sinh(0.0) - 0.0) < eps); - Assert(ABS(Math.sinh(1.0) - (Math.e - 1.0 / Math.e) / 2.0) < eps); + Assert(Abs(Math.sinh(0.0) - 0.0) < eps); + Assert(Abs(Math.sinh(1.0) - (Math.e - 1.0 / Math.e) / 2.0) < eps); - Assert(ABS(Math.cosh(0.0) - 1.0) < eps); - Assert(ABS(Math.cosh(1.0) - (Math.e + 1.0 / Math.e) / 2.0) < eps); + Assert(Abs(Math.cosh(0.0) - 1.0) < eps); + Assert(Abs(Math.cosh(1.0) - (Math.e + 1.0 / Math.e) / 2.0) < eps); - Assert(ABS(Math.tanh(0.0) - 0.0) < eps); - Assert(ABS(Math.tanh(1.0) - (Math.e - 1.0 / Math.e) / (Math.e + 1.0 / Math.e)) < eps); + Assert(Abs(Math.tanh(0.0) - 0.0) < eps); + Assert(Abs(Math.tanh(1.0) - (Math.e - 1.0 / Math.e) / (Math.e + 1.0 / Math.e)) < eps); - Assert(ABS(Math.arcsinh(0.0) - 0.0) < eps); - Assert(ABS(Math.arcsinh((Math.e - 1.0 / Math.e) / 2.0) - 1.0) < eps); + Assert(Abs(Math.arcsinh(0.0) - 0.0) < eps); + Assert(Abs(Math.arcsinh((Math.e - 1.0 / Math.e) / 2.0) - 1.0) < eps); - Assert(ABS(Math.arccosh(1.0) - 0.0) < eps); - Assert(ABS(Math.arccosh((Math.e + 1.0 / Math.e) / 2.0) - 1.0) < eps); + Assert(Abs(Math.arccosh(1.0) - 0.0) < eps); + Assert(Abs(Math.arccosh((Math.e + 1.0 / Math.e) / 2.0) - 1.0) < eps); - Assert(ABS(Math.arctanh(0.0) - 0.0) < eps); - Assert(ABS(Math.arctanh((Math.e - 1.0 / Math.e) / (Math.e + 1.0 / Math.e)) - 1.0) < eps) + Assert(Abs(Math.arctanh(0.0) - 0.0) < eps); + Assert(Abs(Math.arctanh((Math.e - 1.0 / Math.e) / (Math.e + 1.0 / Math.e)) - 1.0) < eps) end MathTest. diff --git a/src/Oberon.y b/src/Oberon.y index f917c26..9da65dc 100644 --- a/src/Oberon.y +++ b/src/Oberon.y @@ -3588,7 +3588,7 @@ static OBNC_INTEGER TypeSize(Trees_Node type) static Trees_Node PredeclaredProcedureAST(const char procName[], Trees_Node expList, int isFunctionCall) { static const struct { const char *name; int symbol; } symbols[] = { - {"ABS", TREES_ABS_PROC}, + {"Abs", TREES_ABS_PROC}, {"AsChar", TREES_CHR_PROC}, {"AsInt", TREES_ORD_PROC}, {"AsReal", TREES_FLT_PROC}, diff --git a/src/Table.c b/src/Table.c index d11e94c..a52d102 100644 --- a/src/Table.c +++ b/src/Table.c @@ -87,7 +87,7 @@ void Table_Init(void) */ static const struct { const char *name; int kind, type; } predecIdents[] = { - {"ABS", TREES_PROCEDURE_KIND, TREES_ABS_PROC}, /* Remove */ + {"Abs", TREES_PROCEDURE_KIND, TREES_ABS_PROC}, /* Remove */ {"AsChar", TREES_PROCEDURE_KIND, TREES_CHR_PROC}, {"AsInt", TREES_PROCEDURE_KIND, TREES_ORD_PROC}, {"AsReal", TREES_PROCEDURE_KIND, TREES_FLT_PROC}, diff --git a/src/y.tab.c b/src/y.tab.c index 2843ea3..eedbf54 100644 --- a/src/y.tab.c +++ b/src/y.tab.c @@ -5566,7 +5566,7 @@ static OBNC_INTEGER TypeSize(Trees_Node type) static Trees_Node PredeclaredProcedureAST(const char procName[], Trees_Node expList, int isFunctionCall) { static const struct { const char *name; int symbol; } symbols[] = { - {"ABS", TREES_ABS_PROC}, + {"Abs", TREES_ABS_PROC}, {"AsChar", TREES_CHR_PROC}, {"AsInt", TREES_ORD_PROC}, {"AsReal", TREES_FLT_PROC}, diff --git a/tests/obnc/passing/T4Expressions.obn b/tests/obnc/passing/T4Expressions.obn index b4835e8..cfd2d8e 100644 --- a/tests/obnc/passing/T4Expressions.obn +++ b/tests/obnc/passing/T4Expressions.obn @@ -54,7 +54,7 @@ module T4Expressions; Assert(A[1, 2] = A[1][2]); i := 0; j := 0; - A[0, 0] := ABS(A[IncReturnZero(i), IncReturnZero(j)]); + A[0, 0] := Abs(A[IncReturnZero(i), IncReturnZero(j)]); Assert(i = 1); Assert(j = 1); @@ -378,7 +378,7 @@ Out.Integer(AsInt({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln; procedure TestPredeclaredFunctionProcedures; const eps = 0.01; (*make sure function procedures with constant parameters are constant expressions*) - absConst = ABS(0); + absConst = Abs(0); floorConst = Floor(eps); fltConst = AsReal(0); ordConst = AsInt(true); @@ -392,14 +392,14 @@ Out.Integer(AsInt({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln; x: Byte; s: Set; begin - Assert(ABS(-1) = 1); - Assert(ABS(0) = 0); - Assert(ABS(1) = 1); - Assert(ABS(-1.0) = 1.0); - Assert(ABS(0.0) = 0.0); - Assert(ABS(1.0) = 1.0); + Assert(Abs(-1) = 1); + Assert(Abs(0) = 0); + Assert(Abs(1) = 1); + Assert(Abs(-1.0) = 1.0); + Assert(Abs(0.0) = 0.0); + Assert(Abs(1.0) = 1.0); i := 0; - j := ABS(IncReturnZero(i) - 1); + j := Abs(IncReturnZero(i) - 1); Assert(j = 1); Assert(i = 1); diff --git a/tests/obnc/passing/T5Statements.obn b/tests/obnc/passing/T5Statements.obn index 7c99899..510a632 100644 --- a/tests/obnc/passing/T5Statements.obn +++ b/tests/obnc/passing/T5Statements.obn @@ -159,7 +159,7 @@ module T5Statements; s.y := 0.0; r.x := 0.0; P(c); - Assert(ABS(c.r - 1.0) < eps); + Assert(Abs(c.r - 1.0) < eps); r.x := 1.0; s := r; diff --git a/tests/obnc/passing/T7Modules.obn b/tests/obnc/passing/T7Modules.obn index d780e15..af82bb2 100644 --- a/tests/obnc/passing/T7Modules.obn +++ b/tests/obnc/passing/T7Modules.obn @@ -57,7 +57,7 @@ begin Assert(A.boolVar = A.boolConst); Assert(A.charVar = A.charConst); Assert(A.intVar = A.intConst); - Assert(ABS(A.realVar - A.realConst) < 1.0E-6); + Assert(Abs(A.realVar - A.realConst) < 1.0E-6); Assert(A.strVar = A.strConst); Assert(A.setVar = A.setConst); Assert(A.recVar.f = 1);