From f6799e2ab1d2b619bbcb7d1e709f44c56e4e8818 Mon Sep 17 00:00:00 2001
From: "J. King" <jking@jkingweb.ca>
Date: Sun, 24 Apr 2022 12:25:37 -0400
Subject: [PATCH] Tests for date ranges in contexts

---
 lib/Context/ExclusionMembers.php   |   2 +-
 lib/Misc/ValueInfo.php             |  10 +-
 tests/cases/Db/BaseDriver.php      |   2 +
 tests/cases/Misc/TestContext.php   |  11 ++
 tests/cases/Misc/TestValueInfo.php | 166 ++++++++++++++---------------
 5 files changed, 104 insertions(+), 87 deletions(-)

diff --git a/lib/Context/ExclusionMembers.php b/lib/Context/ExclusionMembers.php
index 1efa53a3..62f2a403 100644
--- a/lib/Context/ExclusionMembers.php
+++ b/lib/Context/ExclusionMembers.php
@@ -79,7 +79,7 @@ trait ExclusionMembers {
                 }
             }
         }
-        return array_values(array_unique($spec));
+        return array_values(array_unique($spec, \SORT_REGULAR));
     }
 
     public function folder(int $spec = null) {
diff --git a/lib/Misc/ValueInfo.php b/lib/Misc/ValueInfo.php
index 0aba7700..8b31590b 100644
--- a/lib/Misc/ValueInfo.php
+++ b/lib/Misc/ValueInfo.php
@@ -281,15 +281,19 @@ class ValueInfo {
                             if (!$out) {
                                 throw new \Exception;
                             }
-                            return $out;
+                            return $out->setTimezone(new \DateTimeZone("UTC"));
                         } else {
-                            return new \DateTimeImmutable($value, new \DateTimeZone("UTC"));
+                            $out = new \DateTimeImmutable($value, new \DateTimeZone("UTC"));
+                            if ($out) {
+                                return $out->setTimezone(new \DateTimeZone("UTC"));
+                            } elseif ($strict && !$drop) {
+                                throw new \Exception;
+                            }
                         }
                     } catch (\Exception $e) {
                         if ($strict && !$drop) {
                             throw new ExceptionType("strictFailure", $type);
                         }
-                        return null;
                     }
                 } elseif ($strict && !$drop) {
                     throw new ExceptionType("strictFailure", $type);
diff --git a/tests/cases/Db/BaseDriver.php b/tests/cases/Db/BaseDriver.php
index 89a26007..fe7f344c 100644
--- a/tests/cases/Db/BaseDriver.php
+++ b/tests/cases/Db/BaseDriver.php
@@ -387,9 +387,11 @@ abstract class BaseDriver extends \JKingWeb\Arsse\Test\AbstractTest {
         $integer = $this->drv->sqlToken("InTEGer");
         $asc = $this->drv->sqlToken("asc");
         $desc = $this->drv->sqlToken("desc");
+        $least = $this->drv->sqlToken("leASt");
 
         $this->assertSame("NOT_A_TOKEN", $this->drv->sqlToken("NOT_A_TOKEN"));
 
+        $this->assertSame("A", $this->drv->query("SELECT $least('Z', 'A')")->getValue());
         $this->assertSame("Z", $this->drv->query("SELECT $greatest('Z', 'A')")->getValue());
         $this->assertSame("Z", $this->drv->query("SELECT 'Z' collate $nocase")->getValue());
         $this->assertSame("Z", $this->drv->query("SELECT 'Z' where 'Z' $like 'z'")->getValue());
diff --git a/tests/cases/Misc/TestContext.php b/tests/cases/Misc/TestContext.php
index 78bc11ea..1f8b6380 100644
--- a/tests/cases/Misc/TestContext.php
+++ b/tests/cases/Misc/TestContext.php
@@ -8,6 +8,7 @@ namespace JKingWeb\Arsse\TestCase\Misc;
 
 use JKingWeb\Arsse\Context\Context;
 use JKingWeb\Arsse\Context\ExclusionContext;
+use JKingWeb\Arsse\Misc\Date;
 use JKingWeb\Arsse\Misc\ValueInfo;
 
 /**
@@ -129,6 +130,16 @@ class TestContext extends \JKingWeb\Arsse\Test\AbstractTest {
         }
     }
 
+    public function testCleanDateRangeArrayValues(): void {
+        $methods = ["modifiedRanges", "markedRanges"];
+        $in = [null, 1, [1, 2, 3], [1], [null, null], ["ook", null], ["2022-09-13T06:46:28 America/Los_angeles", new \DateTime("2022-01-23T00:33:49Z")], [0, null], [null, 0]];
+        $out = [[Date::normalize("2022-09-13T13:46:28Z"), Date::normalize("2022-01-23T00:33:49Z")], [Date::normalize(0), null], [null, Date::normalize(0)]];
+        $c = new Context;
+        foreach ($methods as $method) {
+            $this->assertEquals($out, $c->$method($in)->$method, "Context method $method did not return the expected results");
+        }
+    }
+
     public function testCloneAContext(): void {
         $c1 = new Context;
         $c2 = clone $c1;
diff --git a/tests/cases/Misc/TestValueInfo.php b/tests/cases/Misc/TestValueInfo.php
index 7b30e117..e17be633 100644
--- a/tests/cases/Misc/TestValueInfo.php
+++ b/tests/cases/Misc/TestValueInfo.php
@@ -349,7 +349,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
             // if we're performing a strict comparison and the value is supposed to fail, we should be getting an exception
             $this->assertException("strictFailure", "", "ExceptionType");
             I::normalize($input, $typeConst | $modeConst);
-            $this->assertTrue(false, "$typename $modeName test expected exception");
+            $this->assertTrue(false, "$typeName $modeName test expected exception");
         } elseif ($drop && !$pass) {
             // if we're performing a drop comparison and the value is supposed to fail, change the expectation to null
             $exp = null;
@@ -451,88 +451,88 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
                For each of these types, there is an expected output value, as well as a boolean indicating whether
                the value should pass or fail a strict normalization. Conversion to DateTime is covered below by a different data set
             */
-            /* Input value                          null         bool           int                      float                        string                          array                                            interval                   */
-            [null,                                  [null,true], [false,false], [0,              false], [0.0,                false], ["",                    false], [[],                                     false], [null, false]],
-            ["",                                    [null,true], [false,true],  [0,              false], [0.0,                false], ["",                    true],  [[""],                                   false], [null, false]],
-            [1,                                     [null,true], [true, true],  [1,              true],  [1.0,                true],  ["1",                   true],  [[1],                                    false], [$this->i("PT1S"), false]],
-            [PHP_INT_MAX,                           [null,true], [true, false], [PHP_INT_MAX,    true],  [(float) PHP_INT_MAX,true],  [(string) PHP_INT_MAX,  true],  [[PHP_INT_MAX],                          false], [$this->i("P292471208677Y195DT15H30M7S"), false]],
-            [1.0,                                   [null,true], [true, true],  [1,              true],  [1.0,                true],  ["1",                   true],  [[1.0],                                  false], [$this->i("PT1S"), false]],
-            ["1.0",                                 [null,true], [true, true],  [1,              true],  [1.0,                true],  ["1.0",                 true],  [["1.0"],                                false], [null, false]],
-            ["001.0",                               [null,true], [true, true],  [1,              true],  [1.0,                true],  ["001.0",               true],  [["001.0"],                              false], [null, false]],
-            ["1.0e2",                               [null,true], [true, false], [100,            true],  [100.0,              true],  ["1.0e2",               true],  [["1.0e2"],                              false], [null, false]],
-            ["1",                                   [null,true], [true, true],  [1,              true],  [1.0,                true],  ["1",                   true],  [["1"],                                  false], [null, false]],
-            ["001",                                 [null,true], [true, true],  [1,              true],  [1.0,                true],  ["001",                 true],  [["001"],                                false], [null, false]],
-            ["1e2",                                 [null,true], [true, false], [100,            true],  [100.0,              true],  ["1e2",                 true],  [["1e2"],                                false], [null, false]],
-            ["+1.0",                                [null,true], [true, true],  [1,              true],  [1.0,                true],  ["+1.0",                true],  [["+1.0"],                               false], [null, false]],
-            ["+001.0",                              [null,true], [true, true],  [1,              true],  [1.0,                true],  ["+001.0",              true],  [["+001.0"],                             false], [null, false]],
-            ["+1.0e2",                              [null,true], [true, false], [100,            true],  [100.0,              true],  ["+1.0e2",              true],  [["+1.0e2"],                             false], [null, false]],
-            ["+1",                                  [null,true], [true, true],  [1,              true],  [1.0,                true],  ["+1",                  true],  [["+1"],                                 false], [null, false]],
-            ["+001",                                [null,true], [true, true],  [1,              true],  [1.0,                true],  ["+001",                true],  [["+001"],                               false], [null, false]],
-            ["+1e2",                                [null,true], [true, false], [100,            true],  [100.0,              true],  ["+1e2",                true],  [["+1e2"],                               false], [null, false]],
-            [0,                                     [null,true], [false,true],  [0,              true],  [0.0,                true],  ["0",                   true],  [[0],                                    false], [$this->i("PT0S"), false]],
-            ["0",                                   [null,true], [false,true],  [0,              true],  [0.0,                true],  ["0",                   true],  [["0"],                                  false], [null, false]],
-            ["000",                                 [null,true], [false,true],  [0,              true],  [0.0,                true],  ["000",                 true],  [["000"],                                false], [null, false]],
-            [0.0,                                   [null,true], [false,true],  [0,              true],  [0.0,                true],  ["0",                   true],  [[0.0],                                  false], [$this->i("PT0S"), false]],
-            ["0.0",                                 [null,true], [false,true],  [0,              true],  [0.0,                true],  ["0.0",                 true],  [["0.0"],                                false], [null, false]],
-            ["000.000",                             [null,true], [false,true],  [0,              true],  [0.0,                true],  ["000.000",             true],  [["000.000"],                            false], [null, false]],
-            ["+0",                                  [null,true], [false,true],  [0,              true],  [0.0,                true],  ["+0",                  true],  [["+0"],                                 false], [null, false]],
-            ["+000",                                [null,true], [false,true],  [0,              true],  [0.0,                true],  ["+000",                true],  [["+000"],                               false], [null, false]],
-            ["+0.0",                                [null,true], [false,true],  [0,              true],  [0.0,                true],  ["+0.0",                true],  [["+0.0"],                               false], [null, false]],
-            ["+000.000",                            [null,true], [false,true],  [0,              true],  [0.0,                true],  ["+000.000",            true],  [["+000.000"],                           false], [null, false]],
-            [-1,                                    [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-1",                  true],  [[-1],                                   false], [$this->i("PT1S"), false]],
-            [-1.0,                                  [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-1",                  true],  [[-1.0],                                 false], [$this->i("PT1S"), false]],
-            ["-1.0",                                [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-1.0",                true],  [["-1.0"],                               false], [null, false]],
-            ["-001.0",                              [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-001.0",              true],  [["-001.0"],                             false], [null, false]],
-            ["-1.0e2",                              [null,true], [true, false], [-100,           true],  [-100.0,             true],  ["-1.0e2",              true],  [["-1.0e2"],                             false], [null, false]],
-            ["-1",                                  [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-1",                  true],  [["-1"],                                 false], [null, false]],
-            ["-001",                                [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-001",                true],  [["-001"],                               false], [null, false]],
-            ["-1e2",                                [null,true], [true, false], [-100,           true],  [-100.0,             true],  ["-1e2",                true],  [["-1e2"],                               false], [null, false]],
-            [-0,                                    [null,true], [false,true],  [0,              true],  [0.0,                true],  ["0",                   true],  [[-0],                                   false], [$this->i("PT0S"), false]],
-            ["-0",                                  [null,true], [false,true],  [0,              true],  [-0.0,               true],  ["-0",                  true],  [["-0"],                                 false], [null, false]],
-            ["-000",                                [null,true], [false,true],  [0,              true],  [-0.0,               true],  ["-000",                true],  [["-000"],                               false], [null, false]],
-            [-0.0,                                  [null,true], [false,true],  [0,              true],  [-0.0,               true],  ["-0",                  true],  [[-0.0],                                 false], [$this->i("PT0S"), false]],
-            ["-0.0",                                [null,true], [false,true],  [0,              true],  [-0.0,               true],  ["-0.0",                true],  [["-0.0"],                               false], [null, false]],
-            ["-000.000",                            [null,true], [false,true],  [0,              true],  [-0.0,               true],  ["-000.000",            true],  [["-000.000"],                           false], [null, false]],
-            [false,                                 [null,true], [false,true],  [0,              false], [0.0,                false], ["",                    false], [[false],                                false], [null, false]],
-            [true,                                  [null,true], [true, true],  [1,              false], [1.0,                false], ["1",                   false], [[true],                                 false], [null, false]],
-            ["on",                                  [null,true], [true, true],  [0,              false], [0.0,                false], ["on",                  true],  [["on"],                                 false], [null, false]],
-            ["off",                                 [null,true], [false,true],  [0,              false], [0.0,                false], ["off",                 true],  [["off"],                                false], [null, false]],
-            ["yes",                                 [null,true], [true, true],  [0,              false], [0.0,                false], ["yes",                 true],  [["yes"],                                false], [null, false]],
-            ["no",                                  [null,true], [false,true],  [0,              false], [0.0,                false], ["no",                  true],  [["no"],                                 false], [null, false]],
-            ["true",                                [null,true], [true, true],  [0,              false], [0.0,                false], ["true",                true],  [["true"],                               false], [null, false]],
-            ["false",                               [null,true], [false,true],  [0,              false], [0.0,                false], ["false",               true],  [["false"],                              false], [null, false]],
-            [INF,                                   [null,true], [true, false], [0,              false], [INF,                true],  ["INF",                 false], [[INF],                                  false], [null, false]],
-            [-INF,                                  [null,true], [true, false], [0,              false], [-INF,               true],  ["-INF",                false], [[-INF],                                 false], [null, false]],
-            [NAN,                                   [null,true], [false,false], [0,              false], [NAN,                true],  ["NAN",                 false], [[],                                     false], [null, false]],
-            [[],                                    [null,true], [false,false], [0,              false], [0.0,                false], ["",                    false], [[],                                     true],  [null, false]],
-            ["some string",                         [null,true], [true, false], [0,              false], [0.0,                false], ["some string",         true],  [["some string"],                        false], [null, false]],
-            ["           ",                         [null,true], [true, false], [0,              false], [0.0,                false], ["           ",         true],  [["           "],                        false], [null, false]],
-            [new \StdClass,                         [null,true], [true, false], [0,              false], [0.0,                false], ["",                    false], [[new \StdClass],                        false], [null, false]],
-            [new StrClass(""),                      [null,true], [false,true],  [0,              false], [0.0,                false], ["",                    true],  [[new StrClass("")],                     false], [null, false]],
-            [new StrClass("1"),                     [null,true], [true, true],  [1,              true],  [1.0,                true],  ["1",                   true],  [[new StrClass("1")],                    false], [null, false]],
-            [new StrClass("0"),                     [null,true], [false,true],  [0,              true],  [0.0,                true],  ["0",                   true],  [[new StrClass("0")],                    false], [null, false]],
-            [new StrClass("-1"),                    [null,true], [true, false], [-1,             true],  [-1.0,               true],  ["-1",                  true],  [[new StrClass("-1")],                   false], [null, false]],
-            [new StrClass("Msg"),                   [null,true], [true, false], [0,              false], [0.0,                false], ["Msg",                 true],  [[new StrClass("Msg")],                  false], [null, false]],
-            [new StrClass("   "),                   [null,true], [true, false], [0,              false], [0.0,                false], ["   ",                 true],  [[new StrClass("   ")],                  false], [null, false]],
-            [2.5,                                   [null,true], [true, false], [2,              false], [2.5,                true],  ["2.5",                 true],  [[2.5],                                  false], [$this->i("PT2S", 0.5), false]],
-            [0.5,                                   [null,true], [true, false], [0,              false], [0.5,                true],  ["0.5",                 true],  [[0.5],                                  false], [$this->i("PT0S", 0.5), false]],
-            ["2.5",                                 [null,true], [true, false], [2,              false], [2.5,                true],  ["2.5",                 true],  [["2.5"],                                false], [null, false]],
-            ["0.5",                                 [null,true], [true, false], [0,              false], [0.5,                true],  ["0.5",                 true],  [["0.5"],                                false], [null, false]],
-            [$this->d("2010-01-01T00:00:00", 0, 0), [null,true], [true, false], [1262304000,     false], [1262304000.0,       false], ["2010-01-01T00:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 0, 0)],false], [null, false]],
-            [$this->d("2010-01-01T00:00:00", 0, 1), [null,true], [true, false], [1262304000,     false], [1262304000.0,       false], ["2010-01-01T00:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 0, 1)],false], [null, false]],
-            [$this->d("2010-01-01T00:00:00", 1, 0), [null,true], [true, false], [1262322000,     false], [1262322000.0,       false], ["2010-01-01T05:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 1, 0)],false], [null, false]],
-            [$this->d("2010-01-01T00:00:00", 1, 1), [null,true], [true, false], [1262322000,     false], [1262322000.0,       false], ["2010-01-01T05:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 1, 1)],false], [null, false]],
-            [1e14,                                  [null,true], [true, false], [10 ** 14,       true],  [1e14,               true],  ["100000000000000",     true],  [[1e14],                                 false], [$this->i("P1157407407DT9H46M40S"), false]],
-            [1e-6,                                  [null,true], [true, false], [0,              false], [1e-6,               true],  ["0.000001",            true],  [[1e-6],                                 false], [$this->i("PT0S", 1e-6), false]],
-            [[1,2,3],                               [null,true], [true, false], [0,              false], [0.0,                false], ["",                    false], [[1,2,3],                                true],  [null, false]],
-            [['a' => 1,'b' => 2],                       [null,true], [true, false], [0,              false], [0.0,                false], ["",                    false], [['a' => 1,'b' => 2],                        true],  [null, false]],
-            [new Result([['a' => 1,'b' => 2]]),         [null,true], [true, false], [0,              false], [0.0,                false], ["",                    false], [[['a' => 1,'b' => 2]],                      true],  [null, false]],
-            [$this->i("PT1H"),                      [null,true], [true, false], [60 * 60,          false], [60.0 * 60.0,          false], ["PT1H",                true],  [[$this->i("PT1H")],                     false], [$this->i("PT1H"), true]],
-            [$this->i("P2DT1H"),                    [null,true], [true, false], [(48 + 1) * 60 * 60,   false], [1.0 * (48 + 1) * 60 * 60,   false], ["P2DT1H",              true],  [[$this->i("P2DT1H")],                   false], [$this->i("P2DT1H"), true]],
-            [$this->i("PT0H"),                      [null,true], [true, false], [0,              false], [0.0,                false], ["PT0S",                true],  [[$this->i("PT0H")],                     false], [$this->i("PT0H"), true]],
-            [$dateDiff,                             [null,true], [true, false], [366 * 24 * 60 * 60,   false], [1.0 * 366 * 24 * 60 * 60,   false], ["P366D",               true],  [[$dateDiff],                            false], [$dateNorm, true]],
-            ["1 year, 2 days",                      [null,true], [true, false], [0,              false], [0.0,                false], ["1 year, 2 days",      true],  [["1 year, 2 days"],                     false], [$this->i("P1Y2D"), false]],
-            ["P1Y2D",                               [null,true], [true, false], [0,              false], [0.0,                false], ["P1Y2D",               true],  [["P1Y2D"],                              false], [$this->i("P1Y2D"), true]],
+            /* Input value                          null         bool           int                          float                              string                          array                                            interval                   */
+            [null,                                  [null,true], [false,false], [0,                  false], [0.0,                      false], ["",                    false], [[],                                     false], [null, false]],
+            ["",                                    [null,true], [false,true],  [0,                  false], [0.0,                      false], ["",                    true],  [[""],                                   false], [null, false]],
+            [1,                                     [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["1",                   true],  [[1],                                    false], [$this->i("PT1S"), false]],
+            [PHP_INT_MAX,                           [null,true], [true, false], [PHP_INT_MAX,        true],  [(float) PHP_INT_MAX,      true],  [(string) PHP_INT_MAX,  true],  [[PHP_INT_MAX],                          false], [$this->i("P292471208677Y195DT15H30M7S"), false]],
+            [1.0,                                   [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["1",                   true],  [[1.0],                                  false], [$this->i("PT1S"), false]],
+            ["1.0",                                 [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["1.0",                 true],  [["1.0"],                                false], [null, false]],
+            ["001.0",                               [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["001.0",               true],  [["001.0"],                              false], [null, false]],
+            ["1.0e2",                               [null,true], [true, false], [100,                true],  [100.0,                    true],  ["1.0e2",               true],  [["1.0e2"],                              false], [null, false]],
+            ["1",                                   [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["1",                   true],  [["1"],                                  false], [null, false]],
+            ["001",                                 [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["001",                 true],  [["001"],                                false], [null, false]],
+            ["1e2",                                 [null,true], [true, false], [100,                true],  [100.0,                    true],  ["1e2",                 true],  [["1e2"],                                false], [null, false]],
+            ["+1.0",                                [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["+1.0",                true],  [["+1.0"],                               false], [null, false]],
+            ["+001.0",                              [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["+001.0",              true],  [["+001.0"],                             false], [null, false]],
+            ["+1.0e2",                              [null,true], [true, false], [100,                true],  [100.0,                    true],  ["+1.0e2",              true],  [["+1.0e2"],                             false], [null, false]],
+            ["+1",                                  [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["+1",                  true],  [["+1"],                                 false], [null, false]],
+            ["+001",                                [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["+001",                true],  [["+001"],                               false], [null, false]],
+            ["+1e2",                                [null,true], [true, false], [100,                true],  [100.0,                    true],  ["+1e2",                true],  [["+1e2"],                               false], [null, false]],
+            [0,                                     [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["0",                   true],  [[0],                                    false], [$this->i("PT0S"), false]],
+            ["0",                                   [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["0",                   true],  [["0"],                                  false], [null, false]],
+            ["000",                                 [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["000",                 true],  [["000"],                                false], [null, false]],
+            [0.0,                                   [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["0",                   true],  [[0.0],                                  false], [$this->i("PT0S"), false]],
+            ["0.0",                                 [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["0.0",                 true],  [["0.0"],                                false], [null, false]],
+            ["000.000",                             [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["000.000",             true],  [["000.000"],                            false], [null, false]],
+            ["+0",                                  [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["+0",                  true],  [["+0"],                                 false], [null, false]],
+            ["+000",                                [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["+000",                true],  [["+000"],                               false], [null, false]],
+            ["+0.0",                                [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["+0.0",                true],  [["+0.0"],                               false], [null, false]],
+            ["+000.000",                            [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["+000.000",            true],  [["+000.000"],                           false], [null, false]],
+            [-1,                                    [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-1",                  true],  [[-1],                                   false], [$this->i("PT1S"), false]],
+            [-1.0,                                  [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-1",                  true],  [[-1.0],                                 false], [$this->i("PT1S"), false]],
+            ["-1.0",                                [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-1.0",                true],  [["-1.0"],                               false], [null, false]],
+            ["-001.0",                              [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-001.0",              true],  [["-001.0"],                             false], [null, false]],
+            ["-1.0e2",                              [null,true], [true, false], [-100,               true],  [-100.0,                   true],  ["-1.0e2",              true],  [["-1.0e2"],                             false], [null, false]],
+            ["-1",                                  [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-1",                  true],  [["-1"],                                 false], [null, false]],
+            ["-001",                                [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-001",                true],  [["-001"],                               false], [null, false]],
+            ["-1e2",                                [null,true], [true, false], [-100,               true],  [-100.0,                   true],  ["-1e2",                true],  [["-1e2"],                               false], [null, false]],
+            [-0,                                    [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["0",                   true],  [[-0],                                   false], [$this->i("PT0S"), false]],
+            ["-0",                                  [null,true], [false,true],  [0,                  true],  [-0.0,                     true],  ["-0",                  true],  [["-0"],                                 false], [null, false]],
+            ["-000",                                [null,true], [false,true],  [0,                  true],  [-0.0,                     true],  ["-000",                true],  [["-000"],                               false], [null, false]],
+            [-0.0,                                  [null,true], [false,true],  [0,                  true],  [-0.0,                     true],  ["-0",                  true],  [[-0.0],                                 false], [$this->i("PT0S"), false]],
+            ["-0.0",                                [null,true], [false,true],  [0,                  true],  [-0.0,                     true],  ["-0.0",                true],  [["-0.0"],                               false], [null, false]],
+            ["-000.000",                            [null,true], [false,true],  [0,                  true],  [-0.0,                     true],  ["-000.000",            true],  [["-000.000"],                           false], [null, false]],
+            [false,                                 [null,true], [false,true],  [0,                  false], [0.0,                      false], ["",                    false], [[false],                                false], [null, false]],
+            [true,                                  [null,true], [true, true],  [1,                  false], [1.0,                      false], ["1",                   false], [[true],                                 false], [null, false]],
+            ["on",                                  [null,true], [true, true],  [0,                  false], [0.0,                      false], ["on",                  true],  [["on"],                                 false], [null, false]],
+            ["off",                                 [null,true], [false,true],  [0,                  false], [0.0,                      false], ["off",                 true],  [["off"],                                false], [null, false]],
+            ["yes",                                 [null,true], [true, true],  [0,                  false], [0.0,                      false], ["yes",                 true],  [["yes"],                                false], [null, false]],
+            ["no",                                  [null,true], [false,true],  [0,                  false], [0.0,                      false], ["no",                  true],  [["no"],                                 false], [null, false]],
+            ["true",                                [null,true], [true, true],  [0,                  false], [0.0,                      false], ["true",                true],  [["true"],                               false], [null, false]],
+            ["false",                               [null,true], [false,true],  [0,                  false], [0.0,                      false], ["false",               true],  [["false"],                              false], [null, false]],
+            [INF,                                   [null,true], [true, false], [0,                  false], [INF,                      true],  ["INF",                 false], [[INF],                                  false], [null, false]],
+            [-INF,                                  [null,true], [true, false], [0,                  false], [-INF,                     true],  ["-INF",                false], [[-INF],                                 false], [null, false]],
+            [NAN,                                   [null,true], [false,false], [0,                  false], [NAN,                      true],  ["NAN",                 false], [[],                                     false], [null, false]],
+            [[],                                    [null,true], [false,false], [0,                  false], [0.0,                      false], ["",                    false], [[],                                     true],  [null, false]],
+            ["some string",                         [null,true], [true, false], [0,                  false], [0.0,                      false], ["some string",         true],  [["some string"],                        false], [null, false]],
+            ["           ",                         [null,true], [true, false], [0,                  false], [0.0,                      false], ["           ",         true],  [["           "],                        false], [null, false]],
+            [new \StdClass,                         [null,true], [true, false], [0,                  false], [0.0,                      false], ["",                    false], [[new \StdClass],                        false], [null, false]],
+            [new StrClass(""),                      [null,true], [false,true],  [0,                  false], [0.0,                      false], ["",                    true],  [[new StrClass("")],                     false], [null, false]],
+            [new StrClass("1"),                     [null,true], [true, true],  [1,                  true],  [1.0,                      true],  ["1",                   true],  [[new StrClass("1")],                    false], [null, false]],
+            [new StrClass("0"),                     [null,true], [false,true],  [0,                  true],  [0.0,                      true],  ["0",                   true],  [[new StrClass("0")],                    false], [null, false]],
+            [new StrClass("-1"),                    [null,true], [true, false], [-1,                 true],  [-1.0,                     true],  ["-1",                  true],  [[new StrClass("-1")],                   false], [null, false]],
+            [new StrClass("Msg"),                   [null,true], [true, false], [0,                  false], [0.0,                      false], ["Msg",                 true],  [[new StrClass("Msg")],                  false], [null, false]],
+            [new StrClass("   "),                   [null,true], [true, false], [0,                  false], [0.0,                      false], ["   ",                 true],  [[new StrClass("   ")],                  false], [null, false]],
+            [2.5,                                   [null,true], [true, false], [2,                  false], [2.5,                      true],  ["2.5",                 true],  [[2.5],                                  false], [$this->i("PT2S", 0.5), false]],
+            [0.5,                                   [null,true], [true, false], [0,                  false], [0.5,                      true],  ["0.5",                 true],  [[0.5],                                  false], [$this->i("PT0S", 0.5), false]],
+            ["2.5",                                 [null,true], [true, false], [2,                  false], [2.5,                      true],  ["2.5",                 true],  [["2.5"],                                false], [null, false]],
+            ["0.5",                                 [null,true], [true, false], [0,                  false], [0.5,                      true],  ["0.5",                 true],  [["0.5"],                                false], [null, false]],
+            [$this->d("2010-01-01T00:00:00", 0, 0), [null,true], [true, false], [1262304000,         false], [1262304000.0,             false], ["2010-01-01T00:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 0, 0)],false], [null, false]],
+            [$this->d("2010-01-01T00:00:00", 0, 1), [null,true], [true, false], [1262304000,         false], [1262304000.0,             false], ["2010-01-01T00:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 0, 1)],false], [null, false]],
+            [$this->d("2010-01-01T00:00:00", 1, 0), [null,true], [true, false], [1262322000,         false], [1262322000.0,             false], ["2010-01-01T05:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 1, 0)],false], [null, false]],
+            [$this->d("2010-01-01T00:00:00", 1, 1), [null,true], [true, false], [1262322000,         false], [1262322000.0,             false], ["2010-01-01T05:00:00Z",true],  [[$this->d("2010-01-01T00:00:00", 1, 1)],false], [null, false]],
+            [1e14,                                  [null,true], [true, false], [10 ** 14,           true],  [1e14,                     true],  ["100000000000000",     true],  [[1e14],                                 false], [$this->i("P1157407407DT9H46M40S"), false]],
+            [1e-6,                                  [null,true], [true, false], [0,                  false], [1e-6,                     true],  ["0.000001",            true],  [[1e-6],                                 false], [$this->i("PT0S", 1e-6), false]],
+            [[1,2,3],                               [null,true], [true, false], [0,                  false], [0.0,                      false], ["",                    false], [[1,2,3],                                true],  [null, false]],
+            [['a' => 1,'b' => 2],                   [null,true], [true, false], [0,                  false], [0.0,                      false], ["",                    false], [['a' => 1,'b' => 2],                    true],  [null, false]],
+            [new Result([['a' => 1,'b' => 2]]),     [null,true], [true, false], [0,                  false], [0.0,                      false], ["",                    false], [[['a' => 1,'b' => 2]],                  true],  [null, false]],
+            [$this->i("PT1H"),                      [null,true], [true, false], [60 * 60,            false], [60.0 * 60.0,              false], ["PT1H",                true],  [[$this->i("PT1H")],                     false], [$this->i("PT1H"), true]],
+            [$this->i("P2DT1H"),                    [null,true], [true, false], [(48 + 1) * 60 * 60, false], [1.0 * (48 + 1) * 60 * 60, false], ["P2DT1H",              true],  [[$this->i("P2DT1H")],                   false], [$this->i("P2DT1H"), true]],
+            [$this->i("PT0H"),                      [null,true], [true, false], [0,                  false], [0.0,                      false], ["PT0S",                true],  [[$this->i("PT0H")],                     false], [$this->i("PT0H"), true]],
+            [$dateDiff,                             [null,true], [true, false], [366 * 24 * 60 * 60, false], [1.0 * 366 * 24 * 60 * 60, false], ["P366D",               true],  [[$dateDiff],                            false], [$dateNorm, true]],
+            ["1 year, 2 days",                      [null,true], [true, false], [0,                  false], [0.0,                      false], ["1 year, 2 days",      true],  [["1 year, 2 days"],                     false], [$this->i("P1Y2D"), false]],
+            ["P1Y2D",                               [null,true], [true, false], [0,                  false], [0.0,                      false], ["P1Y2D",               true],  [["P1Y2D"],                              false], [$this->i("P1Y2D"), true]],
         ] as $set) {
             // shift the input value off the set
             $input = array_shift($set);