Skip to content

Commit

Permalink
tests added
Browse files Browse the repository at this point in the history
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
  • Loading branch information
shruti2522 committed May 4, 2024
1 parent a37fe21 commit 844c65d
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 13 deletions.
6 changes: 3 additions & 3 deletions kclvm/api/src/service/service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ impl KclvmServiceImpl {
/// assert_eq!(result.type_errors.len(), 0);
/// assert_eq!(result.symbols.len(), 12);
/// assert_eq!(result.scopes.len(), 3);
/// assert_eq!(result.node_symbol_map.len(), 169);
/// assert_eq!(result.symbol_node_map.len(), 169);
/// assert_eq!(result.fully_qualified_name_map.len(), 178);
/// assert_eq!(result.node_symbol_map.len(), 171);
/// assert_eq!(result.symbol_node_map.len(), 171);
/// assert_eq!(result.fully_qualified_name_map.len(), 180);
/// assert_eq!(result.pkg_scope_map.len(), 3);
/// ```
#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 157,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 158,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 157,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 158,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -240,7 +240,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 158,
index: 160,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -337,7 +337,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -585,6 +585,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 157,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 158,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -617,7 +631,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 159,
index: 161,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -827,6 +841,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 157,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 158,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -1069,6 +1097,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 157,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 158,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -1101,7 +1143,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 160,
index: 162,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 157,
index: 159,
generation: 0,
},
kind: Value,
Expand Down
28 changes: 28 additions & 0 deletions kclvm/sema/src/builtin/system_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,34 @@ register_file_member! {
false,
None,
)
mkdir => Type::function(
None,
Type::str_ref(),
&[
Parameter {
name: "directory".to_string(),
ty: Type::str_ref(),
has_default: false,
},
],
r#"Create a new directory at the specified path if it doesn't already exist."#,
false,
None,
)
delete => Type::function(
None,
Type::str_ref(),
&[
Parameter {
name: "filepath".to_string(),
ty: Type::str_ref(),
has_default: false,
},
],
r#"Delete a file or an empty directory at the specified path."#,
false,
None,
)
}

// ------------------------------
Expand Down
6 changes: 6 additions & 0 deletions test/grammar/builtins/file/delete/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import file

file.delete("test_dir")



1 change: 1 addition & 0 deletions test/grammar/builtins/file/delete/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
delete: failed to delete 'test_dir': No such file or directory
3 changes: 3 additions & 0 deletions test/grammar/builtins/file/mkdir/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import file

file.mkdir("test_dir")
1 change: 1 addition & 0 deletions test/grammar/builtins/file/mkdir/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mkdir: created directory 'test_dir'

0 comments on commit 844c65d

Please sign in to comment.