diff options
author | José Fonseca <jfonseca@vmware.com> | 2014-11-07 11:33:28 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2014-11-07 11:33:28 +0000 |
commit | 5ae6bdc0d040312cdcb32bc9637ef59a4530f8d8 (patch) | |
tree | 4e9db714609513d95c36b21fc503fdf32e084949 /scripts | |
parent | 983407090388198c8e6e48c97f4100727b8af116 (diff) |
scrips/jsondiff: Handle NaNs correctly.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/jsondiff.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py index 8719cd58..a76d0c9d 100755 --- a/scripts/jsondiff.py +++ b/scripts/jsondiff.py @@ -175,7 +175,12 @@ class Comparer(Visitor): def visitValue(self, a, b): if isinstance(a, float) and isinstance(b, (int, long, float)) or \ isinstance(b, float) and isinstance(a, (int, long, float)): - if a == 0: + if a is b: + # NaNs take this path + return True + elif a == b: + return True + elif a == 0: return abs(b) < self.tolerance else: return abs((b - a)/a) < self.tolerance |