Serene Runtime 1.0.0
C runtime for the Serene programming language
Loading...
Searching...
No Matches
value_tests.h
Go to the documentation of this file.
1/* -*- C -*-
2 * Serene programming language
3 * Copyright (C) 2019-2026 Sameer Rahmani <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include <serene/rt/core.h>
23
24#include "base.h"
25
26#define VALUE_TESTS(X) X("values::basics", test_value_basics),
27
28#if defined(V_DEBUG)
29# define V_TEST_LOG(...) DBG("VALUE_TEST", __VA_ARGS__)
30#else
31# define V_TEST_LOG(...)
32#endif
33
34static void test_value_basics() {
35 MAKE_ENGINE(mm, engine);
36 MAKE_CONTEXT(engine, ctx);
37
40
41 TEST_CHECK(x1->type == VI64);
42 TEST_CHECK(x1->as.i64 == 5);
43 TEST_CHECK(x2->as.i64 == -15);
44
45 RELEASE_CONTEXT(ctx);
46 SHUTDOWN_ENGINE(mm, engine);
47}
#define TEST_CHECK(cond)
Definition acutest.h:96
#define RELEASE_CONTEXT(x)
Definition base.h:46
#define SHUTDOWN_ENGINE(mm, engine)
Definition base.h:38
#define MAKE_ENGINE(mm, engine)
Definition base.h:32
#define MAKE_CONTEXT(engine, x)
Definition base.h:42
static srn_metadata_t absurd_metadata
We use this for testing.
Definition core.h:66
@ VI64
Definition core.h:116
static srn_value_t * srn_make_i64(srn_context_t *ctx, srn_metadata_t *metadata, int64_t x)
Definition numbers.h:24
int64_t i64
We represent all the immidiate numbers with this field and cast as we to an appropriate type.
Definition core.h:138
union srn_value_t::@033047061046230251001111174367071167226300135003 as
IMPORTANT NOTE: The size of this union should never be larger than a word.
srn_value_tag_t type
Definition core.h:132
static void test_value_basics()
Definition value_tests.h:34