Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
Signed-off-by: xiarui.xr <[email protected]>
  • Loading branch information
amyXia1994 committed Oct 19, 2023
1 parent a4f6be2 commit bd0cc53
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kclvm/ast_pretty/src/test_data/type_alias.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Color = "Red"|"Yellow"|"Blue"
type Color = "Red" | "Yellow" | "Blue"
colorRed: Color = "Red"
colorYellow: Color = "Yellow"
colorBlue: Color = "Blue"
Expand Down
4 changes: 2 additions & 2 deletions kclvm/parser/src/parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ fn test_type_str() {

check_type_str(
r####"bool | True | int | str|str"####,
expect![[r#"bool|True|int|str|str"#]],
expect![[r#"bool | True | int | str | str"#]],
);
check_type_str(
r####"[ [{str: float}] | int]"####,
expect![[r#"[[{str:float}]|int]"#]],
expect![[r#"[[{str:float}] | int]"#]],
);
}

Expand Down
2 changes: 1 addition & 1 deletion kclvm/parser/testdata/type-01.k.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"filename":"type-01.k","pkg":"__main__","doc":"","name":"__main__","body":[{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"a","filename":"type-01.k","line":1,"column":5,"end_line":1,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":1,"column":5,"end_line":1,"end_column":6},"type_value":{"node":"any","filename":"type-01.k","line":1,"column":9,"end_line":1,"end_column":12},"ty":{"node":"Any","filename":"type-01.k","line":1,"column":9,"end_line":1,"end_column":12}}},"filename":"type-01.k","line":1,"column":5,"end_line":1,"end_column":12},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"b","filename":"type-01.k","line":3,"column":5,"end_line":3,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":3,"column":5,"end_line":3,"end_column":6},"type_value":{"node":"bool","filename":"type-01.k","line":3,"column":9,"end_line":3,"end_column":13},"ty":{"node":{"Basic":"Bool"},"filename":"type-01.k","line":3,"column":9,"end_line":3,"end_column":13}}},"filename":"type-01.k","line":3,"column":5,"end_line":3,"end_column":13},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"c","filename":"type-01.k","line":4,"column":5,"end_line":4,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":4,"column":5,"end_line":4,"end_column":6},"type_value":{"node":"int","filename":"type-01.k","line":4,"column":9,"end_line":4,"end_column":12},"ty":{"node":{"Basic":"Int"},"filename":"type-01.k","line":4,"column":9,"end_line":4,"end_column":12}}},"filename":"type-01.k","line":4,"column":5,"end_line":4,"end_column":12},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"d","filename":"type-01.k","line":5,"column":5,"end_line":5,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":5,"column":5,"end_line":5,"end_column":6},"type_value":{"node":"float","filename":"type-01.k","line":5,"column":9,"end_line":5,"end_column":14},"ty":{"node":{"Basic":"Float"},"filename":"type-01.k","line":5,"column":9,"end_line":5,"end_column":14}}},"filename":"type-01.k","line":5,"column":5,"end_line":5,"end_column":14},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"e","filename":"type-01.k","line":6,"column":5,"end_line":6,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":6,"column":5,"end_line":6,"end_column":6},"type_value":{"node":"str","filename":"type-01.k","line":6,"column":9,"end_line":6,"end_column":12},"ty":{"node":{"Basic":"Str"},"filename":"type-01.k","line":6,"column":9,"end_line":6,"end_column":12}}},"filename":"type-01.k","line":6,"column":5,"end_line":6,"end_column":12},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"type_list1","filename":"type-01.k","line":8,"column":5,"end_line":8,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":8,"column":5,"end_line":8,"end_column":15},"type_value":{"node":"[]","filename":"type-01.k","line":8,"column":18,"end_line":8,"end_column":20},"ty":{"node":{"List":{"inner_type":null}},"filename":"type-01.k","line":8,"column":18,"end_line":8,"end_column":20}}},"filename":"type-01.k","line":8,"column":5,"end_line":8,"end_column":20},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"type_list2","filename":"type-01.k","line":9,"column":5,"end_line":9,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":9,"column":5,"end_line":9,"end_column":15},"type_value":{"node":"[[]]","filename":"type-01.k","line":9,"column":18,"end_line":9,"end_column":22},"ty":{"node":{"List":{"inner_type":{"node":{"List":{"inner_type":null}},"filename":"type-01.k","line":9,"column":19,"end_line":9,"end_column":21}}},"filename":"type-01.k","line":9,"column":18,"end_line":9,"end_column":22}}},"filename":"type-01.k","line":9,"column":5,"end_line":9,"end_column":22},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"type_list3","filename":"type-01.k","line":10,"column":5,"end_line":10,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":10,"column":5,"end_line":10,"end_column":15},"type_value":{"node":"[int]","filename":"type-01.k","line":10,"column":18,"end_line":10,"end_column":23},"ty":{"node":{"List":{"inner_type":{"node":{"Basic":"Int"},"filename":"type-01.k","line":10,"column":19,"end_line":10,"end_column":22}}},"filename":"type-01.k","line":10,"column":18,"end_line":10,"end_column":23}}},"filename":"type-01.k","line":10,"column":5,"end_line":10,"end_column":23},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"b","filename":"type-01.k","line":12,"column":5,"end_line":12,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":12,"column":5,"end_line":12,"end_column":6},"type_value":{"node":"int|str|[]|{:}","filename":"type-01.k","line":12,"column":9,"end_line":12,"end_column":29},"ty":{"node":{"Union":{"type_elements":[{"node":{"Basic":"Int"},"filename":"type-01.k","line":12,"column":9,"end_line":12,"end_column":12},{"node":{"Basic":"Str"},"filename":"type-01.k","line":12,"column":15,"end_line":12,"end_column":18},{"node":{"List":{"inner_type":null}},"filename":"type-01.k","line":12,"column":21,"end_line":12,"end_column":23},{"node":{"Dict":{"key_type":null,"value_type":null}},"filename":"type-01.k","line":12,"column":26,"end_line":12,"end_column":29}]}},"filename":"type-01.k","line":12,"column":9,"end_line":12,"end_column":29}}},"filename":"type-01.k","line":12,"column":5,"end_line":12,"end_column":29}],"comments":[]}
{"filename":"type-01.k","pkg":"__main__","doc":"","name":"__main__","body":[{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"a","filename":"type-01.k","line":1,"column":5,"end_line":1,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":1,"column":5,"end_line":1,"end_column":6},"type_value":{"node":"any","filename":"type-01.k","line":1,"column":9,"end_line":1,"end_column":12},"ty":{"node":"Any","filename":"type-01.k","line":1,"column":9,"end_line":1,"end_column":12}}},"filename":"type-01.k","line":1,"column":5,"end_line":1,"end_column":12},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"b","filename":"type-01.k","line":3,"column":5,"end_line":3,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":3,"column":5,"end_line":3,"end_column":6},"type_value":{"node":"bool","filename":"type-01.k","line":3,"column":9,"end_line":3,"end_column":13},"ty":{"node":{"Basic":"Bool"},"filename":"type-01.k","line":3,"column":9,"end_line":3,"end_column":13}}},"filename":"type-01.k","line":3,"column":5,"end_line":3,"end_column":13},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"c","filename":"type-01.k","line":4,"column":5,"end_line":4,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":4,"column":5,"end_line":4,"end_column":6},"type_value":{"node":"int","filename":"type-01.k","line":4,"column":9,"end_line":4,"end_column":12},"ty":{"node":{"Basic":"Int"},"filename":"type-01.k","line":4,"column":9,"end_line":4,"end_column":12}}},"filename":"type-01.k","line":4,"column":5,"end_line":4,"end_column":12},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"d","filename":"type-01.k","line":5,"column":5,"end_line":5,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":5,"column":5,"end_line":5,"end_column":6},"type_value":{"node":"float","filename":"type-01.k","line":5,"column":9,"end_line":5,"end_column":14},"ty":{"node":{"Basic":"Float"},"filename":"type-01.k","line":5,"column":9,"end_line":5,"end_column":14}}},"filename":"type-01.k","line":5,"column":5,"end_line":5,"end_column":14},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"e","filename":"type-01.k","line":6,"column":5,"end_line":6,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":6,"column":5,"end_line":6,"end_column":6},"type_value":{"node":"str","filename":"type-01.k","line":6,"column":9,"end_line":6,"end_column":12},"ty":{"node":{"Basic":"Str"},"filename":"type-01.k","line":6,"column":9,"end_line":6,"end_column":12}}},"filename":"type-01.k","line":6,"column":5,"end_line":6,"end_column":12},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"type_list1","filename":"type-01.k","line":8,"column":5,"end_line":8,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":8,"column":5,"end_line":8,"end_column":15},"type_value":{"node":"[]","filename":"type-01.k","line":8,"column":18,"end_line":8,"end_column":20},"ty":{"node":{"List":{"inner_type":null}},"filename":"type-01.k","line":8,"column":18,"end_line":8,"end_column":20}}},"filename":"type-01.k","line":8,"column":5,"end_line":8,"end_column":20},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"type_list2","filename":"type-01.k","line":9,"column":5,"end_line":9,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":9,"column":5,"end_line":9,"end_column":15},"type_value":{"node":"[[]]","filename":"type-01.k","line":9,"column":18,"end_line":9,"end_column":22},"ty":{"node":{"List":{"inner_type":{"node":{"List":{"inner_type":null}},"filename":"type-01.k","line":9,"column":19,"end_line":9,"end_column":21}}},"filename":"type-01.k","line":9,"column":18,"end_line":9,"end_column":22}}},"filename":"type-01.k","line":9,"column":5,"end_line":9,"end_column":22},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"type_list3","filename":"type-01.k","line":10,"column":5,"end_line":10,"end_column":15}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":10,"column":5,"end_line":10,"end_column":15},"type_value":{"node":"[int]","filename":"type-01.k","line":10,"column":18,"end_line":10,"end_column":23},"ty":{"node":{"List":{"inner_type":{"node":{"Basic":"Int"},"filename":"type-01.k","line":10,"column":19,"end_line":10,"end_column":22}}},"filename":"type-01.k","line":10,"column":18,"end_line":10,"end_column":23}}},"filename":"type-01.k","line":10,"column":5,"end_line":10,"end_column":23},{"node":{"TypeAlias":{"type_name":{"node":{"names":[{"node":"b","filename":"type-01.k","line":12,"column":5,"end_line":12,"end_column":6}],"pkgpath":"","ctx":"Load"},"filename":"type-01.k","line":12,"column":5,"end_line":12,"end_column":6},"type_value":{"node":"int | str | [] | {:}","filename":"type-01.k","line":12,"column":9,"end_line":12,"end_column":29},"ty":{"node":{"Union":{"type_elements":[{"node":{"Basic":"Int"},"filename":"type-01.k","line":12,"column":9,"end_line":12,"end_column":12},{"node":{"Basic":"Str"},"filename":"type-01.k","line":12,"column":15,"end_line":12,"end_column":18},{"node":{"List":{"inner_type":null}},"filename":"type-01.k","line":12,"column":21,"end_line":12,"end_column":23},{"node":{"Dict":{"key_type":null,"value_type":null}},"filename":"type-01.k","line":12,"column":26,"end_line":12,"end_column":29}]}},"filename":"type-01.k","line":12,"column":9,"end_line":12,"end_column":29}}},"filename":"type-01.k","line":12,"column":5,"end_line":12,"end_column":29}],"comments":[]}
2 changes: 1 addition & 1 deletion kclvm/runtime/src/types/typ_type_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Type {
_ => {
let mut types = Vec::new();
let _ = v.elem_types.iter().map(|e| types.push(e.type_str()));
types.join("|")
types.join(" | ")
}
},
Type::schema_type(ref v) => v.name.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion kclvm/sema/src/ty/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Type {
.iter()
.map(|ty| ty.into_type_annotation_str())
.collect::<Vec<String>>()
.join("|"),
.join(" | "),
TypeKind::Schema(schema_ty) => schema_ty.ty_str_with_pkgpath(),
TypeKind::NumberMultiplier(number_multiplier) => {
if number_multiplier.is_literal {
Expand Down
2 changes: 1 addition & 1 deletion kclvm/sema/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Type {
.iter()
.map(|ty| ty.ty_str())
.collect::<Vec<String>>()
.join("|"),
.join(" | "),
TypeKind::Schema(schema_ty) => schema_ty.name.to_string(),
TypeKind::NumberMultiplier(number_multiplier) => number_multiplier.ty_str(),
TypeKind::Function(func_ty) => func_ty.ty_str(),
Expand Down
2 changes: 1 addition & 1 deletion kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ fn konfig_hover_test_main() {
let expect: Vec<MarkedString> = vec![
"base.pkg.kusion_models.kube.frontend\n\nschema Server",
"Server is abstaction of Deployment and StatefulSet.",
"Attributes:\n\n__settings__?: {str:any}\n\nname?: str\n\nworkloadType: str(Deployment)|str(StatefulSet)\n\nrenderType?: str(Server)|str(KubeVelaApplication)\n\nreplicas: int\n\nimage: str\n\nschedulingStrategy: SchedulingStrategy\n\nmainContainer: Main\n\nsidecarContainers?: [Sidecar]\n\ninitContainers?: [Sidecar]\n\nuseBuiltInLabels?: bool\n\nlabels?: {str:str}\n\nannotations?: {str:str}\n\nuseBuiltInSelector?: bool\n\nselector?: {str:str}\n\npodMetadata?: ObjectMeta\n\nvolumes?: [Volume]\n\nneedNamespace?: bool\n\nenableMonitoring?: bool\n\nconfigMaps?: [ConfigMap]\n\nsecrets?: [Secret]\n\nservices?: [Service]\n\ningresses?: [Ingress]\n\nserviceAccount?: ServiceAccount\n\nstorage?: ObjectStorage\n\ndatabase?: DataBase"
"Attributes:\n\n__settings__?: {str:any}\n\nname?: str\n\nworkloadType: str(Deployment) | str(StatefulSet)\n\nrenderType?: str(Server) | str(KubeVelaApplication)\n\nreplicas: int\n\nimage: str\n\nschedulingStrategy: SchedulingStrategy\n\nmainContainer: Main\n\nsidecarContainers?: [Sidecar]\n\ninitContainers?: [Sidecar]\n\nuseBuiltInLabels?: bool\n\nlabels?: {str:str}\n\nannotations?: {str:str}\n\nuseBuiltInSelector?: bool\n\nselector?: {str:str}\n\npodMetadata?: ObjectMeta\n\nvolumes?: [Volume]\n\nneedNamespace?: bool\n\nenableMonitoring?: bool\n\nconfigMaps?: [ConfigMap]\n\nsecrets?: [Secret]\n\nservices?: [Service]\n\ningresses?: [Ingress]\n\nserviceAccount?: ServiceAccount\n\nstorage?: ObjectStorage\n\ndatabase?: DataBase"
]
.iter()
.map(|s| MarkedString::String(s.to_string()))
Expand Down

0 comments on commit bd0cc53

Please sign in to comment.