ycl

Artifact [9f05fed3af]
Login

Artifact [9f05fed3af]

Artifact 9f05fed3aff3f47b7f07a4ce773416012347fdac:


#! /bin/env tclsh

proc suite_main {} {
	package require {ycl list}
	namespace import [yclprefix]::list::sl

	package require {ycl flow gig}
	namespace import [yclprefix]::flow::gig::gig
	namespace import [yclprefix]::flow::gig::route

	package require {ycl test}
	ycl::test::init
	namespace import [yclprefix]::test::cleanup1

	set setup1 {} 

	test basic {} -setup $setup1 -body {
		[gig {0 lindex {solar baby a}} [

			list 0 apply {{} {
				upvar result result
				string totitle $result
			}}] [

			list 0 apply [list args {
				upvar result result
				set [namespace current]::done [lsort -nocase $result]
			} [namespace current]]]]
		vwait [namespace current]::done
		set [namespace current]::done
	} -cleanup [cleanup1] -result {a baby Solar}

	test syntax {} -setup $setup1 -body {
		[gig {0 lindex {solar baby a}} [

			# missing number here 
			list apply {{} {
				upvar result result
				string totitle $result
			}}] [

			list 0 apply [list args {
				upvar result result
				set [namespace current]::done [lsort -nocase $result]
			} [namespace current]]]]
		vwait [namespace current]::done
		set [namespace current]::done
	} -cleanup [cleanup1] -returnCodes 1 -match glob -result {\{bad return mode*}

	test basic2 {} -setup $setup1 -body {
		set gig [gig {0 lindex {solar baby a}}]

		$gig 0 apply {{} {
				upvar result result
				string totitle $result
			}}
		
		$gig 0 apply [list args {
			upvar result result
			set [namespace current]::done [lsort $result]
		} [namespace current]]
		$gig
		vwait [namespace current]::done
		set [namespace current]::done
	} -cleanup [cleanup1] -result {a baby solar}

	test noargs {} -setup $setup1 -body {
		set gig [gig]
		$gig 0 lindex {solar baby a}
		$gig 0 apply [list {} {
			upvar result result
			variable done [lsort $result]
		} [namespace current]]
		after 0 [list after idle [list $gig]]
		vwait [namespace current]::done
		set [namespace current]::done
	} -cleanup [cleanup1] -result {a baby solar}

	test route {} -setup $setup1 -body {
		set gig [gig]
		$gig 0 lindex one
		$gig 0 apply {{} {
			upvar result result
			list $result two
		}}
		$gig 0 apply [list {} {
			upvar result result
			set [namespace current]::done [list {*}$result three]
		} [namespace current]]

		after 0 [list after idle [list $gig]]
		vwait [namespace current]::done
		set [namespace current]::done
	} -cleanup [cleanup1] -result {one two three}

	test error {} -setup $setup1 -body {
		set gig [gig]
		$gig 0 apply {{} {
			return -code error oopsie 
		}}
		$gig 0 apply {{} {
			upvar result result
			list $result two
		}}
		$gig 1 apply [list {} {
			upvar result result
			set [namespace current]::done [list {got an error} {*}$result three]
		} [namespace current]]

		after 0 [list after idle [list $gig]]
		vwait [namespace current]::done
		set [namespace current]::done
	} -cleanup [cleanup1] -result {one two three}

	cleanupTests

}