Minimal std exports

This commit is contained in:
NotTheDr01ds 2024-09-24 15:40:07 -04:00
parent d2b3556914
commit f691c71ebe
8 changed files with 33 additions and 36 deletions

View File

@ -1,18 +1,9 @@
# std.nu, `used` to load all standard library components
# std.nu, `used` to load base standard library components
#export module assert
#export module bench
#export module dirs
#export module dt
#export module formats
#export module help
export module input
export module iter
#export module log
#export module math
#export module xml
# Make commands available in the top-level module
# Make certain commands available in the top-level namespace
export use lib *
export use formats *
export use dt *

View File

@ -1,4 +1,8 @@
use std/log
export-env {
# Place NU_FORMAT... environment variables in module-scope
export use std/log *
}
def "nu-complete threads" [] {
seq 1 (sys cpu | length)

View File

@ -1,4 +1,3 @@
use std *
use std/assert
def run [

View File

@ -1,5 +1,5 @@
use std *
use std/assert
use std/log
use std/log *
#[test]

View File

@ -1,22 +0,0 @@
use std/assert
#[test]
def std_pre_import [] {
# These commands shouldn't exist without an import
assert length (scope commands | where name == "path add") 0
assert length (scope commands | where name == "ellie") 0
assert length (scope commands | where name == "repeat") 0
assert length (scope commands | where name == "from jsonl") 0
assert length (scope commands | where name == "datetime-diff") 0
}
def std_post_import [] {
# After importing std, these commands should be
# available at the top level namespace
use std *
assert length (scope commands | where name == "path add") 1
assert length (scope commands | where name == "ellie") 1
assert length (scope commands | where name == "repeat") 1
assert length (scope commands | where name == "from jsonl") 1
assert length (scope commands | where name == "datetime-diff") 1
}

View File

@ -0,0 +1,11 @@
use std/assert
export use std *
#[test]
def std_post_import [] {
assert length (scope commands | where name == "path add") 1
assert length (scope commands | where name == "ellie") 1
assert length (scope commands | where name == "repeat") 1
assert length (scope commands | where name == "from jsonl") 1
assert length (scope commands | where name == "datetime-diff") 1
}

View File

@ -0,0 +1,11 @@
use std/assert
#[test]
def std_pre_import [] {
# These commands shouldn't exist without an import
assert length (scope commands | where name == "path add") 0
assert length (scope commands | where name == "ellie") 0
assert length (scope commands | where name == "repeat") 0
assert length (scope commands | where name == "from jsonl") 0
assert length (scope commands | where name == "datetime-diff") 0
}

View File

@ -7,5 +7,8 @@ fn not_loaded() -> TestResult {
#[test]
fn use_command() -> TestResult {
run_test_std("use ([ std, assert ] | path join); assert true; print 'it works'", "it works")
run_test_std(
"use ([ std, assert ] | path join); assert true; print 'it works'",
"it works",
)
}