Skip to content

Commit

Permalink
added generated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
refaktor committed Nov 18, 2024
1 parent 3988576 commit a423b90
Show file tree
Hide file tree
Showing 2 changed files with 412 additions and 0 deletions.
319 changes: 319 additions & 0 deletions tests2/base.tests.rye
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
section "base" "base text" {

group "to-word"
""
{
}

{
equal { to-word "test" } 'test
error { to-word "123" }
}

group "to-integer"
""
{
}

{
equal { to-integer "123" } 123
; equal { to-integer "123.4" } 123
; equal { to-integer "123.6" } 123
; equal { to-integer "123.4" } 123
error { to-integer "abc" }
}

group "to-decimal"
""
{
}

{
equal { to-decimal "123.4" } 123.4
error { to-decimal "abc" }
}

group "to-string"
""
{
}

{
equal { to-string 'test } "test"
equal { to-string 123 } "123"
equal { to-string 123.4 } "123.4000"
equal { to-string "test" } "test"
}

group "to-char"
""
{
}

{
equal { to-char 42 } "*"
error { to-char "*" }
}

group "to-block"
""
{
}

{
equal { list [ 1 2 3 ] |to-block |type? } 'block
equal { list [ 1 2 3 ] |to-block |first } 1
}

group "to-context"
""
{
}

{
equal { dict [ "a" 1 "b" 2 "c" 3 ] |to-context |type? } 'context
; equal { dict [ "a" 1 ] |to-context do\in { a } } '1
}

group "is-string"
""
{
}

{
equal { is-string "test" } 1
equal { is-string 'test } 0
equal { is-string 123 } 0
}

group "is-integer"
""
{
}

{
equal { is-integer 123 } 1
equal { is-integer 123.4 } 0
equal { is-integer "123" } 0
}

group "is-decimal"
""
{
}

{
equal { is-decimal 123.0 } 1
equal { is-decimal 123 } 0
equal { is-decimal "123.4" } 0
}

group "is-number"
""
{
}

{
equal { is-number 123 } 1
equal { is-number 123.4 } 1
equal { is-number "123" } 0
}

group "to-uri"
""
{
}

{
equal { to-uri "https://example.com" } https://example.com
; error { to-uri "not-uri" }
}

group "to-file"
""
{
}

{
equal { to-file "example.txt" } %example.txt
error { to-file 123 }
}

group "type?"
""
{
}

{
equal { type? "test" } 'string
equal { type? 123.4 } 'decimal
}

group "types?"
""
{
}

{
equal { types? { "test" 123 } } { string integer }
}

group "inc"
""
{
}

{
equal { inc 123 } 124
error { inc "123" }
}

group "is-positive"
""
{
}

{
equal { is-positive 123 } 1
equal { is-positive -123 } 0
error { is-positive "123" }
}

group "is-zero"
""
{
}

{
equal { is-zero 0 } 1
equal { is-zero 123 } 0
error { is-zero "123" }
}

group "inc!"
""
{
}

{
equal { a:: 123 inc! 'a a } 124
error { inc! 123 }
}

group "dec!"
""
{
}

{
equal { a:: 123 dec! 'a a } 122
error { dec! 123 }
}

group "change!"
""
{
}

{
equal { a:: 123 change! 333 'a a } 333
equal { a:: 123 change! 124 'a } 1
equal { a:: 123 change! 123 'a } 0
}

group "set!"
""
{
}

{
equal { set! { 123 234 } { a b } b } 234
}

group "dump"
""
{
}

{
equal { does { 1 } |dump } "fn { } { 1 }"
}

group "dict"
""
{
}

{
equal { dict { "a" 123 } -> "b" } 123
}

group "list"
""
{
}

{
equal { list { "a" 123 } -> 1 } "a"
}

group "not"
""
{
}

{
equal { not true } 0
}

group "and"
""
{
}

{
equal { true .and true } 1
equal { false .and true } 0
}

group "or"
""
{
}

{
equal { true .or true } 1
equal { false .or true } 1
equal { true .or false } 1
equal { false .or false } 0
}

group "embed"
""
{
}

{
equal { embed 101 "val {}" } "val 101"
}

group "is-empty"
""
{
}

{
equal { { } .is-empty } 1
}

group "cmd"
""
{
}

{
equal { cmd `echo "hello"` } 1
}

}

Loading

0 comments on commit a423b90

Please sign in to comment.