-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
203 changed files
with
169 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
# Trc | ||
# Trc programming language | ||
|
||
## Trc is a stack-based programming language | ||
|
||
Trc's syntax is easy,and have full toolchain. It is easy to learn modern c++ and compiler,too. | ||
|
||
## language | ||
|
||
100% C++ | ||
|
||
Using c++ 20 standard and use module feature | ||
|
||
But here is a developing ```rust``` instance now! | ||
|
||
[rust_trc](rust/) | ||
Trc is a easy-learn programming language.It can be fast,safe and effective. | ||
|
||
## Goal | ||
|
||
|
@@ -22,22 +10,16 @@ But here is a developing ```rust``` instance now! | |
|
||
**as small as lua** | ||
|
||
## project website | ||
|
||
[Gitee](https://gitee.com/li-muyangangel/trc.git) | ||
[GitHub](https://github.com/limuy2022/trc.git) | ||
there are two ways to use it: | ||
|
||
## All docs reference | ||
[c++ version](./cpp/) | ||
[rust version](./rust/) | ||
|
||
[All docs](doc) | ||
|
||
## How to compile | ||
|
||
[Compilation guide](doc/developer/build.md) | ||
They have their own adventages.You can choose by your preference. | ||
|
||
## International | ||
|
||
trc support many languages,the way to change language is that uses the language's dynamic linked library to replace the original language library | ||
Trc supports many different kinds of languages.We use GNU gettext.So it dont't need change the language by hand. | ||
|
||
## Simple examples | ||
|
||
|
@@ -73,7 +55,10 @@ del "c" | |
println(a * b) | ||
``` | ||
|
||
[more example](tests/black_test/program) | ||
## project website | ||
|
||
[Gitee](https://gitee.com/li-muyangangel/trc.git) | ||
[GitHub](https://github.com/limuy2022/trc.git) | ||
|
||
## Contact author | ||
|
||
|
@@ -82,11 +67,3 @@ Wechat:angelgel2020 | |
QQ:3570249647 | ||
|
||
email: ```[email protected]``` | ||
|
||
## Referenced Open-source software | ||
|
||
| Library |Usage | | ||
|:-----------|:-------| | ||
| googletest | Unittest | | ||
|
||
Express my thanks to Open-source software contributors! |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Trc | ||
|
||
## language | ||
|
||
100% C++ | ||
|
||
Using c++ 20 standard and use module feature | ||
|
||
## All docs reference | ||
|
||
[All docs](doc) | ||
|
||
## How to compile | ||
|
||
[Compilation guide](doc/developer/build.md) | ||
|
||
## Referenced Open-source software | ||
|
||
| Library |Usage | | ||
|:-----------|:-------| | ||
| googletest | Unittest | | ||
|
||
Express my thanks to Open-source software contributors! |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
110 changes: 55 additions & 55 deletions
110
tests/unittest/base/test_filesys.cpp → cpp/tests/unittest/base/test_filesys.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
/** | ||
* @file test_filesys.cpp | ||
* @brief 测试filesys模块 | ||
* @date 2022-05-03 | ||
* | ||
* @copyright Copyright (c) 2022 | ||
* | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include <list> | ||
#include <string> | ||
import filesys; | ||
import filesys_tools; | ||
|
||
using namespace trc; | ||
|
||
static void test_readfile(const char* path, const char* expect) { | ||
std::string filedata; | ||
utils::readcode(filedata, tools::redefine_path(path)); | ||
EXPECT_STREQ(filedata.c_str(), expect); | ||
} | ||
|
||
// 测试读取文件的函数 | ||
TEST(filesys, readfile) { | ||
// 测试读取多行文件 | ||
test_readfile("filesys/readfile/readwithlines.in", | ||
"\n\n\nreadwithlines\n\nreadwithlines\n"); | ||
// 测试读取空文件 | ||
test_readfile("filesys/readfile/readempty.in", ""); | ||
// 测试读取英文文件 | ||
test_readfile("filesys/readfile/readenglish.in", | ||
"abcd\nefgh\nijkl\nmnop\nqrst\nuvwx\nyz\n"); | ||
// 测试读取中文文件 | ||
test_readfile("filesys/readfile/readchinese.in", | ||
"生活就像海洋,只有意志坚强的人才能到达彼岸\n"); | ||
std::string filedata; | ||
// 测试读取不存在文件 | ||
EXPECT_EQ(1, | ||
utils::readcode_with_code( | ||
filedata, tools::redefine_path("filesys/readfile/failtoread"))); | ||
// 测试成功读取文件 | ||
filedata.clear(); | ||
EXPECT_EQ(0, | ||
utils::readcode_with_code( | ||
filedata, tools::redefine_path("filesys/readfile/readenglish.in"))); | ||
// 测试读取超大文件 | ||
std::string expect_big_data; | ||
char basestr[] = "pppppppppppp\n"; | ||
expect_big_data.reserve(sizeof(basestr) * 10240); | ||
for (int i = 0; i < 10240; ++i) { | ||
expect_big_data += basestr; | ||
} | ||
test_readfile("filesys/readfile/readlonglong.in", expect_big_data.c_str()); | ||
} | ||
/** | ||
* @file test_filesys.cpp | ||
* @brief 测试filesys模块 | ||
* @date 2022-05-03 | ||
* | ||
* @copyright Copyright (c) 2022 | ||
* | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include <list> | ||
#include <string> | ||
import filesys; | ||
import filesys_tools; | ||
|
||
using namespace trc; | ||
|
||
static void test_readfile(const char* path, const char* expect) { | ||
std::string filedata; | ||
utils::readcode(filedata, tools::redefine_path(path)); | ||
EXPECT_STREQ(filedata.c_str(), expect); | ||
} | ||
|
||
// 测试读取文件的函数 | ||
TEST(filesys, readfile) { | ||
// 测试读取多行文件 | ||
test_readfile("filesys/readfile/readwithlines.in", | ||
"\n\n\nreadwithlines\n\nreadwithlines\n"); | ||
// 测试读取空文件 | ||
test_readfile("filesys/readfile/readempty.in", ""); | ||
// 测试读取英文文件 | ||
test_readfile("filesys/readfile/readenglish.in", | ||
"abcd\nefgh\nijkl\nmnop\nqrst\nuvwx\nyz\n"); | ||
// 测试读取中文文件 | ||
test_readfile("filesys/readfile/readchinese.in", | ||
"生活就像海洋,只有意志坚强的人才能到达彼岸\n"); | ||
std::string filedata; | ||
// 测试读取不存在文件 | ||
EXPECT_EQ(1, | ||
utils::readcode_with_code( | ||
filedata, tools::redefine_path("filesys/readfile/failtoread"))); | ||
// 测试成功读取文件 | ||
filedata.clear(); | ||
EXPECT_EQ(0, | ||
utils::readcode_with_code( | ||
filedata, tools::redefine_path("filesys/readfile/readenglish.in"))); | ||
// 测试读取超大文件 | ||
std::string expect_big_data; | ||
char basestr[] = "pppppppppppp\n"; | ||
expect_big_data.reserve(sizeof(basestr) * 10240); | ||
for (int i = 0; i < 10240; ++i) { | ||
expect_big_data += basestr; | ||
} | ||
test_readfile("filesys/readfile/readlonglong.in", expect_big_data.c_str()); | ||
} |
86 changes: 43 additions & 43 deletions
86
tests/unittest/base/test_io.cpp → cpp/tests/unittest/base/test_io.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
/** | ||
* 测试自己封装的io库 | ||
*/ | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <gtest/gtest.h> | ||
#include <string> | ||
#include <vector> | ||
import io; | ||
import filesys_tools; | ||
|
||
using namespace trc; | ||
|
||
static void check_readstr( | ||
const char* path, const std::vector<const char*>& expectstr) { | ||
FILE* file | ||
= tools::fopen_with_check(tools::redefine_path(path).c_str(), "r"); | ||
char* raw_str; | ||
// -1是为了避开最后一个false(eof)值 | ||
for (size_t i = 0, n = expectstr.size(); i < n - 1; ++i) { | ||
EXPECT_TRUE(io::readstr(raw_str, file)); | ||
EXPECT_STREQ(raw_str, expectstr[i]); | ||
free(raw_str); | ||
} | ||
io::readstr(raw_str, file); | ||
EXPECT_STREQ(raw_str, expectstr.back()); | ||
free(raw_str); | ||
fclose(file); | ||
} | ||
|
||
// 测试字符串读入 | ||
TEST(io, readstr) { | ||
// 测试普通正常多行文件 | ||
check_readstr("io/readstr1.in", { "abcdef", "opiuy", "pploi" }); | ||
// 测试结尾不为换行符的文件 | ||
check_readstr("io/readstr_eof.in", { "io", "ploip" }); | ||
// 测试空文件读入 | ||
check_readstr("io/readstr_empty.in", { "" }); | ||
// 测试长字符串读入 | ||
check_readstr("io/readstr_long.in", | ||
{ std::string(120, 'u').c_str(), std::string(120, 'v').c_str() }); | ||
} | ||
/** | ||
* 测试自己封装的io库 | ||
*/ | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <gtest/gtest.h> | ||
#include <string> | ||
#include <vector> | ||
import io; | ||
import filesys_tools; | ||
|
||
using namespace trc; | ||
|
||
static void check_readstr( | ||
const char* path, const std::vector<const char*>& expectstr) { | ||
FILE* file | ||
= tools::fopen_with_check(tools::redefine_path(path).c_str(), "r"); | ||
char* raw_str; | ||
// -1是为了避开最后一个false(eof)值 | ||
for (size_t i = 0, n = expectstr.size(); i < n - 1; ++i) { | ||
EXPECT_TRUE(io::readstr(raw_str, file)); | ||
EXPECT_STREQ(raw_str, expectstr[i]); | ||
free(raw_str); | ||
} | ||
io::readstr(raw_str, file); | ||
EXPECT_STREQ(raw_str, expectstr.back()); | ||
free(raw_str); | ||
fclose(file); | ||
} | ||
|
||
// 测试字符串读入 | ||
TEST(io, readstr) { | ||
// 测试普通正常多行文件 | ||
check_readstr("io/readstr1.in", { "abcdef", "opiuy", "pploi" }); | ||
// 测试结尾不为换行符的文件 | ||
check_readstr("io/readstr_eof.in", { "io", "ploip" }); | ||
// 测试空文件读入 | ||
check_readstr("io/readstr_empty.in", { "" }); | ||
// 测试长字符串读入 | ||
check_readstr("io/readstr_long.in", | ||
{ std::string(120, 'u').c_str(), std::string(120, 'v').c_str() }); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.