...

Text file src/github.com/datawire/ambassador/v2/build-aux/tests/prelude_uint.bats

Documentation: github.com/datawire/ambassador/v2/build-aux/tests

     1#!/usr/bin/env bats
     2
     3load common
     4
     5# These tests are ordered such that it makes sense to debug them from
     6# top to bottom.
     7
     8@test "prelude_uint.mk: _uint.normalize" {
     9	check_expr_eq strict '$(call _uint.normalize,4)' '4'
    10	check_expr_eq strict '$(call _uint.normalize,0)' '0'
    11	check_expr_eq strict '$(call _uint.normalize,004)' '4'
    12	check_expr_eq strict '$(call _uint.normalize, 4)' '4'
    13	check_expr_eq strict '$(call _uint.normalize,4 )' '4'
    14	# check that it errors for things that aren't uint
    15	not make EXPR='$(call _uint.normalize,)' expr-eq-strict-actual
    16	not make EXPR='$(call _uint.normalize,  )' expr-eq-strict-actual
    17	not make EXPR='$(call _uint.normalize,a)' expr-eq-strict-actual
    18	not make EXPR='$(call _uint.normalize,9a)' expr-eq-strict-actual
    19	not make EXPR='$(call _uint.normalize,a9)' expr-eq-strict-actual
    20	not make EXPR='$(call _uint.normalize,-4)' expr-eq-strict-actual
    21	not make EXPR='$(call _uint.normalize,4.2)' expr-eq-strict-actual
    22}
    23
    24@test "prelude_uint.mk: _uintx.to.uint" {
    25	check_expr_eq strict '$(call _uintx.to.uint,x x x x)' '4'
    26}
    27
    28@test "prelude_uint.mk: _uintx.from.uint.helper" {
    29	check_expr_eq echo '$(call _uintx.from.uint.helper,3,)' 'x x x'
    30}
    31
    32@test "prelude_uint.mk: _uintx.from.uint" {
    33	check_expr_eq strict '$(call _uintx.from.uint,4)' 'x x x x'
    34}
    35
    36@test "prelude_uint.mk: _uintx.max" {
    37	check_expr_eq strict '$(call _uintx.max,x x x,x x)' 'x x x'
    38}
    39
    40@test "prelude_uint.mk: _uintx.min" {
    41	check_expr_eq strict '$(call _uintx.min,x x x,x x)' 'x x'
    42}
    43
    44@test "prelude_uint.mk: uint.max" {
    45	check_expr_eq strict '$(call uint.max,3,2)' '3'
    46}
    47
    48@test "prelude_uint.mk: uint.min" {
    49	check_expr_eq strict '$(call uint.min,3,2)' '2'
    50}
    51
    52@test "prelude_uint.mk: uint.eq" {
    53	check_expr_eq strict '$(if $(call uint.eq,3,3),true,false)' 'true'
    54	check_expr_eq strict '$(if $(call uint.eq,3,4),true,false)' 'false'
    55	check_expr_eq strict '$(if $(call uint.eq,3,03),true,false)' 'true'
    56	check_expr_eq strict '$(if $(call uint.eq,  3  , 03),true,false)' 'true'
    57}
    58
    59@test "prelude_uint.mk: uint.ge" {
    60	check_expr_eq strict '$(if $(call uint.ge,2,3),true,false)' 'false'
    61	check_expr_eq strict '$(if $(call uint.ge,3,3),true,false)' 'true'
    62	check_expr_eq strict '$(if $(call uint.ge,4,3),true,false)' 'true'
    63}
    64
    65@test "prelude_uint.mk: uint.le" {
    66	check_expr_eq strict '$(if $(call uint.le,2,3),true,false)' 'true'
    67	check_expr_eq strict '$(if $(call uint.le,3,3),true,false)' 'true'
    68	check_expr_eq strict '$(if $(call uint.le,4,3),true,false)' 'false'
    69}
    70
    71@test "prelude_uint.mk: uint.gt" {
    72	check_expr_eq strict '$(if $(call uint.gt,2,3),true,false)' 'false'
    73	check_expr_eq strict '$(if $(call uint.gt,3,3),true,false)' 'false'
    74	check_expr_eq strict '$(if $(call uint.gt,4,3),true,false)' 'true'
    75}
    76
    77@test "prelude_uint.mk: uint.lt" {
    78	check_expr_eq strict '$(if $(call uint.lt,2,3),true,false)' 'true'
    79	check_expr_eq strict '$(if $(call uint.lt,3,3),true,false)' 'false'
    80	check_expr_eq strict '$(if $(call uint.lt,4,3),true,false)' 'false'
    81}

View as plain text