From eaf7ecfd0244bac057f4677d66506fcda7a4596d Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:21:53 -0500 Subject: [PATCH] Move Table/List helper module to new std-rfc (#1025) This module was previously in `std-rfc`, but was left behind when we "reset" it. This simply moves it back into `std-rfc` for evaluation along with updates for latest main changes. --- .../std-rfc/conversions/into.nu | 0 .../std-rfc/conversions/mod.nu | 0 .../std-rfc/tables/col-indices.nu | 0 .../std-rfc/tables/mod.nu | 0 .../std-rfc/tables/reject-column-ranges.nu | 0 .../std-rfc/tables/reject-ranges.nu | 1 + .../std-rfc/tables/row-indices.nu | 0 .../std-rfc/tables/select-column-ranges.nu | 0 .../std-rfc/tables/select-ranges.nu | 0 .../tests/conversions.nu | 15 ++++-- .../tests/tables.nu | 53 ++++++++++++------- 11 files changed, 46 insertions(+), 23 deletions(-) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/conversions/into.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/conversions/mod.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/col-indices.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/mod.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/reject-column-ranges.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/reject-ranges.nu (96%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/row-indices.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/select-column-ranges.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/std-rfc/tables/select-ranges.nu (100%) rename {stdlib-candidate-old => stdlib-candidate}/tests/conversions.nu (68%) rename {stdlib-candidate-old => stdlib-candidate}/tests/tables.nu (81%) diff --git a/stdlib-candidate-old/std-rfc/conversions/into.nu b/stdlib-candidate/std-rfc/conversions/into.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/conversions/into.nu rename to stdlib-candidate/std-rfc/conversions/into.nu diff --git a/stdlib-candidate-old/std-rfc/conversions/mod.nu b/stdlib-candidate/std-rfc/conversions/mod.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/conversions/mod.nu rename to stdlib-candidate/std-rfc/conversions/mod.nu diff --git a/stdlib-candidate-old/std-rfc/tables/col-indices.nu b/stdlib-candidate/std-rfc/tables/col-indices.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/tables/col-indices.nu rename to stdlib-candidate/std-rfc/tables/col-indices.nu diff --git a/stdlib-candidate-old/std-rfc/tables/mod.nu b/stdlib-candidate/std-rfc/tables/mod.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/tables/mod.nu rename to stdlib-candidate/std-rfc/tables/mod.nu diff --git a/stdlib-candidate-old/std-rfc/tables/reject-column-ranges.nu b/stdlib-candidate/std-rfc/tables/reject-column-ranges.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/tables/reject-column-ranges.nu rename to stdlib-candidate/std-rfc/tables/reject-column-ranges.nu diff --git a/stdlib-candidate-old/std-rfc/tables/reject-ranges.nu b/stdlib-candidate/std-rfc/tables/reject-ranges.nu similarity index 96% rename from stdlib-candidate-old/std-rfc/tables/reject-ranges.nu rename to stdlib-candidate/std-rfc/tables/reject-ranges.nu index 05e39a6..802bc48 100644 --- a/stdlib-candidate-old/std-rfc/tables/reject-ranges.nu +++ b/stdlib-candidate/std-rfc/tables/reject-ranges.nu @@ -10,5 +10,6 @@ use ./row-indices.nu * export def "reject ranges" [ ...ranges ] { enumerate | flatten + | collect | reject ...(row-indices ...$ranges) } diff --git a/stdlib-candidate-old/std-rfc/tables/row-indices.nu b/stdlib-candidate/std-rfc/tables/row-indices.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/tables/row-indices.nu rename to stdlib-candidate/std-rfc/tables/row-indices.nu diff --git a/stdlib-candidate-old/std-rfc/tables/select-column-ranges.nu b/stdlib-candidate/std-rfc/tables/select-column-ranges.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/tables/select-column-ranges.nu rename to stdlib-candidate/std-rfc/tables/select-column-ranges.nu diff --git a/stdlib-candidate-old/std-rfc/tables/select-ranges.nu b/stdlib-candidate/std-rfc/tables/select-ranges.nu similarity index 100% rename from stdlib-candidate-old/std-rfc/tables/select-ranges.nu rename to stdlib-candidate/std-rfc/tables/select-ranges.nu diff --git a/stdlib-candidate-old/tests/conversions.nu b/stdlib-candidate/tests/conversions.nu similarity index 68% rename from stdlib-candidate-old/tests/conversions.nu rename to stdlib-candidate/tests/conversions.nu index ba6e0d8..003d28c 100644 --- a/stdlib-candidate-old/tests/conversions.nu +++ b/stdlib-candidate/tests/conversions.nu @@ -1,7 +1,8 @@ use std assert use ../std-rfc/conversions * -export def "test range-into-list" [] { +#[test] +def range-into-list [] { assert equal ( 1..10 | into list ) ( @@ -9,7 +10,8 @@ export def "test range-into-list" [] { ) } -export def "test string-into-list" [] { +#[test] +def string-into-list [] { assert equal ( "foo" | into list ) ( @@ -17,7 +19,8 @@ export def "test string-into-list" [] { ) } -export def "test range-stride-into-list" [] { +#[test] +def range-stride-into-list [] { assert equal ( 0..2..10 | into list ) ( @@ -25,7 +28,8 @@ export def "test range-stride-into-list" [] { ) } -export def "test null-into-list" [] { +#[test] +def null-into-list [] { assert equal ( null | into list | get 0 | describe ) ( @@ -33,7 +37,8 @@ export def "test null-into-list" [] { ) } -export def "test list-into-list" [] { +#[test] +def list-into-list [] { assert equal ( [ foo bar baz ] | into list ) ( diff --git a/stdlib-candidate-old/tests/tables.nu b/stdlib-candidate/tests/tables.nu similarity index 81% rename from stdlib-candidate-old/tests/tables.nu rename to stdlib-candidate/tests/tables.nu index 4d22d5b..a7a7337 100644 --- a/stdlib-candidate-old/tests/tables.nu +++ b/stdlib-candidate/tests/tables.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc/tables * const test_table = [ @@ -29,7 +29,8 @@ const enumerated_table = [ [ 9 'a9' 'b9' 'c9' 'd9' 'e9' 'f9' ] ] -export def "test row-indices-range" [] { +#[test] +def row-indices--range [] { assert equal ( row-indices 0..3 10..11 ) ( @@ -37,7 +38,8 @@ export def "test row-indices-range" [] { ) } -export def "test row-indices-index" [] { +#[test] +export def row-indices--index [] { assert equal ( row-indices 4 ) ( @@ -45,7 +47,8 @@ export def "test row-indices-index" [] { ) } -export def "test row-indices-complex" [] { +#[test] +def row-indices--complex [] { assert equal ( row-indices 0..2..6 3 7 ) ( @@ -53,7 +56,8 @@ export def "test row-indices-complex" [] { ) } -export def "test col-index-ints" [] { +#[test] +def col-index--ints [] { assert equal ( # Third and Fifth Columns $test_table | col-indices 2 4 @@ -62,7 +66,8 @@ export def "test col-index-ints" [] { ) } -export def "test col-index-complex" [] { +#[test] +def col-index--complex [] { assert equal ( # Every other column, plus the second $test_table | col-indices 0..2..10 1 @@ -71,7 +76,8 @@ export def "test col-index-complex" [] { ) } -export def "test select-range single-int" [] { +#[test] +def select-range--single_int [] { assert equal ( $test_table | select ranges 1 ) ( @@ -79,7 +85,8 @@ export def "test select-range single-int" [] { ) } -export def "test select-range single-range" [] { +#[test] +def select-range--single_range [] { assert equal ( $test_table | select ranges 2..4 ) ( @@ -87,7 +94,8 @@ export def "test select-range single-range" [] { ) } -export def "test select-range complex" [] { +#[test] +def select-range--complex [] { assert equal ( # First and every following third-row + second row $test_table | select ranges 1 0..3..100 @@ -96,7 +104,8 @@ export def "test select-range complex" [] { ) } -export def "test select-range out-of-bounds" [] { +#[test] +def select-range--out_of_bounds [] { assert equal ( $test_table | select ranges 100 ) ( @@ -104,7 +113,8 @@ export def "test select-range out-of-bounds" [] { ) } -export def "test reject-range single-index" [] { +#[test] +def reject-range--single_index [] { assert equal ( $test_table | reject ranges 4 ) ( @@ -112,7 +122,8 @@ export def "test reject-range single-index" [] { ) } -export def "test reject-range ranges" [] { +#[test] +def reject-range--ranges [] { assert equal ( # Reject rows 0-3 and 5-9, leaving only 4 $test_table | reject ranges 0..3 5..9 @@ -121,13 +132,15 @@ export def "test reject-range ranges" [] { ) } -export def "test reject-range out-of-bounds" [] { +#[test] +def reject-range--out_of_bounds [] { assert error { $test_table | reject ranges 1000 } } -export def "test select-col index" [] { +#[test] +def select-col--index [] { assert equal ( $test_table | select column-ranges 2 ) ( @@ -135,7 +148,8 @@ export def "test select-col index" [] { ) } -export def "test select-col indices" [] { +#[test] +def select-col--indices [] { assert equal ( $test_table | select column-ranges 2 4 ) ( @@ -143,7 +157,8 @@ export def "test select-col indices" [] { ) } -export def "test select-col ranges-and-index" [] { +#[test] +def select-col--ranges_and_index [] { assert equal ( $test_table | select column-ranges 0..2..5 1 ) ( @@ -151,7 +166,8 @@ export def "test select-col ranges-and-index" [] { ) } -export def "test reject-col ranges-and-index" [] { +#[test] +def reject-col--ranges_and_index [] { assert equal ( $test_table | reject column-ranges 0..2..5 1 ) ( @@ -159,7 +175,8 @@ export def "test reject-col ranges-and-index" [] { ) } -export def "test reject-col out-of-bounds" [] { +#[test] +def reject-col--out_of_bounds [] { assert equal ( $test_table | reject column-ranges 1_000 ) (