Fix: bt2: erroneous integer comparison of Field and Value
[babeltrace.git] / tests / bindings / python / bt2 / test_value.py
index 2b15d104ac0057464e00487c86ddfaa7e1d491dd..8f886c7233afb4cc73047f2ee34f15ba244bd35f 100644 (file)
@@ -1,3 +1,21 @@
+#
+# Copyright (C) 2019 EfficiOS Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; only version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+
 from functools import partial, partialmethod
 import operator
 import unittest
@@ -7,45 +25,14 @@ import copy
 import bt2
 
 
-class _TestFrozen:
-    def test_is_frozen(self):
-        self._def.freeze()
-        self.assertTrue(self._def.is_frozen)
-
-    def test_frozen(self):
-        self._def.freeze()
-        self.assertTrue(self._def.frozen)
-
-    def test_frozen_exc(self):
-        self._def.freeze()
-
-        with self.assertRaisesRegex(bt2.Frozen, r'.* value object is frozen$') as cm:
-            self._modify_def()
-
-        self.assertEqual(self._def, self._def_value)
-
-    def test_get_value_when_frozen(self):
-        self._def.freeze()
-        self.assertEqual(self._def, self._def_value)
-
-
-class _TestFrozenSimple(_TestFrozen):
-    def _modify_def(self):
-        self._def.value = self._def_new_value
-
-
 class _TestCopySimple:
     def test_copy(self):
-        cpy = copy.copy(self._def)
-        self.assertIsNot(cpy, self._def)
-        self.assertNotEqual(cpy.addr, self._def.addr)
-        self.assertEqual(cpy, self._def)
+        with self.assertRaises(NotImplementedError):
+            copy.copy(self._def)
 
     def test_deepcopy(self):
-        cpy = copy.deepcopy(self._def)
-        self.assertIsNot(cpy, self._def)
-        self.assertNotEqual(cpy.addr, self._def.addr)
-        self.assertEqual(cpy, self._def)
+        with self.assertRaises(NotImplementedError):
+            copy.deepcopy(self._def)
 
 
 _COMP_BINOPS = (
@@ -54,7 +41,7 @@ _COMP_BINOPS = (
 )
 
 
-class _TestNumericValue(_TestFrozenSimple, _TestCopySimple):
+class _TestNumericValue(_TestCopySimple):
     def _binop(self, op, rhs):
         rexc = None
         rvexc = None
@@ -126,7 +113,7 @@ class _TestNumericValue(_TestFrozenSimple, _TestCopySimple):
         self.assertEqual(self._def.addr, addr_before)
 
     def _test_unaryop_value_same(self, op):
-        value_before = copy.copy(self._def)
+        value_before = self._def.__class__(self._def)
         self._unaryop(op)
         self.assertEqual(self._def, value_before)
 
@@ -156,7 +143,7 @@ class _TestNumericValue(_TestFrozenSimple, _TestCopySimple):
         self.assertEqual(self._def.addr, addr_before)
 
     def _test_binop_lhs_value_same(self, op, rhs):
-        value_before = copy.copy(self._def)
+        value_before = self._def.__class__(self._def)
         r, rv = self._binop(op, rhs)
         self.assertEqual(self._def, value_before)
 
@@ -201,7 +188,7 @@ class _TestNumericValue(_TestFrozenSimple, _TestCopySimple):
         # the current value of `int_value_obj`, so after this the value
         # of the object is 5. This does not compare to 5.3, which is
         # why we also use the `int()` type here.
-        if type(self._def) is bt2.IntegerValue:
+        if isinstance(self._def, bt2._IntegerValue):
             rv = int(rv)
 
         self.assertEqual(r, rv)
@@ -607,7 +594,7 @@ _UNARYOPS = (
 )
 
 
-def _inject_numeric_testing_methods(cls):
+def _inject_numeric_testing_methods(cls, has_neg=True):
     def test_binop_name(suffix):
         return 'test_binop_{}_{}'.format(name, suffix)
 
@@ -619,7 +606,6 @@ def _inject_numeric_testing_methods(cls):
 
     # inject testing methods for each binary operation
     for name, binop in _BINOPS:
-
         setattr(cls, test_binop_name('invalid_unknown'), partialmethod(_TestNumericValue._test_binop_invalid_unknown, op=binop))
         setattr(cls, test_binop_name('invalid_none'), partialmethod(_TestNumericValue._test_binop_invalid_none, op=binop))
         setattr(cls, test_binop_name('type_true'), partialmethod(_TestNumericValue._test_binop_type_true, op=binop))
@@ -634,14 +620,17 @@ def _inject_numeric_testing_methods(cls):
         setattr(cls, test_binop_name('lhs_value_same_true'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_true, op=binop))
         setattr(cls, test_binop_name('lhs_value_same_pos_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_int, op=binop))
         setattr(cls, test_binop_name('lhs_value_same_pos_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_vint, op=binop))
-        setattr(cls, test_binop_name('type_neg_int'), partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop))
-        setattr(cls, test_binop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop))
-        setattr(cls, test_binop_name('value_neg_int'), partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop))
-        setattr(cls, test_binop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop))
+
+        if has_neg:
+            setattr(cls, test_binop_name('type_neg_int'), partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop))
+            setattr(cls, test_binop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop))
+            setattr(cls, test_binop_name('value_neg_int'), partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop))
+            setattr(cls, test_binop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop))
+            setattr(cls, test_binop_name('lhs_addr_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop))
+            setattr(cls, test_binop_name('lhs_addr_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop))
+            setattr(cls, test_binop_name('lhs_value_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop))
+            setattr(cls, test_binop_name('lhs_value_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop))
+
         setattr(cls, test_binop_name('type_false'), partialmethod(_TestNumericValue._test_binop_type_false, op=binop))
         setattr(cls, test_binop_name('type_zero_int'), partialmethod(_TestNumericValue._test_binop_type_zero_int, op=binop))
         setattr(cls, test_binop_name('type_zero_vint'), partialmethod(_TestNumericValue._test_binop_type_zero_vint, op=binop))
@@ -654,22 +643,25 @@ def _inject_numeric_testing_methods(cls):
         setattr(cls, test_binop_name('lhs_value_same_false'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_false, op=binop))
         setattr(cls, test_binop_name('lhs_value_same_zero_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_int, op=binop))
         setattr(cls, test_binop_name('lhs_value_same_zero_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_vint, op=binop))
+
+        if has_neg:
+            setattr(cls, test_binop_name('type_neg_float'), partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop))
+            setattr(cls, test_binop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop))
+            setattr(cls, test_binop_name('value_neg_float'), partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop))
+            setattr(cls, test_binop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop))
+            setattr(cls, test_binop_name('lhs_addr_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop))
+            setattr(cls, test_binop_name('lhs_addr_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop))
+            setattr(cls, test_binop_name('lhs_value_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop))
+            setattr(cls, test_binop_name('lhs_value_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop))
+
         setattr(cls, test_binop_name('type_pos_float'), partialmethod(_TestNumericValue._test_binop_type_pos_float, op=binop))
-        setattr(cls, test_binop_name('type_neg_float'), partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop))
         setattr(cls, test_binop_name('type_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_type_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop))
         setattr(cls, test_binop_name('value_pos_float'), partialmethod(_TestNumericValue._test_binop_value_pos_float, op=binop))
-        setattr(cls, test_binop_name('value_neg_float'), partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop))
         setattr(cls, test_binop_name('value_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_value_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop))
         setattr(cls, test_binop_name('lhs_addr_same_pos_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop))
         setattr(cls, test_binop_name('lhs_addr_same_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop))
         setattr(cls, test_binop_name('lhs_value_same_pos_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop))
         setattr(cls, test_binop_name('lhs_value_same_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop))
         setattr(cls, test_binop_name('type_zero_float'), partialmethod(_TestNumericValue._test_binop_type_zero_float, op=binop))
         setattr(cls, test_binop_name('type_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_type_zero_vfloat, op=binop))
         setattr(cls, test_binop_name('value_zero_float'), partialmethod(_TestNumericValue._test_binop_value_zero_float, op=binop))
@@ -696,10 +688,13 @@ def _inject_numeric_testing_methods(cls):
         setattr(cls, test_ibinop_name('type_pos_vint'), partialmethod(_TestNumericValue._test_ibinop_type_pos_vint, op=ibinop))
         setattr(cls, test_ibinop_name('value_pos_int'), partialmethod(_TestNumericValue._test_ibinop_value_pos_int, op=ibinop))
         setattr(cls, test_ibinop_name('value_pos_vint'), partialmethod(_TestNumericValue._test_ibinop_value_pos_vint, op=ibinop))
-        setattr(cls, test_ibinop_name('type_neg_int'), partialmethod(_TestNumericValue._test_ibinop_type_neg_int, op=ibinop))
-        setattr(cls, test_ibinop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_ibinop_type_neg_vint, op=ibinop))
-        setattr(cls, test_ibinop_name('value_neg_int'), partialmethod(_TestNumericValue._test_ibinop_value_neg_int, op=ibinop))
-        setattr(cls, test_ibinop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_ibinop_value_neg_vint, op=ibinop))
+
+        if has_neg:
+            setattr(cls, test_ibinop_name('type_neg_int'), partialmethod(_TestNumericValue._test_ibinop_type_neg_int, op=ibinop))
+            setattr(cls, test_ibinop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_ibinop_type_neg_vint, op=ibinop))
+            setattr(cls, test_ibinop_name('value_neg_int'), partialmethod(_TestNumericValue._test_ibinop_value_neg_int, op=ibinop))
+            setattr(cls, test_ibinop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_ibinop_value_neg_vint, op=ibinop))
+
         setattr(cls, test_ibinop_name('type_false'), partialmethod(_TestNumericValue._test_ibinop_type_false, op=ibinop))
         setattr(cls, test_ibinop_name('value_false'), partialmethod(_TestNumericValue._test_ibinop_value_false, op=ibinop))
         setattr(cls, test_ibinop_name('type_zero_int'), partialmethod(_TestNumericValue._test_ibinop_type_zero_int, op=ibinop))
@@ -707,20 +702,22 @@ def _inject_numeric_testing_methods(cls):
         setattr(cls, test_ibinop_name('value_zero_int'), partialmethod(_TestNumericValue._test_ibinop_value_zero_int, op=ibinop))
         setattr(cls, test_ibinop_name('value_zero_vint'), partialmethod(_TestNumericValue._test_ibinop_value_zero_vint, op=ibinop))
         setattr(cls, test_ibinop_name('type_pos_float'), partialmethod(_TestNumericValue._test_ibinop_type_pos_float, op=ibinop))
-        setattr(cls, test_ibinop_name('type_neg_float'), partialmethod(_TestNumericValue._test_ibinop_type_neg_float, op=ibinop))
+
+        if has_neg:
+            setattr(cls, test_ibinop_name('type_neg_float'), partialmethod(_TestNumericValue._test_ibinop_type_neg_float, op=ibinop))
+            setattr(cls, test_ibinop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_neg_vfloat, op=ibinop))
+            setattr(cls, test_ibinop_name('value_neg_float'), partialmethod(_TestNumericValue._test_ibinop_value_neg_float, op=ibinop))
+            setattr(cls, test_ibinop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_neg_vfloat, op=ibinop))
+
         setattr(cls, test_ibinop_name('type_pos_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_pos_vfloat, op=ibinop))
-        setattr(cls, test_ibinop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_neg_vfloat, op=ibinop))
         setattr(cls, test_ibinop_name('value_pos_float'), partialmethod(_TestNumericValue._test_ibinop_value_pos_float, op=ibinop))
-        setattr(cls, test_ibinop_name('value_neg_float'), partialmethod(_TestNumericValue._test_ibinop_value_neg_float, op=ibinop))
         setattr(cls, test_ibinop_name('value_pos_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_pos_vfloat, op=ibinop))
-        setattr(cls, test_ibinop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_neg_vfloat, op=ibinop))
         setattr(cls, test_ibinop_name('type_zero_float'), partialmethod(_TestNumericValue._test_ibinop_type_zero_float, op=ibinop))
         setattr(cls, test_ibinop_name('type_zero_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_zero_vfloat, op=ibinop))
         setattr(cls, test_ibinop_name('value_zero_float'), partialmethod(_TestNumericValue._test_ibinop_value_zero_float, op=ibinop))
         setattr(cls, test_ibinop_name('value_zero_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_zero_vfloat, op=ibinop))
 
 
-@unittest.skip("this is broken")
 class CreateValueFuncTestCase(unittest.TestCase):
     def test_create_none(self):
         v = bt2.create_value(None)
@@ -739,25 +736,25 @@ class CreateValueFuncTestCase(unittest.TestCase):
     def test_create_int_pos(self):
         raw = 23
         v = bt2.create_value(raw)
-        self.assertIsInstance(v, bt2.IntegerValue)
+        self.assertIsInstance(v, bt2.SignedIntegerValue)
         self.assertEqual(v, raw)
 
     def test_create_int_neg(self):
         raw = -23
         v = bt2.create_value(raw)
-        self.assertIsInstance(v, bt2.IntegerValue)
+        self.assertIsInstance(v, bt2.SignedIntegerValue)
         self.assertEqual(v, raw)
 
     def test_create_float_pos(self):
         raw = 17.5
         v = bt2.create_value(raw)
-        self.assertIsInstance(v, bt2.FloatValue)
+        self.assertIsInstance(v, bt2.RealValue)
         self.assertEqual(v, raw)
 
     def test_create_float_neg(self):
         raw = -17.5
         v = bt2.create_value(raw)
-        self.assertIsInstance(v, bt2.FloatValue)
+        self.assertIsInstance(v, bt2.RealValue)
         self.assertEqual(v, raw)
 
     def test_create_string(self):
@@ -823,8 +820,7 @@ class CreateValueFuncTestCase(unittest.TestCase):
             v = bt2.create_value(a)
 
 
-@unittest.skip("this is broken")
-class BoolValueTestCase(_TestFrozenSimple, _TestCopySimple, unittest.TestCase):
+class BoolValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
         self._f = bt2.BoolValue(False)
         self._t = bt2.BoolValue(True)
@@ -916,20 +912,16 @@ class BoolValueTestCase(_TestFrozenSimple, _TestCopySimple, unittest.TestCase):
         self.assertNotEqual(self._t, False)
 
 
-@unittest.skip("this is broken")
-class IntegerValueTestCase(_TestNumericValue, unittest.TestCase):
+class _TestIntegerValue(_TestNumericValue):
     def setUp(self):
         self._pv = 23
-        self._nv = -52
-        self._ip = bt2.IntegerValue(self._pv)
-        self._in = bt2.IntegerValue(self._nv)
+        self._ip = self._CLS(self._pv)
         self._def = self._ip
         self._def_value = self._pv
-        self._def_new_value = -101
+        self._def_new_value = 101
 
     def tearDown(self):
         del self._ip
-        del self._in
         del self._def
         del self._def_value
 
@@ -943,7 +935,7 @@ class IntegerValueTestCase(_TestNumericValue, unittest.TestCase):
         return self.assertRaisesRegex(ValueError, r"expecting an unsigned 64-bit integral value")
 
     def test_create_default(self):
-        i = bt2.IntegerValue()
+        i = self._CLS()
         self.assertEqual(i, 0)
 
     def test_create_pos(self):
@@ -952,33 +944,25 @@ class IntegerValueTestCase(_TestNumericValue, unittest.TestCase):
     def test_create_neg(self):
         self.assertEqual(self._in, self._nv)
 
-    def test_create_pos_too_big(self):
-        with self._assert_expecting_int64():
-            i = bt2.IntegerValue(2 ** 63)
-
-    def test_create_neg_too_big(self):
-        with self._assert_expecting_int64():
-            i = bt2.IntegerValue(-(2 ** 63) - 1)
-
     def test_create_from_vint(self):
-        i = bt2.IntegerValue(self._ip)
+        i = self._CLS(self._ip)
         self.assertEqual(i, self._pv)
 
     def test_create_from_false(self):
-        i = bt2.IntegerValue(False)
+        i = self._CLS(False)
         self.assertFalse(i)
 
     def test_create_from_true(self):
-        i = bt2.IntegerValue(True)
+        i = self._CLS(True)
         self.assertTrue(i)
 
     def test_create_from_float(self):
-        i = bt2.IntegerValue(99.6)
+        i = self._CLS(99.6)
         self.assertEqual(i, 99)
 
     def test_create_from_vfloat(self):
         f = bt2.create_value(17.5)
-        i = bt2.IntegerValue(f)
+        i = self._CLS(f)
         self.assertEqual(i, 17)
 
     def test_create_from_unknown(self):
@@ -986,11 +970,11 @@ class IntegerValueTestCase(_TestNumericValue, unittest.TestCase):
             pass
 
         with self._assert_expecting_int():
-            i = bt2.IntegerValue(A())
+            i = self._CLS(A())
 
     def test_create_from_varray(self):
         with self._assert_expecting_int():
-            i = bt2.IntegerValue(bt2.ArrayValue())
+            i = self._CLS(bt2.ArrayValue())
 
     def test_assign_true(self):
         raw = True
@@ -1007,11 +991,6 @@ class IntegerValueTestCase(_TestNumericValue, unittest.TestCase):
         self._def.value = raw
         self.assertEqual(self._def, raw)
 
-    def test_assign_neg_int(self):
-        raw = -13
-        self._def.value = raw
-        self.assertEqual(self._def, raw)
-
     def test_assign_vint(self):
         raw = 999
         self._def.value = bt2.create_value(raw)
@@ -1023,16 +1002,67 @@ class IntegerValueTestCase(_TestNumericValue, unittest.TestCase):
         self.assertEqual(self._def, int(raw))
 
 
-_inject_numeric_testing_methods(IntegerValueTestCase)
+class SignedIntegerValueTestCase(_TestIntegerValue, unittest.TestCase):
+    _CLS = bt2.SignedIntegerValue
+
+    def setUp(self):
+        super().setUp()
+        self._nv = -52
+        self._in = self._CLS(self._nv)
+        self._def_new_value = -101
+
+    def tearDown(self):
+        super().tearDown()
+        del self._in
+
+    def test_create_neg(self):
+        self.assertEqual(self._in, self._nv)
+
+    def test_create_pos_too_big(self):
+        with self._assert_expecting_int64():
+            i = self._CLS(2 ** 63)
+
+    def test_create_neg_too_big(self):
+        with self._assert_expecting_int64():
+            i = self._CLS(-(2 ** 63) - 1)
+
+    def test_assign_neg_int(self):
+        raw = -13
+        self._def.value = raw
+        self.assertEqual(self._def, raw)
+
+    def test_compare_big_int(self):
+        # Larger than the IEEE 754 double-precision exact representation of
+        # integers.
+        raw = (2**53) + 1
+        v = bt2.create_value(raw)
+        self.assertEqual(v, raw)
+
+
+_inject_numeric_testing_methods(SignedIntegerValueTestCase)
+
+
+class UnsignedIntegerValueTestCase(_TestIntegerValue, unittest.TestCase):
+    _CLS = bt2.UnsignedIntegerValue
+
+    def test_create_pos_too_big(self):
+        with self._assert_expecting_uint64():
+            i = self._CLS(2 ** 64)
+
+    def test_create_neg(self):
+        with self._assert_expecting_uint64():
+            i = self._CLS(-1)
+
+
+_inject_numeric_testing_methods(UnsignedIntegerValueTestCase, False)
 
 
-@unittest.skip("this is broken")
-class FloatValueTestCase(_TestNumericValue, unittest.TestCase):
+class RealValueTestCase(_TestNumericValue, unittest.TestCase):
     def setUp(self):
         self._pv = 23.4
         self._nv = -52.7
-        self._fp = bt2.FloatValue(self._pv)
-        self._fn = bt2.FloatValue(self._nv)
+        self._fp = bt2.RealValue(self._pv)
+        self._fn = bt2.RealValue(self._nv)
         self._def = self._fp
         self._def_value = self._pv
         self._def_new_value = -101.88
@@ -1051,7 +1081,7 @@ class FloatValueTestCase(_TestNumericValue, unittest.TestCase):
             cb()
 
     def test_create_default(self):
-        f = bt2.FloatValue()
+        f = bt2.RealValue()
         self.assertEqual(f, 0.0)
 
     def test_create_pos(self):
@@ -1061,30 +1091,30 @@ class FloatValueTestCase(_TestNumericValue, unittest.TestCase):
         self.assertEqual(self._fn, self._nv)
 
     def test_create_from_vint(self):
-        f = bt2.FloatValue(self._fp)
+        f = bt2.RealValue(self._fp)
         self.assertEqual(f, self._pv)
 
     def test_create_from_false(self):
-        f = bt2.FloatValue(False)
+        f = bt2.RealValue(False)
         self.assertFalse(f)
 
     def test_create_from_true(self):
-        f = bt2.FloatValue(True)
+        f = bt2.RealValue(True)
         self.assertTrue(f)
 
     def test_create_from_int(self):
         raw = 17
-        f = bt2.FloatValue(raw)
+        f = bt2.RealValue(raw)
         self.assertEqual(f, float(raw))
 
     def test_create_from_vint(self):
         raw = 17
-        f = bt2.FloatValue(bt2.create_value(raw))
+        f = bt2.RealValue(bt2.create_value(raw))
         self.assertEqual(f, float(raw))
 
     def test_create_from_vfloat(self):
         raw = 17.17
-        f = bt2.FloatValue(bt2.create_value(raw))
+        f = bt2.RealValue(bt2.create_value(raw))
         self.assertEqual(f, raw)
 
     def test_create_from_unknown(self):
@@ -1092,11 +1122,11 @@ class FloatValueTestCase(_TestNumericValue, unittest.TestCase):
             pass
 
         with self._assert_expecting_float():
-            f = bt2.FloatValue(A())
+            f = bt2.RealValue(A())
 
     def test_create_from_varray(self):
         with self._assert_expecting_float():
-            f = bt2.FloatValue(bt2.ArrayValue())
+            f = bt2.RealValue(bt2.ArrayValue())
 
     def test_assign_true(self):
         self._def.value = True
@@ -1150,11 +1180,10 @@ class FloatValueTestCase(_TestNumericValue, unittest.TestCase):
         self._test_invalid_op(lambda: ~self._def)
 
 
-_inject_numeric_testing_methods(FloatValueTestCase)
+_inject_numeric_testing_methods(RealValueTestCase)
 
 
-@unittest.skip("this is broken")
-class StringValueTestCase(_TestCopySimple, _TestFrozenSimple, unittest.TestCase):
+class StringValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
         self._def_value = 'Hello, World!'
         self._def = bt2.StringValue(self._def_value)
@@ -1272,8 +1301,7 @@ class StringValueTestCase(_TestCopySimple, _TestFrozenSimple, unittest.TestCase)
         self.assertEqual(self._def, self._def_value)
 
 
-@unittest.skip("this is broken")
-class ArrayValueTestCase(_TestFrozen, unittest.TestCase):
+class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
         self._def_value = [None, False, True, -23, 0, 42, -42.4, 23.17, 'yes']
         self._def = bt2.ArrayValue(copy.deepcopy(self._def_value))
@@ -1320,22 +1348,6 @@ class ArrayValueTestCase(_TestFrozen, unittest.TestCase):
     def test_len(self):
         self.assertEqual(len(self._def), len(self._def_value))
 
-    def test_copy(self):
-        to_copy = (1, 2, 'hello', (4, 5.2))
-        a = bt2.ArrayValue(to_copy)
-        cpy = copy.copy(a)
-        self.assertEqual(a, cpy)
-        self.assertNotEqual(a.addr, cpy.addr)
-        self.assertEqual(a[3].addr, cpy[3].addr)
-
-    def test_deepcopy(self):
-        to_copy = (1, 2, 'hello', (4, 5.2))
-        a = bt2.ArrayValue(to_copy)
-        cpy = copy.deepcopy(a)
-        self.assertEqual(a, cpy)
-        self.assertNotEqual(a.addr, cpy.addr)
-        self.assertNotEqual(a[3].addr, cpy[3].addr)
-
     def test_eq_int(self):
         self.assertNotEqual(self._def, 23)
 
@@ -1428,8 +1440,7 @@ class ArrayValueTestCase(_TestFrozen, unittest.TestCase):
             self.assertEqual(velem, elem)
 
 
-@unittest.skip("this is broken")
-class MapValueTestCase(_TestFrozen, unittest.TestCase):
+class MapValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
         self._def_value = {
             'none': None,
@@ -1478,32 +1489,6 @@ class MapValueTestCase(_TestFrozen, unittest.TestCase):
     def test_len(self):
         self.assertEqual(len(self._def), len(self._def_value))
 
-    def test_copy(self):
-        to_copy = {
-            'yes': 1,
-            'no': 2,
-            's': 'hello',
-            'inner': (4, 5.2)
-        }
-        m = bt2.MapValue(to_copy)
-        cpy = copy.copy(m)
-        self.assertEqual(m, cpy)
-        self.assertNotEqual(m.addr, cpy.addr)
-        self.assertEqual(m['inner'].addr, cpy['inner'].addr)
-
-    def test_deepcopy(self):
-        to_copy = {
-            'yes': 1,
-            'no': 2,
-            's': 'hello',
-            'inner': (4, 5.2)
-        }
-        m = bt2.MapValue(to_copy)
-        cpy = copy.deepcopy(m)
-        self.assertEqual(m, cpy)
-        self.assertNotEqual(m.addr, cpy.addr)
-        self.assertNotEqual(m['inner'].addr, cpy['inner'].addr)
-
     def test_eq_int(self):
         self.assertNotEqual(self._def, 23)
 
This page took 0.031116 seconds and 4 git commands to generate.