Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 4b9639b

Browse files
committed
move tests under tests/ dir
1 parent 7d567e8 commit 4b9639b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1067
-1193
lines changed

api.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,3 @@ namespace lib_ruby_parser
2020
into_blob<ParserOptions, ParserOptionsBlob>(std::move(options))));
2121
}
2222
}
23-
24-
#ifdef TEST_ENV
25-
26-
#include "test_helper.hpp"
27-
28-
namespace lib_ruby_parser
29-
{
30-
static void test_parse(void)
31-
{
32-
annotate_test;
33-
34-
ParserOptions options(
35-
String::Copied("(eval)"),
36-
MaybeDecoder(Decoder(nullptr, nullptr)),
37-
MaybeTokenRewriter(TokenRewriter(nullptr)),
38-
true);
39-
40-
ByteList input = ByteList::Copied("2 + 3", 5);
41-
42-
ParserResult result = parse(
43-
std::move(input),
44-
std::move(options));
45-
46-
assert_eq(result.ast->tag, Node::Tag::SEND);
47-
assert_eq(result.tokens.len, 4); // tINT tPLUS tINT EOF
48-
assert_eq(result.comments.len, 0);
49-
assert_eq(result.magic_comments.len, 0);
50-
assert_byte_list(result.input.bytes, "2 + 3");
51-
}
52-
53-
void run_test_group_api(void)
54-
{
55-
const test_fn_t tests[] = {
56-
test_parse,
57-
};
58-
59-
run_tests_as_group("api", tests, sizeof(tests) / sizeof(test_fn_t));
60-
}
61-
}
62-
63-
#endif

api.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ namespace lib_ruby_parser
99
/// Parses given `input` according to `option`.
1010
/// This is the main entrypoint API.
1111
ParserResult parse(ByteList input, ParserOptions options);
12-
13-
#ifdef TEST_ENV
14-
void run_test_group_api(void);
15-
#endif
1612
} // namespace lib_ruby_parser
1713

1814
#endif // LIB_RUBY_PARSER_API_HPP

bytes.cpp

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -27,71 +27,3 @@ namespace lib_ruby_parser
2727

2828
Bytes::Bytes(ByteList raw_) : raw(std::move(raw_)) {}
2929
} // namespace lib_ruby_parser
30-
31-
#ifdef TEST_ENV
32-
33-
#include "test_helper.hpp"
34-
#include <cstdlib>
35-
#include <iostream>
36-
37-
namespace lib_ruby_parser
38-
{
39-
extern "C"
40-
{
41-
ByteListBlob lib_ruby_parser__test__make_byte_list(char i1, char i2, char i3);
42-
}
43-
44-
static void test_byte_list_fields(void)
45-
{
46-
annotate_test;
47-
48-
ByteList byte_list = from_blob<ByteListBlob, ByteList>(
49-
lib_ruby_parser__test__make_byte_list('1', '2', '3'));
50-
assert_byte_list(byte_list, "123");
51-
52-
ByteList moved = std::move(byte_list);
53-
}
54-
55-
static void test_byte_list_constructors(void)
56-
{
57-
annotate_test;
58-
59-
char *owned = static_cast<char *>(malloc(4));
60-
owned[0] = '1';
61-
owned[1] = '2';
62-
owned[2] = '3';
63-
owned[3] = '4';
64-
ByteList byte_list_owned = ByteList::Owned(owned, 4);
65-
assert_byte_list(byte_list_owned, "1234");
66-
67-
ByteList byte_list_coped = ByteList::Copied("56789", 5);
68-
assert_byte_list(byte_list_coped, "56789");
69-
}
70-
71-
extern "C"
72-
{
73-
BytesBlob lib_ruby_parser__test__make_bytes(char i1, char i2, char i3);
74-
}
75-
static void test_bytes_fields(void)
76-
{
77-
annotate_test;
78-
79-
Bytes bytes = from_blob<BytesBlob, Bytes>(
80-
lib_ruby_parser__test__make_bytes('a', 'b', 'c'));
81-
assert_byte_list(bytes.raw, "abc");
82-
}
83-
84-
void run_test_group_bytes(void)
85-
{
86-
const test_fn_t tests[] = {
87-
test_byte_list_fields,
88-
test_byte_list_constructors,
89-
test_bytes_fields,
90-
};
91-
92-
run_tests_as_group("bytes", tests, sizeof(tests) / sizeof(test_fn_t));
93-
}
94-
95-
}
96-
97-
#endif

bytes.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ namespace lib_ruby_parser
4848
Bytes(Bytes &&) = default;
4949
Bytes &operator=(Bytes &&) = default;
5050
};
51-
52-
#ifdef TEST_ENV
53-
void run_test_group_bytes(void);
54-
#endif
55-
5651
} // namespace lib_ruby_parser
5752

5853
#endif // LIB_RUBY_PARSER_BYTES_HPP

comment.cpp

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,78 +15,3 @@ namespace lib_ruby_parser
1515

1616
LIST_IMPL(CommentList, Comment, LIB_RUBY_PARSER_drop_comment_list);
1717
} // namespace lib_ruby_parser
18-
19-
#ifdef TEST_ENV
20-
21-
#include "test_helper.hpp"
22-
23-
namespace lib_ruby_parser
24-
{
25-
extern "C"
26-
{
27-
CommentType lib_ruby_parser__test__make_comment_type_document(void);
28-
CommentType lib_ruby_parser__test__make_comment_type_inline(void);
29-
CommentType lib_ruby_parser__test__make_comment_type_unknown(void);
30-
}
31-
static void test_comment_type_options(void)
32-
{
33-
annotate_test;
34-
35-
CommentType comment_type;
36-
37-
comment_type = lib_ruby_parser__test__make_comment_type_document();
38-
assert_eq(comment_type, CommentType::DOCUMENT);
39-
40-
comment_type = lib_ruby_parser__test__make_comment_type_inline();
41-
assert_eq(comment_type, CommentType::INLINE);
42-
43-
comment_type = lib_ruby_parser__test__make_comment_type_unknown();
44-
assert_eq(comment_type, CommentType::UNKNOWN);
45-
}
46-
47-
extern "C"
48-
{
49-
CommentBlob lib_ruby_parser__test__make_comment(LocBlob location, CommentTypeBlob kind);
50-
}
51-
static void test_comment_fields(void)
52-
{
53-
annotate_test;
54-
55-
Comment comment = from_blob<CommentBlob, Comment>(
56-
lib_ruby_parser__test__make_comment(
57-
into_blob<Loc, LocBlob>(Loc(1, 2)),
58-
into_blob<CommentType, CommentTypeBlob>(CommentType::INLINE)));
59-
60-
assert_comment(comment, Loc(1, 2), CommentType::INLINE);
61-
}
62-
63-
extern "C"
64-
{
65-
CommentListBlob lib_ruby_parser__test__make_comment_list(CommentBlob comment);
66-
}
67-
static void test_comment_list_fields(void)
68-
{
69-
annotate_test;
70-
71-
CommentList comment_list = from_blob<CommentListBlob, CommentList>(
72-
lib_ruby_parser__test__make_comment_list(
73-
lib_ruby_parser__test__make_comment(
74-
into_blob<Loc, LocBlob>(Loc(1, 2)),
75-
into_blob<CommentType, CommentTypeBlob>(CommentType::INLINE))));
76-
assert_eq(comment_list.len, 1);
77-
assert_comment(comment_list.ptr[0], Loc(1, 2), CommentType::INLINE);
78-
}
79-
80-
void run_test_group_comment(void)
81-
{
82-
const test_fn_t tests[] = {
83-
test_comment_type_options,
84-
test_comment_fields,
85-
test_comment_list_fields,
86-
};
87-
88-
run_tests_as_group("comment", tests, sizeof(tests) / sizeof(test_fn_t));
89-
}
90-
}
91-
92-
#endif

comment.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ namespace lib_ruby_parser
5252
CommentList(CommentList &&);
5353
CommentList &operator=(CommentList &&);
5454
};
55-
56-
#ifdef TEST_ENV
57-
void run_test_group_comment(void);
58-
#endif
5955
} // namespace lib_ruby_parser
6056

6157
#endif // LIB_RUBY_PARSER_COMMENT_HPP

decoded_input.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,3 @@ namespace lib_ruby_parser
1212
lines(std::move(lines_)),
1313
bytes(std::move(bytes_)) {}
1414
}
15-
16-
#ifdef TEST_ENV
17-
18-
#include "test_helper.hpp"
19-
20-
namespace lib_ruby_parser
21-
{
22-
extern "C"
23-
{
24-
DecodedInputBlob lib_ruby_parser__test__make_decoded_input(void);
25-
}
26-
static void test_decoded_input(void)
27-
{
28-
annotate_test;
29-
30-
DecodedInput decoded_input = from_blob<DecodedInputBlob, DecodedInput>(
31-
lib_ruby_parser__test__make_decoded_input());
32-
33-
assert_string_eq(decoded_input.name, "(eval)");
34-
assert_eq(decoded_input.lines.len, 1);
35-
assert_source_line(decoded_input.lines.ptr[0], 10, 20, false);
36-
assert_byte_list(decoded_input.bytes, "2 + 2");
37-
}
38-
39-
void run_test_group_decoded_input(void)
40-
{
41-
const test_fn_t tests[] = {
42-
test_decoded_input,
43-
};
44-
45-
run_tests_as_group("decoded_input", tests, sizeof(tests) / sizeof(test_fn_t));
46-
}
47-
}
48-
49-
#endif

decoded_input.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ namespace lib_ruby_parser
2424
DecodedInput(DecodedInput &&) = default;
2525
DecodedInput &operator=(DecodedInput &&) = default;
2626
};
27-
28-
#ifdef TEST_ENV
29-
void run_test_group_decoded_input(void);
30-
#endif
3127
} // namespace lib_ruby_parser
3228

3329
#endif // LIB_RUBY_PARSER_DECODED_INPUT_HPP

0 commit comments

Comments
 (0)