[FIX] py.js: unhandled prefix `not`

closes #6129
This commit is contained in:
Thomas Groutars 2015-03-29 16:16:32 +02:00 committed by Xavier Morel
parent f57e580f2d
commit b665478fa7
2 changed files with 15 additions and 2 deletions

View File

@ -317,10 +317,10 @@ var py = {};
} else if (token in symbols) {
var symbol;
// transform 'not in' and 'is not' in a single token
if (token === 'in' && tokens[tokens.length-1].id === 'not') {
if (token === 'in' && tokens.length > 1 && tokens[tokens.length-1].id === 'not') {
symbol = symbols['not in'];
tokens.pop();
} else if (token === 'not' && tokens[tokens.length-1].id === 'is') {
} else if (token === 'not' && tokens.length > 1 && tokens[tokens.length-1].id === 'is') {
symbol = symbols['is not'];
tokens.pop();
} else {

View File

@ -1,3 +1,16 @@
openerp.testing.section('eval.basics', {
dependencies: ['web.core'],
setup: function (instance) {
instance.session.uid = 42;
}
}, function (test) {
test('not prefix', function (instance) {
ok(py.eval('not False'));
ok(py.eval('not foo', {foo: false}));
ok(py.eval('not a in b', {a: 3, b: [1, 2, 4, 8]}));
});
});
openerp.testing.section('eval.types', {
dependencies: ['web.core'],
setup: function (instance) {