Skip to content

Commit

Permalink
feature: async case tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brewlin committed Sep 18, 2024
1 parent 90dc135 commit c31b2f0
Show file tree
Hide file tree
Showing 5 changed files with 601 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ release: install build-liba install
# NOTICE: don't use this
.PHONEY: release
dev_release: install
tuc run tulang.tu
tuc run tulang.tu
mv a.out release/tu
cp release/tu $(prefix)/bin/tu

Expand All @@ -100,7 +100,7 @@ test_dev:
@$(TEST_COMPILER); test_compiler
@echo "test compiler success"

cases = mixed class common datastruct internalpkg memory native operator runtime statement
cases = async mixed class common datastruct internalpkg memory native operator runtime statement

# make test -j9
tests_cases: $(cases)
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $ make tests
- [x] func,goto,class,mem
- [x] return,type,use,if,continue,break
- [x] while,for|range for,loop,match
- [ ] async await
- [x] async await

### @动态写法
更多用例请看`/tests`
Expand Down Expand Up @@ -124,7 +124,7 @@ enum {
mem Rbtree {
RbtreeNode* root
RbtreeNode* sentinel
u64 insert
u64 insert
}
mem RbtreeNode {
u64 key
Expand Down Expand Up @@ -156,5 +156,42 @@ Rbtree::find(hk<u64>){
}
fn main(){}
```
### @特性相关
async
```
use fmt
use runtime
use os

mem ReadStream: async {
i32 bytes
i32 readn
i32 fd
}
ReadStream::poll(){
if this.readn != this.bytes {
this.readn += 1
return runtime.PollPending
}
match this.fd {
1 : return runtime.PollReady , "hello "
2 : return runtime.PollReady , "world"
_ : os.die("")
}
}
async fn read(){
fut<ReadStream> = new ReadStream { fd: 1, bytes: 5}
buf += fut.await

fut2<ReadStream> = new ReadStream { fd: 2, bytes: 5}
buf += fut2.await
return buf
}

fn main(){
body = runtime.block(read())
fmt.println(body)
}
```
## License
Copyright @2016-2024 The tu-lang author. All rights reserved.
Binary file modified release/tu
Binary file not shown.
Binary file modified release/tulang.a
Binary file not shown.
Loading

0 comments on commit c31b2f0

Please sign in to comment.