+1
-1
@@ -244,7 +244,7 @@
|
||||
};
|
||||
|
||||
Sao.PYSON.Not.eval_ = function(value, context) {
|
||||
return !value.v;
|
||||
return !Sao.PYSON.Bool.eval_(value, context);
|
||||
};
|
||||
Sao.PYSON.Not.init_from_object = function(obj) {
|
||||
return new Sao.PYSON.Not(obj.v);
|
||||
|
||||
@@ -128,6 +128,24 @@
|
||||
'decode(Not(false))');
|
||||
QUnit.strictEqual(new Sao.PYSON.Not(true).toString(),
|
||||
"Not(true)");
|
||||
|
||||
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Not({}));
|
||||
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
|
||||
"decode(Not({}))");
|
||||
|
||||
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Not({
|
||||
'a': 1,
|
||||
}));
|
||||
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
|
||||
"decode(Not({'a': 1}))");
|
||||
|
||||
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Not([]));
|
||||
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
|
||||
"decode(Not([]))");
|
||||
|
||||
eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Not(['a']));
|
||||
QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
|
||||
"decode(Not(['a']))");
|
||||
});
|
||||
|
||||
QUnit.test('PYSON Bool', function() {
|
||||
|
||||
@@ -223,7 +223,7 @@ class Not(PYSON):
|
||||
|
||||
@staticmethod
|
||||
def eval(dct, context):
|
||||
return not dct['v']
|
||||
return not Bool(dct['v']).eval(dct, context)
|
||||
|
||||
|
||||
class Bool(PYSON):
|
||||
|
||||
@@ -223,7 +223,7 @@ class Not(PYSON):
|
||||
|
||||
@staticmethod
|
||||
def eval(dct, context):
|
||||
return not dct['v']
|
||||
return not Bool(dct['v']).eval(dct, context)
|
||||
|
||||
|
||||
class Bool(PYSON):
|
||||
|
||||
@@ -70,6 +70,20 @@ class PYSONTestCase(unittest.TestCase):
|
||||
repr(pyson.Eval('foo') != 'bar'),
|
||||
"(Eval('foo') != 'bar')")
|
||||
|
||||
eval_ = pyson.PYSONEncoder().encode(pyson.Not({}))
|
||||
self.assertTrue(pyson.PYSONDecoder().decode(eval_))
|
||||
|
||||
eval_ = pyson.PYSONEncoder().encode(pyson.Not({
|
||||
'a': 1,
|
||||
}))
|
||||
self.assertFalse(pyson.PYSONDecoder().decode(eval_))
|
||||
|
||||
eval_ = pyson.PYSONEncoder().encode(pyson.Not([]))
|
||||
self.assertTrue(pyson.PYSONDecoder().decode(eval_))
|
||||
|
||||
eval_ = pyson.PYSONEncoder().encode(pyson.Not(['a']))
|
||||
self.assertFalse(pyson.PYSONDecoder().decode(eval_))
|
||||
|
||||
def test_Bool(self):
|
||||
'Test pyson.Bool'
|
||||
self.assertEqual(pyson.Bool('test').pyson(), {
|
||||
|
||||
Reference in New Issue
Block a user