Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
oovm committed Dec 12, 2023
1 parent d082a88 commit 06b8b7b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .run/Test All.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<option name="emulateTerminal" value="false" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
Expand Down
4 changes: 2 additions & 2 deletions projects/valkyrie-ast/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class B(A) { }

这个语言中这样定义代数效应

```
```vk
class Logging {
level: Integer
message: String
Expand All @@ -40,7 +40,7 @@ class Logging {

使用 raise 激发代数效应, 使用 try catch 语句处理代数效应.

```
```vk
try {
raise Logging::debug("hello")
}
Expand Down
4 changes: 2 additions & 2 deletions projects/valkyrie-ast/src/control_flow/loop_while/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ outer: loop {



```
```vk
// promotion local variable here!!
let outer_continue = || {
if c1 {
Expand Down Expand Up @@ -82,7 +82,7 @@ let outer_break = || {



```
```vk
// promotion local variable here!!
let outer_continue = || {
if c1 {
Expand Down
20 changes: 20 additions & 0 deletions projects/valkyrie-parser/tests/declaration/class.ron
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ DefineClass {
],
},
name: base1,
type: Base1,
},
Field {
annotations: Annotation {
Expand All @@ -60,6 +61,7 @@ DefineClass {
],
},
name: base2,
type: Base2,
},
Field {
annotations: Annotation {
Expand All @@ -68,6 +70,7 @@ DefineClass {
],
},
name: base3,
type: Base3,
},
],
span: 219..329,
Expand All @@ -77,9 +80,17 @@ DefineClass {
terms: [
Field {
name: item1,
type: UnaryNode {
prefix: !,
base: T,
},
},
Field {
name: item2,
type: UnaryNode {
prefix: !,
base: U,
},
},
],
span: 329..392,
Expand Down Expand Up @@ -289,6 +300,7 @@ DefineClass {
],
},
name: x_base,
type: XBase,
},
Field {
name: private,
Expand All @@ -303,6 +315,7 @@ DefineClass {
],
},
name: _y_base,
type: YBase,
},
Method {
name: constructor,
Expand Down Expand Up @@ -379,15 +392,19 @@ DefineClass {
],
},
name: type,
type: String,
default: 'item',
},
Field {
name: unknown_all,
},
Field {
name: default_value,
type: A,
},
Field {
name: infer_type,
default: null,
},
Method {
annotations: Annotation {
Expand Down Expand Up @@ -564,6 +581,7 @@ DefineClass {
],
},
name: field1,
type: u32,
},
Field {
annotations: Annotation {
Expand All @@ -572,6 +590,7 @@ DefineClass {
],
},
name: field 2,
type: f64,
},
Field {
annotations: Annotation {
Expand All @@ -590,6 +609,7 @@ DefineClass {
],
},
name: fields,
type: T,
},
Method {
annotations: Annotation {
Expand Down
1 change: 1 addition & 0 deletions projects/valkyrie-parser/tests/declaration/trait.ron
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Trait {
body: [
Field {
name: unit,
type: T,
},
],
}
Expand Down
27 changes: 27 additions & 0 deletions projects/valkyrie-parser/tests/declaration/union.ron
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Union {
body: [
Field {
name: value,
type: T,
},
],
},
Expand All @@ -197,6 +198,7 @@ Union {
body: [
Field {
name: value,
type: V,
},
],
},
Expand All @@ -205,6 +207,7 @@ Union {
body: [
Field {
name: error,
type: E,
},
],
},
Expand All @@ -219,9 +222,21 @@ Union {
body: [
Field {
name: value,
type: T,
},
Field {
name: errors,
type: GenericCallNode {
monadic: false,
base: List,
term: [
ArgumentTerm {
key: Nothing,
value: E,
},
],
span: 1019..1026,
},
},
],
},
Expand All @@ -230,9 +245,21 @@ Union {
body: [
Field {
name: fatal,
type: E,
},
Field {
name: errors,
type: GenericCallNode {
monadic: false,
base: List,
term: [
ArgumentTerm {
key: Nothing,
value: E,
},
],
span: 1083..1090,
},
},
],
},
Expand Down
54 changes: 0 additions & 54 deletions projects/valkyrie-parser/tests/tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,55 +1 @@
mod declaration;
mod expression;
mod literal;
mod statement;

use std::{
fs::File,
io::Write as _,
path::{Path, PathBuf},
};
use valkyrie_antlr::ValkyrieProgramParser;
use valkyrie_ast::helper::{Lispify, PrettyPrint, PrettyProvider};
#[test]
fn ready() {
println!("it works!")
}

fn here() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests").canonicalize().expect("failed to get manifest dir")
}

pub fn pretty_print<T: PrettyPrint>(value: &T) {
let arena = PrettyProvider::new(80);
println!("{}", value.pretty_colorful(&arena));
}

fn top_debug(text: &str, output: &str) -> std::io::Result<()> {
let mut file = File::create(here().join(output))?;
let apply = ValkyrieProgramParser::parse(text).unwrap();
let theme = PrettyProvider::new(128);
for expr in &apply.statements {
println!("=================================================================");
pretty_print(expr);
let text = expr.pretty_colorful(&theme);
let lisp = expr.lispify();
writeln!(file, "{}", lisp.pretty_string(&theme))?;
println!("{}", lisp.pretty_colorful(&theme));
}
Ok(())
}

fn repl_debug(text: &str, output: &str) -> std::io::Result<()> {
let mut file = File::create(here().join(output))?;
let apply = ValkyrieProgramParser::parse(text).unwrap();
let mut theme = PrettyProvider::new(128);
for expr in &apply.statements {
println!("=================================================================");
pretty_print(expr);
let text = expr.pretty_colorful(&theme);
let lisp = expr.lispify();
writeln!(file, "{}", lisp.pretty_string(&theme))?;
println!("{}", lisp.pretty_colorful(&theme));
}
Ok(())
}
39 changes: 0 additions & 39 deletions projects/valkyrie-types/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,13 @@ fn ready() {
println!("it works!")
}

#[test]
fn test_primitive() {
let value: usize = 0;
assert_type(value, "Unsigned64", "std::primitive::Unsigned64");
let value: f64 = 0.0;
assert_type(value, "Float64", "std::primitive::Float64");
}

#[test]
fn test_list_index() {
let out = ValkyrieList::from_iter(vec!['1', '2', '3', '4', '5', '6', '7', '8', '9']);
println!("1: {:?}", out.get_ordinal(1));
println!("2: {:?}", out.get_ordinal(-1));
println!("2: {:?}", out.get_range(1, -1, 1).collect::<Vec<_>>());
}
#[test]
fn test_list() {
let value: Vec<usize> = vec![];
assert_type(value, "List[Unsigned64]", "std::collection::List[std::primitive::Unsigned64]");
// let value: Option<usize> = None;
// assert_type(value, "Option[u64]", "std::primitive::Option[std::primitive::u64]");
// let value: Option<Option<usize>> = Some(None);
// assert_type(value, "Option[Option[u64]]", "std::primitive::Option[std::primitive::Option]");
}

#[test]
fn test_tuple() {
let value: (u8, u16, u32, u64) = (0, 0, 0, 0);
assert_type(
value,
"Tuple[Unsigned8, Unsigned16, Unsigned32, Unsigned64]",
"std::primitive::Tuple[std::primitive::Unsigned8, std::primitive::Unsigned16, std::primitive::Unsigned32, std::primitive::Unsigned64]",
);
// let value: Option<Option<usize>> = Some(None);
// assert_type(value, "Option[Option[u64]]", "std::primitive::Option[std::primitive::Option]");
}

pub fn check_raw(list: &[u32]) -> bool {
for i in list {
Expand Down Expand Up @@ -134,13 +105,3 @@ fn test() {
println!("RAW: {}", check_raw(&list));
println!("FSM: {}", check_fsm(&list));
}

#[test]
fn test222() {
let id = ValkyrieID::new(["std", "display", "Show"].iter().map(|s| s.to_string()));
let t = ValkyrieInterface::new(id);
println!("{:#?}", t);
println!("{:?}", t.name());
println!("{:?}", t.namespace());
println!("{:?}", t.full_name());
}

0 comments on commit 06b8b7b

Please sign in to comment.