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

Go to the source code of this file.

Macros

#define NS_TESTS(X)
 

Functions

static void test_ns_make ()
 

Macro Definition Documentation

◆ NS_TESTS

#define NS_TESTS ( X)
Value:
X("namespace::make", test_ns_make)
static void test_ns_make()
Definition ns_tests.h:30

Definition at line 28 of file ns_tests.h.

Function Documentation

◆ test_ns_make()

static void test_ns_make ( )
static

Definition at line 30 of file ns_tests.h.

30 {
31 MAKE_ENGINE(mm, engine);
32 MAKE_CONTEXT(engine, ctx);
33
34 srn_value_t *name = srn_string_make(ctx, &absurd_metadata, "serene.tests");
36
38 // ns should has it's own context
39 TEST_CHECK(AS_NS(ns)->root_context != ctx);
40 TEST_CHECK(AS_NS(ns)->sym_table.len == 0);
41
42 TEST_CHECK(srn_string_eq(AS_NS(ns)->name, AS_STRING(name)));
43
44 RELEASE_CONTEXT(ctx);
45 SHUTDOWN_ENGINE(mm, engine);
46}
#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
@ VNamespace
Definition core.h:122
#define AS_STRING(value_ref)
Definition core.h:171
#define AS_NS(value_ref)
Definition core.h:170
#define IS_A(value_ref, field)
Definition core.h:162
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
bool srn_string_eq(const srn_string_t *a, const srn_string_t *b)
Definition strings.c:76
Here is the call graph for this function: