From b966351e1f88319520c7bdbaa6fba9e198b366b4 Mon Sep 17 00:00:00 2001 From: psvri Date: Sat, 18 Jan 2025 16:49:14 +0530 Subject: [PATCH] Implement IsNot operator --- core/translate/expr.rs | 13 +++++++++++++ testing/compare.test | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/core/translate/expr.rs b/core/translate/expr.rs index 4f1fe2bae..3cb2a631a 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -605,6 +605,19 @@ pub fn translate_expr( if_true_label, ); } + ast::Operator::IsNot => { + let if_true_label = program.allocate_label(); + wrap_eval_jump_expr( + program, + Insn::Ne { + lhs: e1_reg, + rhs: e2_reg, + target_pc: if_true_label, + }, + target_register, + if_true_label, + ); + } #[cfg(feature = "json")] op @ (ast::Operator::ArrowRight | ast::Operator::ArrowRightShift) => { let json_func = match op { diff --git a/testing/compare.test b/testing/compare.test index d98fdebe0..a9f6bb477 100644 --- a/testing/compare.test +++ b/testing/compare.test @@ -160,4 +160,25 @@ foreach {testname lhs rhs ans} { text-text-2 'a' 'a' 1 } { do_execsql_test compare-is-$testname "SELECT $lhs is $rhs" $::ans +} + +foreach {testname lhs rhs ans} { + int-int-1 8 1 1 + int-int-2 8 8 0 +} { + do_execsql_test compare-is-not-$testname "SELECT $lhs is not $rhs" $::ans +} + +foreach {testname lhs rhs ans} { + float-float-1 8.0 1.0 1 + float-float-2 8.0 8.0 0 +} { + do_execsql_test compare-is-not-$testname "SELECT $lhs is not $rhs" $::ans +} + +foreach {testname lhs rhs ans} { + text-text-1 'a' 'b' 1 + text-text-2 'a' 'a' 0 +} { + do_execsql_test compare-is-not-$testname "SELECT $lhs is not $rhs" $::ans } \ No newline at end of file