Blob Blame History Raw
From 1d4b227e21a4563e2b0526413783c603acd01f8c Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Tue, 24 Jul 2018 01:35:02 -0400
Subject: [PATCH 4/5] Increase tolerances to work on all arches.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 tests/testthat/test_layout.kk.R | 34 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/tests/testthat/test_layout.kk.R b/tests/testthat/test_layout.kk.R
index 51c915b..cfb77fb 100644
--- a/tests/testthat/test_layout.kk.R
+++ b/tests/testthat/test_layout.kk.R
@@ -9,24 +9,20 @@ test_that("Kamada-Kawai layout generator works", {
   l <- layout_with_kk(g, maxiter=50)
   if (Sys.info()["sysname"] == "Darwin") {
     expect_that(sum(l), equals(-1.13071769106689))
-  } else if (Sys.info()["sysname"] == "Linux" &&
-             Sys.info()["machine"] == "x86_64") {
-    expect_that(sum(l), equals(-6.77278645472984e-05))
-  } else if (Sys.info()["sysname"] == "Linux" &&
-             Sys.info()["machine"] == "i686") {
-    expect_that(sum(l), equals(0.914809637353466))
+  } else if (Sys.info()["sysname"] == "Linux") {
+    if (Sys.info()["machine"] %in% c("aarch64", "i686", "ppc64", "ppc64le", "s390x")) {
+      expect_that(sum(l), equals(0.914809637353466))
+    } else {
+      expect_that(sum(l), equals(-6.77278645472984e-05))
+    }
   }
 
   g <- make_star(30)
   l <- layout_with_kk(g, maxiter=500)
   if (Sys.info()["sysname"] == "Darwin") {
     expect_that(sum(l), equals(-85.6883999492408))
-  } else if (Sys.info()["sysname"] == "Linux" &&
-             Sys.info()["machine"] == "x86_64") {
-    expect_that(sum(l), equals(-86.1405864709501))
-  } else if (Sys.info()["sysname"] == "Linux" &&
-             Sys.info()["machine"] == "i686") {
-    expect_that(sum(l), equals(-85.142223229617))
+  } else if (Sys.info()["sysname"] == "Linux") {
+    expect_that(sum(l), equals(-84.8, tolerance = 0.1))
   }
 
   g <- make_ring(10)
@@ -34,12 +30,14 @@ test_that("Kamada-Kawai layout generator works", {
   l <- layout_with_kk(g, maxiter=500)
   if (Sys.info()["sysname"] == "Darwin") {
     expect_that(sum(l), equals(1.61069099387368))
-  } else if (Sys.info()["sysname"] == "Linux" &&
-             Sys.info()["machine"] == "x86_64") {
-    expect_that(sum(l), equals(-1.83036635516248))
-  } else if (Sys.info()["sysname"] == "Linux" &&
-             Sys.info()["machine"] == "i686") {
-    expect_that(sum(l), equals(0.0631144692360025))
+  } else if (Sys.info()["sysname"] == "Linux") {
+    if (Sys.info()["machine"] %in% c("aarch64", "ppc64", "ppc64le", "s390x")) {
+      expect_that(sum(l), equals(1.54, tolerance = 0.01))
+    } else if (Sys.info()["machine"] == "i686") {
+      expect_that(sum(l), equals(0.0631144692360025))
+    } else {
+      expect_that(sum(l), equals(-1.83036635516248))
+    }
   }
   
 })
-- 
2.20.1