stdlib: add an automatic loading of "prelude" commands (#8627)

This commit is contained in:
Antoine Stevan
2023-04-05 22:44:59 +02:00
committed by GitHub
parent 56efbd7de9
commit 7bac0b417f
3 changed files with 137 additions and 2 deletions

35
src/tests/test_stdlib.rs Normal file
View File

@@ -0,0 +1,35 @@
use crate::tests::{fail_test, run_test, TestResult};
#[test]
fn library_loaded() -> TestResult {
run_test(
"help std | lines | first 1 | to text",
"std.nu, `used` to load all standard library components",
)
}
#[test]
fn prelude_loaded() -> TestResult {
run_test(
"help assert | lines | first 1 | to text",
"Universal assert command",
)
}
#[test]
fn prelude_run() -> TestResult {
run_test("assert true; print 'it works'", "it works")
}
#[test]
fn not_loaded() -> TestResult {
fail_test("help log info", "")
}
#[test]
fn use_command() -> TestResult {
run_test(
"use std 'log info'; log info 'this is some information'",
"",
)
}