Skip to content

Commit d4bc051

Browse files
committed
Corrected misspelling in scripts, we need error handling to catch this easily...
1 parent 4baa356 commit d4bc051

File tree

6 files changed

+269
-8
lines changed

6 files changed

+269
-8
lines changed

source/loaders/ts_loader/bootstrap/lib/test/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const inspect = (handle, equal = assert.notDeepStrictEqual) => {
2828

2929
// Test load from memory
3030
inspect(load_from_memory('memory_module', `
31-
export function mem_sum(left: number, rigth: number): number {
32-
return left + rigth;
31+
export function mem_sum(left: number, right: number): number {
32+
return left + right;
3333
}
34-
export async function mem_sum_async(left: number, rigth: number): number {
35-
return left + rigth;
34+
export async function mem_sum_async(left: number, right: number): number {
35+
return left + right;
3636
}
3737
`, {}));
3838

source/scripts/typescript/typedfunc/source/typedfunc.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22

3-
export function typed_sum(left: number, rigth: number): number {
4-
return left + rigth;
3+
export function typed_sum(left: number, right: number): number {
4+
return left + right;
55
}
66

7-
export async function typed_sum_async(left: number, rigth: number): Promise<number> {
8-
return left + rigth;
7+
export async function typed_sum_async(left: number, right: number): Promise<number> {
8+
return left + right;
99
}
1010

1111
export function build_name(first: string, last = 'Smith') {

source/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ add_subdirectory(metacall_file_test)
184184
add_subdirectory(metacall_file_fail_test)
185185
add_subdirectory(metacall_typescript_test)
186186
add_subdirectory(metacall_typescript_node_test)
187+
add_subdirectory(metacall_typescript_call_map_test)
187188
#add_subdirectory(metacall_typescript_tsx_test) # TODO: Download react dependencies locally instead of globally
188189
add_subdirectory(metacall_lua_test)
189190
add_subdirectory(metacall_rpc_test)
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Check if this loader is enabled
2+
if(NOT OPTION_BUILD_LOADERS OR NOT OPTION_BUILD_LOADERS_NODE OR NOT OPTION_BUILD_LOADERS_TS
3+
OR NOT OPTION_BUILD_SCRIPTS OR NOT OPTION_BUILD_SCRIPTS_NODE OR NOT OPTION_BUILD_SCRIPTS_TS)
4+
return()
5+
endif()
6+
7+
#
8+
# Executable name and options
9+
#
10+
11+
# Target name
12+
set(target metacall-typescript-call-map-test)
13+
message(STATUS "Test ${target}")
14+
15+
#
16+
# Compiler warnings
17+
#
18+
19+
include(Warnings)
20+
21+
#
22+
# Compiler security
23+
#
24+
25+
include(SecurityFlags)
26+
27+
#
28+
# Sources
29+
#
30+
31+
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
32+
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
33+
34+
set(sources
35+
${source_path}/main.cpp
36+
${source_path}/metacall_typescript_call_map_test.cpp
37+
)
38+
39+
# Group source files
40+
set(header_group "Header Files (API)")
41+
set(source_group "Source Files")
42+
source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
43+
${header_group} ${headers})
44+
source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$"
45+
${source_group} ${sources})
46+
47+
#
48+
# Create executable
49+
#
50+
51+
# Build executable
52+
add_executable(${target}
53+
${sources}
54+
)
55+
56+
# Create namespaced alias
57+
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
58+
59+
#
60+
# Project options
61+
#
62+
63+
set_target_properties(${target}
64+
PROPERTIES
65+
${DEFAULT_PROJECT_OPTIONS}
66+
FOLDER "${IDE_FOLDER}"
67+
)
68+
69+
#
70+
# Include directories
71+
#
72+
73+
target_include_directories(${target}
74+
PRIVATE
75+
${DEFAULT_INCLUDE_DIRECTORIES}
76+
${PROJECT_BINARY_DIR}/source/include
77+
)
78+
79+
#
80+
# Libraries
81+
#
82+
83+
target_link_libraries(${target}
84+
PRIVATE
85+
${DEFAULT_LIBRARIES}
86+
87+
GTest
88+
89+
${META_PROJECT_NAME}::metacall
90+
)
91+
92+
#
93+
# Compile definitions
94+
#
95+
96+
target_compile_definitions(${target}
97+
PRIVATE
98+
${DEFAULT_COMPILE_DEFINITIONS}
99+
)
100+
101+
#
102+
# Compile options
103+
#
104+
105+
target_compile_options(${target}
106+
PRIVATE
107+
${DEFAULT_COMPILE_OPTIONS}
108+
)
109+
110+
#
111+
# Linker options
112+
#
113+
114+
target_link_libraries(${target}
115+
PRIVATE
116+
${DEFAULT_LINKER_OPTIONS}
117+
)
118+
119+
#
120+
# Define test
121+
#
122+
123+
add_test(NAME ${target}
124+
COMMAND $<TARGET_FILE:${target}>
125+
)
126+
127+
#
128+
# Define dependencies
129+
#
130+
131+
add_dependencies(${target}
132+
node_loader
133+
ts_loader
134+
)
135+
136+
#
137+
# Define test properties
138+
#
139+
140+
set_property(TEST ${target}
141+
PROPERTY LABELS ${target}
142+
)
143+
144+
include(TestEnvironmentVariables)
145+
146+
test_environment_variables(${target}
147+
""
148+
${TESTS_ENVIRONMENT_VARIABLES}
149+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* MetaCall Library by Parra Studios
3+
* A library for providing a foreign function interface calls.
4+
*
5+
* Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
#include <gtest/gtest.h>
22+
23+
int main(int argc, char *argv[])
24+
{
25+
::testing::InitGoogleTest(&argc, argv);
26+
27+
return RUN_ALL_TESTS();
28+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* MetaCall Library by Parra Studios
3+
* A library for providing a foreign function interface calls.
4+
*
5+
* Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
#include <gtest/gtest.h>
22+
23+
#include <metacall/metacall.h>
24+
#include <metacall/metacall_loaders.h>
25+
#include <metacall/metacall_value.h>
26+
27+
class metacall_typescript_call_map_test : public testing::Test
28+
{
29+
public:
30+
};
31+
32+
TEST_F(metacall_typescript_call_map_test, DefaultConstructor)
33+
{
34+
metacall_print_info();
35+
36+
ASSERT_EQ((int)0, (int)metacall_initialize());
37+
38+
struct metacall_allocator_std_type std_ctx = { &std::malloc, &std::realloc, &std::free };
39+
40+
void *allocator = metacall_allocator_create(METACALL_ALLOCATOR_STD, (void *)&std_ctx);
41+
42+
/* TypeScript */
43+
#if defined(OPTION_BUILD_LOADERS_TS)
44+
{
45+
const char *ts_scripts[] = {
46+
"typedfunc.ts"
47+
};
48+
49+
/* Load scripts */
50+
EXPECT_EQ((int)0, (int)metacall_load_from_file("ts", ts_scripts, sizeof(ts_scripts) / sizeof(ts_scripts[0]), NULL));
51+
52+
/* Test typed sum */
53+
static const char args_map[] = "{\"left\":10,\"right\":2}";
54+
55+
void *ret = metacallfms(metacall_function("typed_sum"), args_map, sizeof(args_map), allocator);
56+
57+
EXPECT_NE((void *)NULL, (void *)ret);
58+
59+
EXPECT_EQ((double)metacall_value_to_double(ret), (double)12.0);
60+
61+
metacall_value_destroy(ret);
62+
}
63+
#endif /* OPTION_BUILD_LOADERS_TS */
64+
65+
/* Print inspect information */
66+
{
67+
size_t size = 0;
68+
69+
char *inspect_str = metacall_inspect(&size, allocator);
70+
71+
EXPECT_NE((char *)NULL, (char *)inspect_str);
72+
73+
EXPECT_GT((size_t)size, (size_t)0);
74+
75+
std::cout << inspect_str << std::endl;
76+
77+
metacall_allocator_free(allocator, inspect_str);
78+
}
79+
80+
metacall_allocator_destroy(allocator);
81+
82+
EXPECT_EQ((int)0, (int)metacall_destroy());
83+
}

0 commit comments

Comments
 (0)