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

Last change on this file since 2081 was 2081, checked in by kevin, 18 years ago

Added darwinports_dlist package for dependency list evaluation in both the
DarwinPorts API and Port API.

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1#!/usr/bin/env tclsh8.3
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... "
37if {[catch {ditem_contains $ditem provides "foo"} value] || $value != 1 ||
38        [catch {ditem_contains $ditem provides "zzz"} value2] || $value2 != 0} {
39        puts "failed: ${value}\n${value2}"
40} else {
41        puts "ok"
42}
43
44puts ""
45puts "Testing dlist"
46
47puts -nonewline "Checking dlist_search... "
48if {[catch {dlist_search [list $ditem] provides "bar"} value] || $value != $ditem} {
49        puts "failed: $value"
50} else {
51        puts "ok"
52}
53
54puts -nonewline "Checking dlist_has_pending... "
55if {[catch {dlist_has_pending [list $ditem] "foo"} value] || $value != 1} {
56        puts "failed: $value"
57} else {
58        puts "ok"
59}
60
61puts -nonewline "Checking dlist_count_unmet... "
62array set status [list foo 1 bar 0]
63if {[catch {dlist_count_unmet [list] status "foo"} value] || $value != 0 ||
64        [catch {dlist_count_unmet [list] status "bar"} value2] || $value2 != 1} {
65        puts "failed: ${value}\n${value2}"
66} else {
67        puts "ok"
68}
69
70# Replicate Shantonu's Bug #354 to test dlist functionality.
71# <http://www.opendarwin.org/bugzilla/show_bug.cgi?id=354>
72# A depends on B, C.
73# B depends on C.
74# C has no dependencies.
75
76set A [ditem_create]
77ditem_key $A provides A
78ditem_append $A requires B
79ditem_append $A requires C
80
81set B [ditem_create]
82ditem_key $B provides B
83ditem_append $B requires C
84
85set C [ditem_create]
86ditem_key $C provides C
87
88array set status [list]
89puts -nonewline "Checking dlist_get_next... "
90if {[catch {dlist_get_next [list $A $B $C] status} value] || $value != $C} {
91        puts "failed: ${value}"
92} else {
93        puts "ok"
94}
95
96puts -nonewline "Checking dlist_eval... "
97proc handler {ditem} { puts -nonewline "[ditem_key $ditem provides] " }
98if {[catch {dlist_eval [list $A $B $C] handler} value] || $value != {}} {
99        puts "failed: ${value}"
100} else {
101        puts "ok"
102}
103
104puts -nonewline "Checking dlist_append_dependents... "
105if {[catch {dlist_append_dependents [list $A $B $C] $B {}} value] || $value != [list $B $C]} {
106        puts "failed: ${value}"
107} else {
108        puts "ok"
109}
110
111
Note: See TracBrowser for help on using the repository browser.