Line data Source code
1 : // Unit tests for the script-level driver scaffold.
2 : //
3 : // `ScriptDriver` owns the per-script-run state the procedural
4 : // scripting executor threads through every statement family. Today
5 : // the driver only owns the shared `semantic::FrameStack` for the
6 : // script-level variable environment; the primitive itself is
7 : // covered by `backend/engine/semantic/frame_stack_test.cc` so this
8 : // file just pins the driver-side wiring (the script driver owns a
9 : // usable frame stack, callers reach the variables through
10 : // `variables()`).
11 :
12 : #include "backend/engine/semantic/script/script_driver.h"
13 :
14 : #include "backend/engine/semantic/value.h"
15 : #include "googlesql/public/value.h"
16 : #include "gtest/gtest.h"
17 :
18 : namespace bigquery_emulator {
19 : namespace backend {
20 : namespace engine {
21 : namespace semantic {
22 : namespace script {
23 : namespace {
24 :
25 1 : TEST(ScriptDriverTest, OwnsAFrameStack) {
26 1 : ScriptDriver driver;
27 1 : EXPECT_EQ(driver.variables().frame_count(), 1u);
28 1 : ASSERT_TRUE(driver.variables().Declare("x", Value::Int64(7)).ok());
29 1 : auto got = driver.variables().Lookup("x");
30 1 : ASSERT_TRUE(got.ok());
31 1 : EXPECT_EQ(got->int64_value(), 7);
32 1 : }
33 :
34 : } // namespace
35 : } // namespace script
36 : } // namespace semantic
37 : } // namespace engine
38 : } // namespace backend
39 : } // namespace bigquery_emulator
|