From 071b27abcf9bc2afce2ce07ba163f87e6f059477 Mon Sep 17 00:00:00 2001 From: jilen Date: Wed, 2 Jul 2025 15:46:40 +0800 Subject: [PATCH] Better test case --- .../scala/minisql/ast/FromExprsSuite.scala | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/test/scala/minisql/ast/FromExprsSuite.scala b/src/test/scala/minisql/ast/FromExprsSuite.scala index 9cab3b1..70a0d6d 100644 --- a/src/test/scala/minisql/ast/FromExprsSuite.scala +++ b/src/test/scala/minisql/ast/FromExprsSuite.scala @@ -75,7 +75,10 @@ class FromExprsSuite extends FunSuite { testFor("Action - Returning") { Returning( - Insert(Ident("table"), List(Assignment(Ident("x"), Ident("col"), Ident("val")))), + Insert( + Ident("table"), + List(Assignment(Ident("x"), Ident("col"), Ident("val"))) + ), Ident("x"), Property(Ident("x"), "id") ) @@ -83,12 +86,35 @@ class FromExprsSuite extends FunSuite { testFor("Action - ReturningGenerated") { ReturningGenerated( - Insert(Ident("table"), List(Assignment(Ident("x"), Ident("col"), Ident("val")))), + Insert( + Ident("table"), + List(Assignment(Ident("x"), Ident("col"), Ident("val"))) + ), Ident("x"), Property(Ident("x"), "generatedId") ) } + testFor("Action - Val outside") { + val p1 = Update( + Ident("table"), + List(Assignment(Ident("x"), Ident("col"), Ident("val"))) + ) + val p2 = Ident("x") + val p3 = Property(Ident("x"), "id") + Returning(p1, p2, p3) + } + + testFor("Action - ReturningGenerated with Update") { + val p1 = Update( + Ident("table"), + List(Assignment(Ident("x"), Ident("col"), Ident("val"))) + ) + val p2 = Ident("x") + val p3 = Property(Ident("x"), "id") + ReturningGenerated(p1, p2, p3) + } + testFor("If expression") { If(Ident("cond"), Ident("then"), Ident("else")) }