Skip to content

Commit

Permalink
Fix nupm test --dir stdlib-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
texastoland committed Mar 13, 2024
1 parent 872a123 commit 65aa7cc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions stdlib-candidate/std-rfc/fs.nu
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export def "file bulk-rename" [
stem_update: closure, # the code to run on the stem of the files: should start with parsing the format and end with reconstructing the same format
--verbose, # be verbose when moving the files around
]: nothing -> nothing {
ls --full-paths $directory | insert new {
get name | path parse | update stem $stem_update | path join
ls --full-paths $directory | insert new {|row|
$row.name | path parse | update stem $stem_update | path join
}
| each {
if $verbose {
Expand Down
10 changes: 6 additions & 4 deletions stdlib-candidate/tests/fs.nu
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[test]
def test [] {
use std assert
use std assert
use ../std-rfc "file bulk-rename"

alias rename = file bulk-rename

export def "file bulk-rename" [] {
let test_dir = $nu.temp-path | path join (random uuid)

mkdir $test_dir
Expand All @@ -22,7 +24,7 @@ def test [] {
let actual = glob $"($test_dir)/*" | str replace $test_dir "" | str trim --left --char "/"
assert equal ($actual | sort) $expected

file bulk-rename $test_dir {
rename $test_dir {
parse "some_{i}_format"
| get 0
| update i { fill --alignment r --character 0 --width 3 }
Expand Down
3 changes: 3 additions & 0 deletions stdlib-candidate/tests/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export module fs.nu
export module record.nu
export module str.nu
34 changes: 16 additions & 18 deletions stdlib-candidate/tests/record.nu
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#[test]
def test_record_list_merge [] {
use std assert
assert equal ([{a:1} {b:2} {c:3} {d:4}] | list merge) {a:1 b:2 c:3 d:4}
use std assert
use ../std-rfc record

export def "list_merge" [] {
assert equal ([{a:1} {b:2} {c:3} {d:4}] | record list merge) {a:1 b:2 c:3 d:4}
}
#[test]
def test_record_filtername_predicate [] {
use std assert
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | filter-name predicate {$in | str contains a}) {aa:1 ab:2 ba:3 ca:5}

export def "filter-name predicate" [] {
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | record filter-name predicate {$in | str contains a}) {aa:1 ab:2 ba:3 ca:5}
}
#[test]
def test_record_filtername_text [] {
use std assert
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | filter-name text a) {aa:1 ab:2 ba:3 ca:5}
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | filter-name text -r ^a) {aa:1 ab:2}
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | filter-name text -r ^A) {}

export def "filter-name text" [] {
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | record filter-name text a) {aa:1 ab:2 ba:3 ca:5}
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | record filter-name text -r ^a) {aa:1 ab:2}
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | record filter-name text -r ^A) {}
}
#[test]
def test_record_filtervalue_predicate [] {
use std assert
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | filter-value predicate { $in mod 2 == 0 }) {ab:2 bb:4 cb:6}

export def "filter-value predicate" [] {
assert equal ({aa:1 ab:2 ba:3 bb:4 ca:5 cb:6} | record filter-value predicate { $in mod 2 == 0 }) {ab:2 bb:4 cb:6}
}
19 changes: 8 additions & 11 deletions stdlib-candidate/tests/str.nu
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#[test]
def test_append [] {
use std assert
assert equal ("foo" | append "/") "foo/"
assert equal (["foo", "bar", "baz"] | append "/") ["foo/", "bar/", "baz/"]
use std assert
use ../std-rfc str

export def append [] {
assert equal ("foo" | str append "/") "foo/"
assert equal (["foo", "bar", "baz"] | str append "/") ["foo/", "bar/", "baz/"]
}

#[test]
def test_prepend [] {
use std assert
assert equal ("foo" | prepend "/") "/foo"
assert equal (["foo", "bar", "baz"] | prepend "/") ["/foo", "/bar", "/baz"]

export def prepend [] {
assert equal ("foo" | str prepend "/") "/foo"
assert equal (["foo", "bar", "baz"] | str prepend "/") ["/foo", "/bar", "/baz"]
}

0 comments on commit 65aa7cc

Please sign in to comment.