Skip to content

Commit

Permalink
Changing logic of Arcadia.Utils/TrueNil. Fixes #351.
Browse files Browse the repository at this point in the history
  • Loading branch information
timsgardner committed Mar 4, 2019
1 parent e51ef25 commit c557668
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Helpers/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,10 @@ public static bool IsNull (object obj)
public static object TrueNil (object obj)
{
UnityEngine.Object obj2 = obj as UnityEngine.Object;
if (obj2 == null) {
if (obj2 == null && obj is UnityEngine.Object) {
return null;
}

return obj;
return obj;
}

// ==================================================================
Expand Down
17 changes: 16 additions & 1 deletion Tests/arcadia/arcadia_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@

;; ------------------------------------------------------------


(at/deftest scene-graph-system t
(as-sub-closing [t "GameObject traversal"]
(with-temp-objects :lit [x y z]
Expand Down Expand Up @@ -568,6 +569,17 @@
;; core-namespace

(at/deftest core-namespace t
(as-sub-closing [t "null->nil"]
(with-temp-objects :lit [obj]
(t (at/is (= obj (ac/null->nil obj))
"non-destroyed object null->nil value is original object")))
(with-temp-objects :lit [obj]
(ac/destroy-immediate obj)
(t (at/is (= nil (ac/null->nil obj))
"destroyed object null->nil value is nil")))
(t
(at/is (= :not-a-unity-object (ac/null->nil :not-a-unity-object)))
(at/is (= nil (ac/null->nil nil)))))
(as-sub-closing [t "instantiate"]
(with-temp-objects :lit [original]
(let [position (al/v3 (rand) (rand) (rand))
Expand All @@ -592,7 +604,10 @@
"3-ary instantiate uses new position"))
(t (at/is (= (.. clone-2 transform rotation)
rotation)
"3-ary instantiate uses new rotation"))))))
"3-ary instantiate uses new rotation"))))))

;; ------------------------------------------------------------


;; ------------------------------------------------------------
;; linear-namespace
Expand Down

0 comments on commit c557668

Please sign in to comment.