mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-03-26 13:52:44 +00:00
Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
This commit is contained in:
@@ -0,0 +1 @@
|
||||
source language/playground/lib.nu
|
||||
@@ -0,0 +1,54 @@
|
||||
export def main [topic, closure] {
|
||||
with-env {N: 5 REJECT: slow } {
|
||||
print (echo $topic " tests" (char newline) | str join)
|
||||
|
||||
do $closure
|
||||
}
|
||||
}
|
||||
|
||||
export def scene [
|
||||
topic: any
|
||||
--tag: string
|
||||
closure: closure
|
||||
] {
|
||||
print $" ($topic)(char newline)"
|
||||
do $closure
|
||||
}
|
||||
|
||||
export def play [
|
||||
topic: any
|
||||
--tag: string
|
||||
closure: closure
|
||||
] {
|
||||
let is_tag_empty = ($tag | is-empty);
|
||||
let should_run_all = ($env | get -i RUN_ALL | default false);
|
||||
|
||||
if $is_tag_empty {
|
||||
do $closure $topic
|
||||
} else {
|
||||
if $tag == $env.REJECT and $should_run_all {
|
||||
$" ($topic) ... (ansi yellow)skipped(ansi reset) (char newline)"
|
||||
} else {
|
||||
do $closure $topic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export def expect [
|
||||
topic: string
|
||||
actual: list<any>
|
||||
--to-be: list<any>
|
||||
] {
|
||||
let are_equal = (($actual | length) == ($to_be | length)) and ($actual | zip $to_be | all {|case|
|
||||
$case.0 == $case.1
|
||||
}
|
||||
)
|
||||
|
||||
let line = (if true == $are_equal {
|
||||
$"(ansi green)ok(ansi reset)(char newline)"
|
||||
} else {
|
||||
$"(ansi red)failed(ansi reset)(char newline)"
|
||||
}
|
||||
)
|
||||
$" ($topic) ... ($line)"
|
||||
}
|
||||
1
dot_config/nushell/nu_scripts/modules/language/std.nu
Normal file
1
dot_config/nushell/nu_scripts/modules/language/std.nu
Normal file
@@ -0,0 +1 @@
|
||||
source language/std/date.nu
|
||||
@@ -0,0 +1,7 @@
|
||||
export def "date local" [now] {
|
||||
insert time {|value|
|
||||
let converted = ($now | date to-timezone $value.tz);
|
||||
|
||||
$converted | format date '%c'
|
||||
}
|
||||
}
|
||||
34
dot_config/nushell/nu_scripts/modules/language/tests/date.nu
Normal file
34
dot_config/nushell/nu_scripts/modules/language/tests/date.nu
Normal file
@@ -0,0 +1,34 @@
|
||||
use ../playground *
|
||||
use ../std/date.nu *
|
||||
|
||||
def mock-now [] {
|
||||
"2021-08-29 03:31:21" | into datetime
|
||||
}
|
||||
|
||||
def people [] {
|
||||
[
|
||||
[ 'name', 'tz'];
|
||||
[ 'andres', 'America/Guayaquil']
|
||||
[ 'fdncred', 'US/Central']
|
||||
]
|
||||
}
|
||||
|
||||
playground "std/date" {
|
||||
|
||||
scene 'command: "date local"' {
|
||||
|
||||
play "adds times in local timezone" {|topic|
|
||||
|
||||
let expected_times = [
|
||||
"Sun Aug 29 03:31:21 2021"
|
||||
"Sun Aug 29 03:31:21 2021"
|
||||
] | into datetime;
|
||||
let actual = (people | date local (mock-now) | get time | into datetime)
|
||||
|
||||
expect $topic $actual --to-be $expected_times
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user