[Xfce4-commits] [panel-plugins/xfce4-calculator-plugin] 04/08: Bug 12548: Added more tests.
noreply at xfce.org
noreply at xfce.org
Mon Jun 20 22:27:48 CEST 2016
This is an automated email from the git hooks/post-receive script.
roland pushed a commit to branch master
in repository panel-plugins/xfce4-calculator-plugin.
commit 9178e18c06cbdf15422a71c0f5ba6831503fae66
Author: Roland Kuebert <roland.kuebert at gmail.com>
Date: Mon Jun 20 22:14:06 2016 +0200
Bug 12548: Added more tests.
Thanks to Wim Hueskes <xfce at wimhueskes.eu>.
---
tests/Makefile.am | 22 ++++++++++++++++++++++
tests/test-abs.awk | 15 +++++++++++++++
tests/test-acos.awk | 15 +++++++++++++++
tests/test-asin.awk | 15 +++++++++++++++
tests/test-atan.awk | 15 +++++++++++++++
tests/test-cos.awk | 15 +++++++++++++++
tests/test-cube-root.awk | 15 +++++++++++++++
tests/test-div-zero-negative.awk | 11 +++++++++++
tests/test-div-zero-zero.awk | 11 +++++++++++
tests/test-div-zero.awk | 11 +++++++++++
tests/test-e-notation.awk | 15 +++++++++++++++
tests/test-exp.awk | 15 +++++++++++++++
tests/test-func.awk | 15 ---------------
tests/test-hex.awk | 15 +++++++++++++++
tests/test-log.awk | 15 +++++++++++++++
tests/test-log10-negative.awk | 11 +++++++++++
tests/test-log10-zero.awk | 11 +++++++++++
tests/test-log10.awk | 15 +++++++++++++++
tests/test-log2.awk | 15 +++++++++++++++
tests/test-pi.awk | 15 +++++++++++++++
tests/test-sin.awk | 15 +++++++++++++++
tests/test-sqrt-minus-one.awk | 11 +++++++++++
tests/test-sqrt.awk | 15 +++++++++++++++
tests/test-tan.awk | 15 +++++++++++++++
24 files changed, 328 insertions(+), 15 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0c3bd33..1b74a74 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,28 @@ EXTRA_DIST = \
TESTS = \
test-simple-expr.awk \
test-minus.awk \
+ test-e-notation.awk \
+ test-abs.awk \
+ test-sqrt.awk \
+ test-sqrt-minus-one.awk \
+ test-hex.awk \
+ test-cube-root.awk \
+ test-log10.awk \
+ test-log10-zero.awk \
+ test-log10-negative.awk \
+ test-log.awk \
+ test-log2.awk \
+ test-exp.awk \
+ test-div-zero.awk \
+ test-div-zero-negative.awk \
+ test-div-zero-zero.awk \
+ test-pi.awk \
+ test-sin.awk \
+ test-cos.awk \
+ test-tan.awk \
+ test-asin.awk \
+ test-acos.awk \
+ test-atan.awk \
test-pow.awk
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/tests/test-abs.awk b/tests/test-abs.awk
new file mode 100755
index 0000000..f456f9f
--- /dev/null
+++ b/tests/test-abs.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'abs(0)+abs(-0.5)+abs(10)+abs(-300)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 310.5) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-acos.awk b/tests/test-acos.awk
new file mode 100755
index 0000000..70b12c5
--- /dev/null
+++ b/tests/test-acos.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'pi/acos(-1) + pi/arccos(-1)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 2) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-asin.awk b/tests/test-asin.awk
new file mode 100755
index 0000000..232048f
--- /dev/null
+++ b/tests/test-asin.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'pi/asin(-1) + pi/arcsin(-1)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - -4) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-atan.awk b/tests/test-atan.awk
new file mode 100755
index 0000000..b45638b
--- /dev/null
+++ b/tests/test-atan.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'pi/atan(-sqrt(3)) + pi/arctan(-sqrt(3))'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - -6) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-cos.awk b/tests/test-cos.awk
new file mode 100755
index 0000000..413ba55
--- /dev/null
+++ b/tests/test-cos.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'cos(pi)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - -1) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-cube-root.awk b/tests/test-cube-root.awk
new file mode 100755
index 0000000..73e546f
--- /dev/null
+++ b/tests/test-cube-root.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'-cbrt(-8) + 10*cbrt(8) + 100*cbrt(0) + cbrt(0.729)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 22.9) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-div-zero-negative.awk b/tests/test-div-zero-negative.awk
new file mode 100755
index 0000000..6f43938
--- /dev/null
+++ b/tests/test-div-zero-negative.awk
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+
+BEGIN{
+ expr = "'-1/0'"
+ "../panel-plugin/calctest " expr | getline res
+ if (tolower(res) != "-inf") {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-div-zero-zero.awk b/tests/test-div-zero-zero.awk
new file mode 100755
index 0000000..4d685d5
--- /dev/null
+++ b/tests/test-div-zero-zero.awk
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+
+BEGIN{
+ expr = "'0/0'"
+ "../panel-plugin/calctest " expr | getline res
+ if ((tolower(res) != "nan") && (tolower(res) != "-nan")) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-div-zero.awk b/tests/test-div-zero.awk
new file mode 100755
index 0000000..1eeef07
--- /dev/null
+++ b/tests/test-div-zero.awk
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+
+BEGIN{
+ expr = "'1/0'"
+ "../panel-plugin/calctest " expr | getline res
+ if (tolower(res) != "inf") {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-e-notation.awk b/tests/test-e-notation.awk
new file mode 100755
index 0000000..67759bd
--- /dev/null
+++ b/tests/test-e-notation.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'3e3 + -2.3e+2 + 6e-2 + -2e-3 + 1e0 + 1e+0 + 1e-0'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 2773.058) > 1.0e-15) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-exp.awk b/tests/test-exp.awk
new file mode 100755
index 0000000..81e7204
--- /dev/null
+++ b/tests/test-exp.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'exp(0) + exp(1) + exp(0.2) + exp(5)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 153.3528436891958185) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-func.awk b/tests/test-func.awk
deleted file mode 100755
index 89f6424..0000000
--- a/tests/test-func.awk
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/awk -f
-
-function abs(x) {
- return (x < 0) ? -x : x
-}
-
-BEGIN{
- expr = "'sqrt(1) + log(1) + ln(1) + exp(1) + sin(1) + cos(1) + tan(1) + asin(1) + arcsin(1) + acos(1) + arccos(1) + atan(1) + arctan(1) + log2(1) + log10(1) + lg(1) + abs(1) + cbrt(1)'"
- "../panel-plugin/calctest " expr | getline res
- if (abs(res - 3.0) > 1.0e-15) {
- print res
- exit 1
- } else
- exit 0
-}
diff --git a/tests/test-hex.awk b/tests/test-hex.awk
new file mode 100755
index 0000000..7f24f3e
--- /dev/null
+++ b/tests/test-hex.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'0x0 + 0xabcdef + 0xFEDCBA - 0x7e9'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 27960000) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-log.awk b/tests/test-log.awk
new file mode 100755
index 0000000..983c060
--- /dev/null
+++ b/tests/test-log.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'log(2.71828182845904523536) + 100*ln(1) + log(5e-10) + ln(5e10)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 4.21887582486820074478057) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-log10-negative.awk b/tests/test-log10-negative.awk
new file mode 100755
index 0000000..74e3c58
--- /dev/null
+++ b/tests/test-log10-negative.awk
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+
+BEGIN{
+ expr = "'log10(-1)'"
+ "../panel-plugin/calctest " expr | getline res
+ if ((tolower(res) != "nan") && (tolower(res) != "-nan")) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-log10-zero.awk b/tests/test-log10-zero.awk
new file mode 100755
index 0000000..8d260b0
--- /dev/null
+++ b/tests/test-log10-zero.awk
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+
+BEGIN{
+ expr = "'log10(0)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (tolower(res) != "-inf") {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-log10.awk b/tests/test-log10.awk
new file mode 100755
index 0000000..f1cdadb
--- /dev/null
+++ b/tests/test-log10.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'log10(100000)+lg(1e20)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 25) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-log2.awk b/tests/test-log2.awk
new file mode 100755
index 0000000..b2a3a3e
--- /dev/null
+++ b/tests/test-log2.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'log2(2) + 100*log2(1) + log2(0.00390625) + log2(4294967296)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 25) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-pi.awk b/tests/test-pi.awk
new file mode 100755
index 0000000..23de0cc
--- /dev/null
+++ b/tests/test-pi.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'-pi'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - -3.1415926535897932) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-sin.awk b/tests/test-sin.awk
new file mode 100755
index 0000000..64def25
--- /dev/null
+++ b/tests/test-sin.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'sin(pi/2)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 1) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-sqrt-minus-one.awk b/tests/test-sqrt-minus-one.awk
new file mode 100755
index 0000000..5cb6ae9
--- /dev/null
+++ b/tests/test-sqrt-minus-one.awk
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+
+BEGIN{
+ expr = "'sqrt(-1)'"
+ "../panel-plugin/calctest " expr | getline res
+ if ((tolower(res) != "nan") && (tolower(res) != "-nan")) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-sqrt.awk b/tests/test-sqrt.awk
new file mode 100755
index 0000000..bb8fb81
--- /dev/null
+++ b/tests/test-sqrt.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'sqrt(0.0001524157875019052)+sqrt(75/3)+10*sqrt(1)+100*sqrt(0--0)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 15.0123456789) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
diff --git a/tests/test-tan.awk b/tests/test-tan.awk
new file mode 100755
index 0000000..36173cb
--- /dev/null
+++ b/tests/test-tan.awk
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+
+function abs(x) {
+ return (x < 0) ? -x : x
+}
+
+BEGIN{
+ expr = "'tan(pi/4)'"
+ "../panel-plugin/calctest " expr | getline res
+ if (abs(res - 1) > 1.0e-14) {
+ print res
+ exit 1
+ } else
+ exit 0
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list