source: trunk/base/src/darwinports1.0/test_dlist.tcl @ 2426

Last change on this file since 2426 was 2426, checked in by landonf (Landon Fuller), 18 years ago

Allow DarwinPorts to build out of the box on newer Darwin releases with Tcl 8.4

  • Remove references to 'tclsh8.3', replacing them with 'tclsh'. This will work everywhere except FreeBSD
  • Remove compile.sh, link.sh, and tcldir.sh, replacing them with config.sh. config.sh references the config data provided by TEA and allows us to steer clear of autoconf.
  • Modify all Makefiles to use config.sh
  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1#!/usr/bin/env tclsh
2# darwinports1.0/test_dlist.tcl
3#
4# Copyright (c) 2003 Kevin Van Vechten <kevin@opendarwin.org>
5
6# Test suite for darwinports_dlist package.
7
8#lappend auto_path .
9#package require darwinports_dlist 1.0
10source darwinports_dlist.tcl
11
12puts ""
13puts "Testing ditem"
14
15puts -nonewline "Checking ditem_create... "
16if {[catch {ditem_create} ditem] || $ditem == ""} {
17        puts "failed: $ditem"
18} else {
19        puts "ok"
20}
21
22puts -nonewline "Checking ditem_key... "
23if {[catch {ditem_key $ditem provides "foo"} value] || $value != "foo"} {
24        puts "failed: $value"
25} else {
26        puts "ok"
27}
28
29puts -nonewline "Checking ditem_append... "
30if {[catch {ditem_append $ditem provides "bar"} value] || $value != {foo bar}} {
31        puts "failed: $value"
32} else {
33        puts "ok"
34}
35
36puts -nonewline "Checking ditem_contains... "
37set value2 ""
38if {[catch {ditem_contains $ditem provides "foo"} value] || $value != 1 ||
39        [catch {ditem_contains $ditem provides "zzz"} value2] || $value2 != 0} {
40        puts "failed: ${value}\n${value2}"
41} else {
42        puts "ok"
43}
44
45puts ""
46puts "Testing dlist"
47
48puts -nonewline "Checking dlist_search... "
49if {[catch {dlist_search [list $ditem] provides "bar"} value] || $value != $ditem} {
50        puts "failed: $value"
51} else {
52        puts "ok"
53}
54
55puts -nonewline "Checking dlist_has_pending... "
56if {[catch {dlist_has_pending [list $ditem] "foo"} value] || $value != 1} {
57        puts "failed: $value"
58} else {
59        puts "ok"
60}
61
62puts -nonewline "Checking dlist_count_unmet... "
63array set status [list foo 1 bar 0]
64if {[catch {dlist_count_unmet [list] status "foo"} value] || $value != 0 ||
65        [catch {dlist_count_unmet [list] status "bar"} value2] || $value2 != 1} {
66        puts "failed: ${value}\n${value2}"
67} else {
68        puts "ok"
69}
70
71# Replicate Shantonu's Bug #354 to test dlist functionality.
72# <http://www.opendarwin.org/bugzilla/show_bug.cgi?id=354>
73# A depends on B, C.
74# B depends on C.
75# C has no dependencies.
76
77set A [ditem_create]
78ditem_key $A provides A
79ditem_append $A requires B
80ditem_append $A requires C
81
82set B [ditem_create]
83ditem_key $B provides B
84ditem_append $B requires C
85
86set C [ditem_create]
87ditem_key $C provides C
88
89array set status [list]
90puts -nonewline "Checking dlist_get_next... "
91if {[catch {dlist_get_next [list $A $B $C] status} value] || $value != $C} {
92        puts "failed: ${value}"
93} else {
94        puts "ok"
95}
96
97puts -nonewline "Checking dlist_eval... "
98proc handler {ditem} { puts -nonewline "[ditem_key $ditem provides] " }
99if {[catch {dlist_eval [list $A $B $C] handler} value] || $value != {}} {
100        puts "failed: ${value}"
101} else {
102        puts "ok"
103}
104
105puts -nonewline "Checking dlist_append_dependents... "
106if {[catch {dlist_append_dependents [list $A $B $C] $B {}} value] || $value != [list $B $C]} {
107        puts "failed: ${value}"
108} else {
109        puts "ok"
110}
111
112
Note: See TracBrowser for help on using the repository browser.