1# ---------------------------------------------------------------------------- 2# 3# GNU Make Standard Library (GMSL) Test Suite 4# 5# Test suite for the GMSL 6# 7# Copyright (c) 2005-2007 John Graham-Cumming 8# 9# This file is part of GMSL 10# 11# Redistribution and use in source and binary forms, with or without 12# modification, are permitted provided that the following conditions 13# are met: 14# 15# Redistributions of source code must retain the above copyright 16# notice, this list of conditions and the following disclaimer. 17# 18# Redistributions in binary form must reproduce the above copyright 19# notice, this list of conditions and the following disclaimer in the 20# documentation and/or other materials provided with the distribution. 21# 22# Neither the name of the John Graham-Cumming nor the names of its 23# contributors may be used to endorse or promote products derived from 24# this software without specific prior written permission. 25# 26# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 29# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 30# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 31# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 32# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 33# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 34# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 36# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37# POSSIBILITY OF SUCH DAMAGE. 38# 39# ---------------------------------------------------------------------------- 40 41.PHONY: all 42all: 43 @echo 44 @echo Test Summary 45 @echo ------------ 46 @echo "$(call int_decode,$(passed)) tests passed; $(call int_decode,$(failed)) tests failed" 47 48include gmsl 49 50passed := 51failed := 52 53ECHO := /bin/echo 54 55start_test = $(shell $(ECHO) -n "Testing '$1': " >&2)$(eval current_test := OK) 56stop_test = $(shell $(ECHO) " $(current_test)" >&2) 57test_pass = .$(eval passed := $(call int_inc,$(passed))) 58test_fail = X$(eval failed := $(call int_inc,$(failed)))$(eval current_test := ERROR '$1' != '$2') 59test_assert = $(if $(filter undefined,$(origin 2)),$(eval 2 :=))$(shell $(ECHO) -n $(if $(call seq,$1,$2),$(call test_pass,$1,$2),$(call test_fail,$1,$2)) >&2) 60 61$(call start_test,not) 62$(call test_assert,$(call not,$(true)),$(false)) 63$(call test_assert,$(call not,$(false)),$(true)) 64$(call stop_test) 65 66$(call start_test,or) 67$(call test_assert,$(call or,$(true),$(true)),$(true)) 68$(call test_assert,$(call or,$(true),$(false)),$(true)) 69$(call test_assert,$(call or,$(false),$(true)),$(true)) 70$(call test_assert,$(call or,$(false),$(false)),$(false)) 71$(call stop_test) 72 73$(call start_test,and) 74$(call test_assert,$(call and,$(true),$(true)),$(true)) 75$(call test_assert,$(call and,$(true),$(false)),$(false)) 76$(call test_assert,$(call and,$(false),$(true)),$(false)) 77$(call test_assert,$(call and,$(false),$(false)),$(false)) 78$(call stop_test) 79 80$(call start_test,xor) 81$(call test_assert,$(call xor,$(true),$(true)),$(false)) 82$(call test_assert,$(call xor,$(true),$(false)),$(true)) 83$(call test_assert,$(call xor,$(false),$(true)),$(true)) 84$(call test_assert,$(call xor,$(false),$(false)),$(false)) 85$(call stop_test) 86 87$(call start_test,nand) 88$(call test_assert,$(call nand,$(true),$(true)),$(false)) 89$(call test_assert,$(call nand,$(true),$(false)),$(true)) 90$(call test_assert,$(call nand,$(false),$(true)),$(true)) 91$(call test_assert,$(call nand,$(false),$(false)),$(true)) 92$(call stop_test) 93 94$(call start_test,nor) 95$(call test_assert,$(call nor,$(true),$(true)),$(false)) 96$(call test_assert,$(call nor,$(true),$(false)),$(false)) 97$(call test_assert,$(call nor,$(false),$(true)),$(false)) 98$(call test_assert,$(call nor,$(false),$(false)),$(true)) 99$(call stop_test) 100 101$(call start_test,xnor) 102$(call test_assert,$(call xnor,$(true),$(true)),$(true)) 103$(call test_assert,$(call xnor,$(true),$(false)),$(false)) 104$(call test_assert,$(call xnor,$(false),$(true)),$(false)) 105$(call test_assert,$(call xnor,$(false),$(false)),$(true)) 106$(call stop_test) 107 108$(call start_test,first) 109$(call test_assert,$(call first,1 2 3),1) 110$(call test_assert,$(call first,1),1) 111$(call test_assert,$(call first,),) 112$(call stop_test) 113 114$(call start_test,last) 115$(call test_assert,$(call last,1 2 3),3) 116$(call test_assert,$(call last,1),1) 117$(call test_assert,$(call last,),) 118$(call stop_test) 119 120$(call start_test,rest) 121$(call test_assert,$(call rest,1 2 3),2 3) 122$(call test_assert,$(call rest,1),) 123$(call test_assert,$(call rest,),) 124$(call stop_test) 125 126$(call start_test,chop) 127$(call test_assert,$(call chop,1 2 3),1 2) 128$(call test_assert,$(call chop,1 2 3 4),1 2 3) 129$(call test_assert,$(call chop,1),) 130$(call test_assert,$(call chop,),) 131$(call stop_test) 132 133$(call start_test,length) 134$(call test_assert,$(call length,1 2 3),3) 135$(call test_assert,$(call length,1 2 3 4),4) 136$(call test_assert,$(call length,1),1) 137$(call test_assert,$(call length,),0) 138$(call stop_test) 139 140$(call start_test,map) 141$(call test_assert,$(call map,origin,__undefined map MAKE),undefined file default) 142$(call test_assert,$(call map,origin,),) 143$(call stop_test) 144 145joinem = $1$2 146$(call start_test,pairmap) 147$(call test_assert,$(call pairmap,addsuffix,2 1 3,a b c),a2 b1 c3) 148$(call test_assert,$(call pairmap,addprefix,2 1 3,a b c d),2a 1b 3c d) 149$(call test_assert,$(call pairmap,addprefix,2 1 3 4,a b c),2a 1b 3c) 150$(call test_assert,$(call pairmap,joinem,2 1 3 4,a b c),2a 1b 3c 4) 151$(call stop_test) 152 153$(call start_test,seq) 154$(call test_assert,$(call seq,abc,abc),T) 155$(call test_assert,$(call seq,x,),) 156$(call test_assert,$(call seq,,x),) 157$(call test_assert,$(call seq,x,x),T) 158$(call test_assert,$(call seq,a%c,abc),) 159$(call test_assert,$(call seq,abc,a%c),) 160$(call test_assert,$(call seq,abc,ABC),) 161$(call test_assert,$(call seq,abc,),) 162$(call test_assert,$(call seq,,),T) 163$(call test_assert,$(call seq,a b c,a b c),T) 164$(call test_assert,$(call seq,aa% bb% cc,aa% bb% cc),T) 165$(call test_assert,$(call seq,aa% bb% cc,aa% bb cc),) 166$(call test_assert,$(call seq,aa% bb% cc,xx yy zz),) 167$(call stop_test) 168 169$(call start_test,sne) 170$(call test_assert,$(call sne,abc,abc),) 171$(call test_assert,$(call sne,x,),T) 172$(call test_assert,$(call sne,,x),T) 173$(call test_assert,$(call sne,x,x),) 174$(call test_assert,$(call sne,abc,ABC),T) 175$(call test_assert,$(call sne,abc,),T) 176$(call test_assert,$(call sne,,),) 177$(call test_assert,$(call sne,a b c,a b c),) 178$(call test_assert,$(call sne,aa% bb% cc,aa% bb% cc),) 179$(call test_assert,$(call sne,aa% bb% cc,aa% bb cc),T) 180$(call stop_test) 181 182$(call start_test,strlen) 183$(call test_assert,$(call strlen,),0) 184$(call test_assert,$(call strlen,a),1) 185$(call test_assert,$(call strlen,a b),3) 186$(call test_assert,$(call strlen,a ),2) 187$(call test_assert,$(call strlen, a),2) 188$(call test_assert,$(call strlen, ),2) 189$(call test_assert,$(call strlen, ),3) 190$(call test_assert,$(call strlen, ),4) 191$(call stop_test) 192 193$(call start_test,substr) 194$(call test_assert,$(call substr,xyz,1,1),x) 195$(call test_assert,$(call substr,xyz,1,2),xy) 196$(call test_assert,$(call substr,xyz,2,3),yz) 197$(call test_assert,$(call substr,some string,1,1),s) 198$(call test_assert,$(call substr,some string,1,2),so) 199$(call test_assert,$(call substr,some string,1,3),som) 200$(call test_assert,$(call substr,some string,1,4),some) 201$(call test_assert,$(call substr,some string,1,5),some ) 202$(call test_assert,$(call substr,some string,1,6),some s) 203$(call test_assert,$(call substr,some string,5,5), ) 204$(call test_assert,$(call substr,some string,5,6), s) 205$(call test_assert,$(call substr,some string,5,7), st) 206$(call test_assert,$(call substr,some string,5,8), str) 207$(call test_assert,$(call substr,some string,1,100),some string) 208$(call stop_test) 209 210$(call start_test,lc) 211$(call test_assert,$(call lc,The Quick Brown Fox),the quick brown fox) 212$(call test_assert,$(call lc,the1 quick2 brown3 fox4),the1 quick2 brown3 fox4) 213$(call test_assert,$(call lc,The_),the_) 214$(call test_assert,$(call lc,),) 215$(call stop_test) 216 217$(call start_test,uc) 218$(call test_assert,$(call uc,The Quick Brown Fox),THE QUICK BROWN FOX) 219$(call test_assert,$(call uc,the1 quick2 brown3 fox4),THE1 QUICK2 BROWN3 FOX4) 220$(call test_assert,$(call uc,The_),THE_) 221$(call test_assert,$(call uc,),) 222$(call stop_test) 223 224$(call start_test,tr) 225$(call test_assert,$(call tr,A B C,1 2 3,CAPITAL),31PIT1L) 226$(call test_assert,$(call tr,a b c,1 2 3,CAPITAL),CAPITAL) 227$(call test_assert,$(call tr,E L I,3 1 1,I AM ELITE),1 AM 311T3) 228$(call stop_test) 229 230$(call start_test,leq) 231$(call test_assert,$(call leq,1 2 3,1 2 3),T) 232$(call test_assert,$(call leq,1 2 3,1 2 3 4),) 233$(call test_assert,$(call leq,1 2 3 4,1 2 3),) 234$(call test_assert,$(call leq,1,1),T) 235$(call test_assert,$(call leq,,),T) 236$(call stop_test) 237 238$(call start_test,lne) 239$(call test_assert,$(call lne,1 2 3,1 2 3),) 240$(call test_assert,$(call lne,1 2 3,1 2 3 4),T) 241$(call test_assert,$(call lne,1 2 3 4,1 2 3),T) 242$(call test_assert,$(call lne,1,1),) 243$(call test_assert,$(call lne,,),) 244$(call stop_test) 245 246$(call start_test,empty_set) 247$(call test_assert,$(empty_set),) 248$(call test_assert,$(empty_set),$(call set_create,)) 249$(call stop_test) 250 251$(call start_test,set_create) 252$(call test_assert,$(call set_create,),) 253$(call test_assert,$(call set_create,1 2 2 3),1 2 3) 254$(call test_assert,$(call set_create,2 1 1 2 2 3),1 2 3) 255$(call test_assert,$(call set_create,1),1) 256$(call stop_test) 257 258$(call start_test,set_insert) 259$(call test_assert,$(call set_insert,1,$(empty_set)),1) 260$(call test_assert,$(call set_insert,1,$(call set_create,1)),1) 261$(call test_assert,$(call set_insert,1,$(call set_create,1 2)),1 2) 262$(call test_assert,$(call set_insert,0,$(call set_create,1 2)),0 1 2) 263$(call stop_test) 264 265$(call start_test,set_remove) 266$(call test_assert,$(call set_remove,1,$(empty_set)),$(empty_set)) 267$(call test_assert,$(call set_remove,1,$(call set_create,1 2)),2) 268$(call test_assert,$(call set_remove,1,$(call set_create,1 11 2)),11 2) 269$(call test_assert,$(call set_remove,0,$(call set_create,1 2)),1 2) 270$(call stop_test) 271 272$(call start_test,set_is_member) 273$(call test_assert,$(call set_is_member,1,$(empty_set)),) 274$(call test_assert,$(call set_is_member,1,$(call set_create,2 3)),) 275$(call test_assert,$(call set_is_member,1,$(call set_create,1 2 3)),T) 276$(call test_assert,$(call set_is_member,1,$(call set_create,1)),T) 277$(call stop_test) 278 279$(call start_test,set_union) 280$(call test_assert,$(call set_union,,),) 281$(call test_assert,$(call set_union,1 2,),1 2) 282$(call test_assert,$(call set_union,,3 4),3 4) 283$(call test_assert,$(call set_union,1 2,3 4),1 2 3 4) 284$(call test_assert,$(call set_union,1 2 3,3 4 5),1 2 3 4 5) 285$(call stop_test) 286 287$(call start_test,set_intersection) 288$(call test_assert,$(call set_intersection,,),) 289$(call test_assert,$(call set_intersection,1 2,),) 290$(call test_assert,$(call set_intersection,,3 4),) 291$(call test_assert,$(call set_intersection,1 2,3 4),) 292$(call test_assert,$(call set_intersection,1 2 3 4,3 4 5),3 4) 293$(call stop_test) 294 295$(call start_test,set_is_subset) 296$(call test_assert,$(call set_is_subset,,),T) 297$(call test_assert,$(call set_is_subset,1 2,),) 298$(call test_assert,$(call set_is_subset,,3 4),T) 299$(call test_assert,$(call set_is_subset,1 2,3 4),) 300$(call test_assert,$(call set_is_subset,1 2,1 2 3 4 5),T) 301$(call test_assert,$(call set_is_subset,1 2,1 2),T) 302$(call test_assert,$(call set_is_subset,1 2,1 3 4 5),) 303$(call stop_test) 304 305$(call start_test,set_equal) 306$(call test_assert,$(call set_equal,,),T) 307$(call test_assert,$(call set_equal,1,),) 308$(call test_assert,$(call set_equal,,1),) 309$(call test_assert,$(call set_equal,1,1),T) 310$(call test_assert,$(call set_equal,1 2,),) 311$(call test_assert,$(call set_equal,,1 2),) 312$(call test_assert,$(call set_equal,1 2,1 2 3),) 313$(call stop_test) 314 315$(call start_test,int_encode) 316$(call test_assert,$(call int_encode,0),) 317$(call test_assert,$(call int_encode,1),x) 318$(call test_assert,$(call int_encode,2),x x) 319$(call test_assert,$(call int_encode,10),x x x x x x x x x x) 320$(call stop_test) 321 322$(call start_test,int_decode) 323$(call test_assert,$(call int_decode,),0) 324$(call test_assert,$(call int_decode,x),1) 325$(call test_assert,$(call int_decode,x x),2) 326$(call test_assert,$(call int_decode,x x x x x x x x x x),10) 327$(call stop_test) 328 329$(call start_test,int_plus) 330$(call test_assert,$(call int_plus,$(call int_encode,3),$(call int_encode,4)),$(call int_encode,7)) 331$(call test_assert,$(call int_plus,$(call int_encode,0),$(call int_encode,4)),$(call int_encode,4)) 332$(call test_assert,$(call int_plus,$(call int_encode,3),$(call int_encode,0)),$(call int_encode,3)) 333$(call test_assert,$(call int_plus,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0)) 334$(call test_assert,$(call int_plus,$(call int_encode,1),$(call int_encode,0)),$(call int_encode,1)) 335$(call stop_test) 336 337$(call start_test,plus) 338$(call test_assert,$(call plus,3,4),7) 339$(call test_assert,$(call plus,4,3),7) 340$(call test_assert,$(call plus,0,4),4) 341$(call test_assert,$(call plus,3,0),3) 342$(call test_assert,$(call plus,0,0),0) 343$(call stop_test) 344 345__gmsl_warning = $1 346$(call start_test,int_subtract) 347$(call test_assert,$(call int_subtract,$(call int_encode,3),$(call int_encode,4)),Subtraction underflow) 348$(call test_assert,$(call int_subtract,$(call int_encode,4),$(call int_encode,3)),$(call int_encode,1)) 349$(call test_assert,$(call int_subtract,$(call int_encode,3),$(call int_encode,0)),$(call int_encode,3)) 350$(call test_assert,$(call int_subtract,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0)) 351$(call test_assert,$(call int_subtract,$(call int_encode,1),$(call int_encode,0)),$(call int_encode,1)) 352$(call stop_test) 353 354__gmsl_warning = x x x x x x x x x x 355$(call start_test,subtract) 356$(call test_assert,$(call subtract,3,4),10) 357$(call test_assert,$(call subtract,4,3),1) 358$(call test_assert,$(call subtract,3,0),3) 359$(call test_assert,$(call subtract,0,0),0) 360$(call stop_test) 361 362$(call start_test,int_multiply) 363$(call test_assert,$(call int_multiply,$(call int_encode,3),$(call int_encode,4)),$(call int_encode,12)) 364$(call test_assert,$(call int_multiply,$(call int_encode,4),$(call int_encode,3)),$(call int_encode,12)) 365$(call test_assert,$(call int_multiply,$(call int_encode,3),$(call int_encode,0)),$(call int_encode,0)) 366$(call test_assert,$(call int_multiply,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0)) 367$(call test_assert,$(call int_multiply,$(call int_encode,1),$(call int_encode,0)),$(call int_encode,0)) 368$(call stop_test) 369 370$(call start_test,multiply) 371$(call test_assert,$(call multiply,3,4),12) 372$(call test_assert,$(call multiply,4,3),12) 373$(call test_assert,$(call multiply,3,0),0) 374$(call test_assert,$(call multiply,0,3),0) 375$(call test_assert,$(call multiply,0,0),0) 376$(call stop_test) 377 378__gmsl_error = $1 379$(call start_test,int_divide) 380$(call test_assert,$(call int_divide,$(call int_encode,3),$(call int_encode,4)),$(call int_encode,0)) 381$(call test_assert,$(call int_divide,$(call int_encode,4),$(call int_encode,3)),$(call int_encode,1)) 382$(call test_assert,$(call int_divide,$(call int_encode,31),$(call int_encode,3)),$(call int_encode,10)) 383$(call test_assert,$(call int_divide,$(call int_encode,30),$(call int_encode,3)),$(call int_encode,10)) 384$(call test_assert,$(call int_divide,$(call int_encode,29),$(call int_encode,3)),$(call int_encode,9)) 385$(call test_assert,$(call int_divide,$(call int_encode,0),$(call int_encode,1)),$(call int_encode,0)) 386$(call test_assert,$(call int_divide,$(call int_encode,1),$(call int_encode,0)),Division by zero) 387$(call stop_test) 388 389__gmsl_error = x x x x x x x x x x 390$(call start_test,divide) 391$(call test_assert,$(call divide,3,4),0) 392$(call test_assert,$(call divide,4,3),1) 393$(call test_assert,$(call divide,21,2),10) 394$(call test_assert,$(call divide,20,2),10) 395$(call test_assert,$(call divide,19,2),9) 396$(call test_assert,$(call divide,1,0),10) 397$(call stop_test) 398 399$(call start_test,associative array) 400$(call test_assert,$(call get,myarray,key1),) 401$(call set,myarray,key1,value1) 402$(call test_assert,$(call get,myarray,key1),value1) 403$(call test_assert,$(call get,myarray,key2),) 404$(call test_assert,$(call get,myarray1,key1),) 405$(call test_assert,$(call defined,myarray,key1),T) 406$(call test_assert,$(call defined,myarray,key2),) 407$(call test_assert,$(call defined,myarray1,key1),) 408$(call set,myarray,key2,value2) 409$(call test_assert,$(call keys,myarray),key1 key2) 410$(call test_assert,$(call keys,myarray1),) 411$(call stop_test) 412 413$(call start_test,named stack) 414$(call test_assert,$(call pop,mystack),) 415$(call test_assert,$(call push,mystack,e2)) 416$(call push,mystack,e1) 417$(call test_assert,$(call pop,mystack),e1) 418$(call test_assert,$(call pop,mystack),e2) 419$(call push,mystack,f3) 420$(call push,mystack,f1) 421$(call test_assert,$(call pop,mystack),f1) 422$(call push,mystack,f2) 423$(call test_assert,$(call peek,mystack),f2) 424$(call test_assert,$(call depth,mystack),2) 425$(call test_assert,$(call pop,mystack),f2) 426$(call test_assert,$(call depth,mystack),1) 427$(call test_assert,$(call pop,myotherstack),) 428$(call stop_test) 429 430$(call start_test,reverse) 431$(call test_assert,$(call reverse,),) 432$(call test_assert,$(call reverse,1),1) 433$(call test_assert,$(call reverse,1 2),2 1) 434$(call test_assert,$(call reverse,1 2 3),3 2 1) 435$(call stop_test) 436 437$(call start_test,uniq) 438$(call test_assert,$(call uniq,),) 439$(call test_assert,$(call uniq,a),a) 440$(call test_assert,$(call uniq,a a),a) 441$(call test_assert,$(call uniq,a aa),a aa) 442$(call test_assert,$(call uniq,a aa a),a aa) 443$(call test_assert,$(call uniq,a b ba ab b a a ba a),a b ba ab) 444$(call stop_test) 445 446c:=, 447$(call start_test,split) 448$(call test_assert,$(call split,$c,comma$cseparated$cstring),comma separated string) 449$(call test_assert,$(call split,*,star*field*record),star field record) 450$(call test_assert,$(call split,*,star*),star) 451$(call test_assert,$(call split,*,star*field),star field) 452$(call test_assert,$(call split,*,star****field),star field) 453$(call test_assert,$(call split,*,),) 454$(call stop_test) 455 456$(call start_test,merge) 457$(call test_assert,$(call merge,$c,list of things),list$cof$cthings) 458$(call test_assert,$(call merge,*,list of things),list*of*things) 459$(call test_assert,$(call merge,*,list),list) 460$(call test_assert,$(call merge,*,),) 461$(call stop_test) 462 463$(call start_test,int_max) 464$(call test_assert,$(call int_max,$(call int_encode,2),$(call int_encode,1)),$(call int_encode,2)) 465$(call test_assert,$(call int_max,$(call int_encode,1),$(call int_encode,2)),$(call int_encode,2)) 466$(call test_assert,$(call int_max,$(call int_encode,2),$(call int_encode,0)),$(call int_encode,2)) 467$(call test_assert,$(call int_max,$(call int_encode,0),$(call int_encode,2)),$(call int_encode,2)) 468$(call test_assert,$(call int_max,$(call int_encode,2),$(call int_encode,2)),$(call int_encode,2)) 469$(call test_assert,$(call int_max,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0)) 470$(call stop_test) 471 472$(call start_test,max) 473$(call test_assert,$(call max,2,1),2) 474$(call test_assert,$(call max,1,2),2) 475$(call test_assert,$(call max,2,0),2) 476$(call test_assert,$(call max,0,2),2) 477$(call test_assert,$(call max,2,2),2) 478$(call test_assert,$(call max,0,0),0) 479$(call stop_test) 480 481$(call start_test,int_min) 482$(call test_assert,$(call int_min,$(call int_encode,2),$(call int_encode,1)),$(call int_encode,1)) 483$(call test_assert,$(call int_min,$(call int_encode,1),$(call int_encode,2)),$(call int_encode,1)) 484$(call test_assert,$(call int_min,$(call int_encode,2),$(call int_encode,0)),$(call int_encode,0)) 485$(call test_assert,$(call int_min,$(call int_encode,0),$(call int_encode,2)),$(call int_encode,0)) 486$(call test_assert,$(call int_min,$(call int_encode,2),$(call int_encode,2)),$(call int_encode,2)) 487$(call test_assert,$(call int_min,$(call int_encode,0),$(call int_encode,0)),$(call int_encode,0)) 488$(call stop_test) 489 490$(call start_test,min) 491$(call test_assert,$(call min,2,1),1) 492$(call test_assert,$(call min,1,2),1) 493$(call test_assert,$(call min,2,0),0) 494$(call test_assert,$(call min,0,2),0) 495$(call test_assert,$(call min,2,2),2) 496$(call test_assert,$(call min,0,0),0) 497$(call stop_test) 498 499__gmsl_error = $1 500$(call start_test,assert functions) 501$(call test_assert,$(call assert,$(true),ignore),) 502$(call test_assert,$(call assert,$(false),failed),Assertion failure: failed) 503$(call test_assert,$(call assert_exists,gmsl-tests),) 504$(call test_assert,$(call assert_exists,MISSING-gmsl-tests),Assertion failure: file 'MISSING-gmsl-tests' missing) 505$(call stop_test) 506 507$(call start_test,int_inc) 508$(call test_assert,$(call int_inc,$(call int_encode,0)),$(call int_encode,1)) 509$(call test_assert,$(call int_inc,$(call int_encode,1)),$(call int_encode,2)) 510$(call test_assert,$(call int_inc,$(call int_encode,4)),$(call int_encode,5)) 511$(call test_assert,$(call int_inc,$(call int_encode,10)),$(call int_encode,11)) 512$(call stop_test) 513 514$(call start_test,inc) 515$(call test_assert,$(call inc,0),1) 516$(call test_assert,$(call inc,1),2) 517$(call test_assert,$(call inc,4),5) 518$(call test_assert,$(call inc,10),11) 519$(call stop_test) 520 521__gmsl_warning = $1 522$(call start_test,int_dec) 523$(call test_assert,$(call int_dec,$(call int_encode,0)),Decrement underflow) 524$(call test_assert,$(call int_dec,$(call int_encode,1)),$(call int_encode,0)) 525$(call test_assert,$(call int_dec,$(call int_encode,4)),$(call int_encode,3)) 526$(call test_assert,$(call int_dec,$(call int_encode,10)),$(call int_encode,9)) 527$(call stop_test) 528 529__gmsl_warning = x x x x x x x x x x 530$(call start_test,dec) 531$(call test_assert,$(call dec,0),10) 532$(call test_assert,$(call dec,1),0) 533$(call test_assert,$(call dec,4),3) 534$(call test_assert,$(call dec,10),9) 535$(call stop_test) 536 537$(call start_test,int_double) 538$(call test_assert,$(call int_double,$(call int_encode,0)),$(call int_encode,0)) 539$(call test_assert,$(call int_double,$(call int_encode,1)),$(call int_encode,2)) 540$(call test_assert,$(call int_double,$(call int_encode,4)),$(call int_encode,8)) 541$(call stop_test) 542 543$(call start_test,double) 544$(call test_assert,$(call double,0),0) 545$(call test_assert,$(call double,1),2) 546$(call test_assert,$(call double,4),8) 547$(call stop_test) 548 549$(call start_test,int_halve) 550$(call test_assert,$(call int_halve,$(call int_encode,0)),$(call int_encode,0)) 551$(call test_assert,$(call int_halve,$(call int_encode,2)),$(call int_encode,1)) 552$(call test_assert,$(call int_halve,$(call int_encode,8)),$(call int_encode,4)) 553$(call test_assert,$(call int_halve,$(call int_encode,7)),$(call int_encode,3)) 554$(call stop_test) 555 556$(call start_test,halve) 557$(call test_assert,$(call halve,0),0) 558$(call test_assert,$(call halve,2),1) 559$(call test_assert,$(call halve,8),4) 560$(call test_assert,$(call halve,7),3) 561$(call stop_test) 562 563$(call start_test,gt) 564$(call test_assert,$(call gt,2,3),) 565$(call test_assert,$(call gt,3,2),$(true)) 566$(call test_assert,$(call gt,2,2),) 567$(call stop_test) 568 569$(call start_test,gte) 570$(call test_assert,$(call gte,2,3),) 571$(call test_assert,$(call gte,3,2),$(true)) 572$(call test_assert,$(call gte,2,2),$(true)) 573$(call stop_test) 574 575$(call start_test,lt) 576$(call test_assert,$(call lt,2,3),$(true)) 577$(call test_assert,$(call lt,3,2),) 578$(call test_assert,$(call lt,2,2),) 579$(call stop_test) 580 581$(call start_test,lte) 582$(call test_assert,$(call lte,2,3),$(true)) 583$(call test_assert,$(call lte,3,2),) 584$(call test_assert,$(call lte,2,2),$(true)) 585$(call stop_test) 586 587$(call start_test,eq) 588$(call test_assert,$(call eq,2,3),) 589$(call test_assert,$(call eq,3,2),) 590$(call test_assert,$(call eq,2,2),$(true)) 591$(call stop_test) 592 593$(call start_test,ne) 594$(call test_assert,$(call ne,2,3),$(true)) 595$(call test_assert,$(call ne,3,2),$(true)) 596$(call test_assert,$(call ne,2,2),) 597$(call stop_test) 598 599$(call start_test,int_gt) 600$(call test_assert,$(call int_gt,$(call int_encode,2),$(call int_encode,3)),) 601$(call test_assert,$(call int_gt,$(call int_encode,3),$(call int_encode,2)),$(true)) 602$(call test_assert,$(call int_gt,$(call int_encode,2),$(call int_encode,2)),) 603$(call stop_test) 604 605$(call start_test,int_gte) 606$(call test_assert,$(call int_gte,$(call int_encode,2),$(call int_encode,3)),) 607$(call test_assert,$(call int_gte,$(call int_encode,3),$(call int_encode,2)),$(true)) 608$(call test_assert,$(call int_gte,$(call int_encode,2),$(call int_encode,2)),$(true)) 609$(call stop_test) 610 611$(call start_test,int_lt) 612$(call test_assert,$(call int_lt,$(call int_encode,2),$(call int_encode,3)),$(true)) 613$(call test_assert,$(call int_lt,$(call int_encode,3),$(call int_encode,2)),) 614$(call test_assert,$(call int_lt,$(call int_encode,2),$(call int_encode,2)),) 615$(call stop_test) 616 617$(call start_test,int_lte) 618$(call test_assert,$(call int_lte,$(call int_encode,2),$(call int_encode,3)),$(true)) 619$(call test_assert,$(call int_lte,$(call int_encode,3),$(call int_encode,2)),) 620$(call test_assert,$(call int_lte,$(call int_encode,2),$(call int_encode,2)),$(true)) 621$(call stop_test) 622 623$(call start_test,int_eq) 624$(call test_assert,$(call int_eq,$(call int_encode,2),$(call int_encode,3)),) 625$(call test_assert,$(call int_eq,$(call int_encode,3),$(call int_encode,2)),) 626$(call test_assert,$(call int_eq,$(call int_encode,2),$(call int_encode,2)),$(true)) 627$(call stop_test) 628 629$(call start_test,int_ne) 630$(call test_assert,$(call int_ne,$(call int_encode,2),$(call int_encode,3)),$(true)) 631$(call test_assert,$(call int_ne,$(call int_encode,3),$(call int_encode,2)),$(true)) 632$(call test_assert,$(call int_ne,$(call int_encode,2),$(call int_encode,2)),) 633$(call stop_test) 634 635$(call start_test,gmsl_compatible) 636$(call test_assert,$(call gmsl_compatible,$(gmsl_version)),$(true)) 637$(call test_assert,$(call gmsl_compatible,0 9 0),$(true)) 638$(call test_assert,$(call gmsl_compatible,0 0 1),$(true)) 639$(call test_assert,$(call gmsl_compatible,0 0 0),$(true)) 640$(call test_assert,$(call gmsl_compatible,2 0 0),) 641$(call test_assert,$(call gmsl_compatible,1 1 0),) 642$(call test_assert,$(call gmsl_compatible,1 0 8),$(true)) 643$(call test_assert,$(call gmsl_compatible,1 0 8),$(true)) 644$(call test_assert,$(call gmsl_compatible,1 0 10),$(true)) 645$(call test_assert,$(call gmsl_compatible,1 0 11),$(true)) 646$(call test_assert,$(call gmsl_compatible,1 0 12),) 647$(call stop_test) 648