Serene Runtime 1.0.0
C runtime for the Serene programming language
Loading...
Searching...
No Matches
context_tests.h File Reference
#include "base.h"
#include "serene/rt/core.h"
#include "serene/rt/namespaces.h"
#include "serene/rt/strings.h"
Include dependency graph for context_tests.h:

Go to the source code of this file.

Macros

#define CTX_TESTS(X)
 

Functions

static void test_context_make ()
 
static void test_namespace_registeration ()
 

Macro Definition Documentation

◆ CTX_TESTS

#define CTX_TESTS ( X)
Value:
X("context::make", test_context_make), \
X("context::ns_registeration", test_namespace_registeration)
static void test_context_make()
static void test_namespace_registeration()

Definition at line 26 of file context_tests.h.

26#define CTX_TESTS(X) \
27 X("context::make", test_context_make), \
28 X("context::ns_registeration", test_namespace_registeration)

Function Documentation

◆ test_context_make()

static void test_context_make ( )
static

Definition at line 30 of file context_tests.h.

30 {
31 MAKE_ENGINE(mm, engine);
32 MAKE_CONTEXT(engine, ctx);
33 ASSERT_NOT_NULL(ctx);
34 ASSERT_NOT_NULL(ctx->engine);
35 TEST_CHECK(ctx->parent == nullptr);
36 RELEASE_CONTEXT(ctx);
37 SHUTDOWN_ENGINE(mm, engine);
38}
#define TEST_CHECK(cond)
Definition acutest.h:96
#define RELEASE_CONTEXT(x)
Definition base.h:46
#define ASSERT_NOT_NULL(x)
Definition base.h:30
#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

◆ test_namespace_registeration()

static void test_namespace_registeration ( )
static

Definition at line 40 of file context_tests.h.

40 {
41 MAKE_ENGINE(mm, engine);
42 MAKE_CONTEXT(engine, ctx);
43
44 srn_value_t *name = srn_string_make(ctx, &absurd_metadata, "serene.tests");
46
48 srn_error_t *err = srn_context_register_namespace(ctx, AS_NS(ns));
49
50 TEST_CHECK(err == nullptr);
51
52 TEST_CHECK(ctx->engine->namespaces.len == 1);
53
54 RELEASE_CONTEXT(ctx);
55 SHUTDOWN_ENGINE(mm, engine);
56}
static srn_metadata_t absurd_metadata
We use this for testing.
Definition core.h:66
#define TYPE(value_ref)
Definition core.h:160
@ VNamespace
Definition core.h:122
#define AS_STRING(value_ref)
Definition core.h:171
#define AS_NS(value_ref)
Definition core.h:170
srn_value_t * srn_namespace_make(srn_context_t *ctx, srn_metadata_t *metadata, srn_string_t *name)
Creates a new namespace in the give context.
Definition namespaces.c:27
srn_value_t * srn_string_make(srn_context_t *ctx, srn_metadata_t *metadata, const char *src)
Create a string from a null terminated C string.
Definition strings.c:50
Here is the call graph for this function: