Esempio n. 1
0
 def test_hashing(self):
     obj = OpaqueObject("data", Atom("language"))
     obj2 = OpaqueObject("data", Atom("language"))
     self.assertEqual(hash(obj), hash(obj2))
     obj3 = OpaqueObject("data", Atom("language2"))
     self.assertNotEqual(hash(obj), hash(obj3))
     obj4 = OpaqueObject("data2", Atom("language"))
     self.assertNotEqual(hash(obj), hash(obj4))
Esempio n. 2
0
 def test_opaque_object(self):
     obj = OpaqueObject("data", Atom("language"))
     self.assertEqual(OpaqueObject, type(obj))
     self.assertEqual("data", obj.data)
     self.assertEqual("language", obj.language)
     self.assertEqual("OpaqueObject('data', Atom('language'))", repr(obj))
     self.assertRaises(TypeError, OpaqueObject, "data", "language")
     self.assertRaises(TypeError, OpaqueObject, [1, 2], Atom("language"))
Esempio n. 3
0
 def test_comparison(self):
     obj = OpaqueObject("data", Atom("language"))
     self.assertEqual(obj, obj)
     self.assertEqual(obj, OpaqueObject("data", Atom("language")))
     self.assertNotEqual(obj, OpaqueObject("data", Atom("language2")))
     self.assertNotEqual(obj, OpaqueObject("data2", Atom("language")))
Esempio n. 4
0
 def test_encode_opaque_object(self):
     self.assertEqual(
         "\x83h\3d\0\x0f$erlport.opaqued\0\10language"
         "m\0\0\0\4data", encode(OpaqueObject("data", Atom("language"))))
     self.assertEqual("\x83data",
                      encode(OpaqueObject("data", Atom("erlang"))))
Esempio n. 5
0
 def test_encode_erlang(self):
     obj = OpaqueObject("data", Atom("erlang"))
     self.assertEqual("data", obj.encode())
Esempio n. 6
0
 def test_encode(self):
     obj = OpaqueObject("data", Atom("language"))
     term = Atom("$erlport.opaque"), Atom("language"), "data"
     self.assertEqual(erlterms.encode_term(term), obj.encode())