# -*- tcl -*-
# ------------------------------------------------------------------------------

source [file join \
	[file dirname [file dirname [file join [pwd] [info script]]]] \
	devtools testutilities.tcl]

testsNeedTcl     8.2
testsNeedTcltest 1.0

testing {
    useLocal uri.tcl uri
}

# ------------------------------------------------------------------------------
# 2016-12-16 to 2017-01-09 revisions (KJN)
# ------------------------------------------------------------------------------
# (1) Test results corrected to match RFC 3986 Sec. 5.4.1 for tests:
#     uri-rfc2396-1.7 uri-rfc2396-1.9 uri-rfc2396-2.7 uri-rfc2396-2.9
# (2) Add tests uri-rfc2396-1.14a uri-rfc2396-2.14a from the list in RFC 3986.
# (3) All tests now pass: existing "knownBug" constraints removed.
# (4) Add tests uri-rfc2396-3.*, uri-rfc2396-4.* for different cases of query
#     and fragment.
# (5) Add tests uri-rfc2396-5.*, uri-rfc2396-8.* for uri::resolve without
#     explicit call to uri::canonicalize.
# (6) Add tests uri-rfc2396-11.*,  uri-rfc2396-12.* from RFC 3986 Sec. 5.4.2
#     "Abnormal Examples".
# (7) Tests uri-rfc2396-11.19, uri-rfc2396-12.19 fail - new "knownBug"
#     constraints and explanation added.
# ------------------------------------------------------------------------------

# Test the "Normal Examples" from RFC 3986 Sec. 5.4.1.

test uri-rfc2396-1.1 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g:h]
} g:h

test uri-rfc2396-1.2 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g]
} http://a/b/c/g

test uri-rfc2396-1.3 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ./g]
} http://a/b/c/g

test uri-rfc2396-1.4 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g/]
} http://a/b/c/g/

test uri-rfc2396-1.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q /g]
} http://a/g

test uri-rfc2396-1.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q //g]
} http://g

test uri-rfc2396-1.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ?y]
} {http://a/b/c/d;p?y}

test uri-rfc2396-1.8 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g?y]
} http://a/b/c/g?y

test uri-rfc2396-1.9 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q \#s]
} {http://a/b/c/d;p?q#s}

test uri-rfc2396-1.10 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g\#s]
} http://a/b/c/g#s

test uri-rfc2396-1.11 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g?y\#s]
} http://a/b/c/g?y#s

test uri-rfc2396-1.12 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q \;x]
} {http://a/b/c/;x}

test uri-rfc2396-1.13 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g\;x]
} {http://a/b/c/g;x}

test uri-rfc2396-1.14 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g\;x?y#s]
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-1.14a {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q {}]
} {http://a/b/c/d;p?q}

test uri-rfc2396-1.15 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q .]
} http://a/b/c/

test uri-rfc2396-1.16 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ./]
} http://a/b/c/

test uri-rfc2396-1.17 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ..]
} http://a/b/

test uri-rfc2396-1.18 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../]
} http://a/b/

test uri-rfc2396-1.19 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../g]
} http://a/b/g

test uri-rfc2396-1.20 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../..]
} http://a/

test uri-rfc2396-1.21 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../../]
} http://a/

test uri-rfc2396-1.22 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../../g]
} http://a/g


# Cf. the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# The tests below are similar, but the base URL omits the query-string "?q".

test uri-rfc2396-2.1 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g:h]
} g:h

test uri-rfc2396-2.2 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g]
} http://a/b/c/g

test uri-rfc2396-2.3 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ./g]
} http://a/b/c/g

test uri-rfc2396-2.4 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g/]
} http://a/b/c/g/

test uri-rfc2396-2.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p /g]
} http://a/g

test uri-rfc2396-2.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p //g]
} http://g

test uri-rfc2396-2.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ?y]
} {http://a/b/c/d;p?y}

test uri-rfc2396-2.8 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g?y]
} http://a/b/c/g?y

test uri-rfc2396-2.9 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p \#s]
} {http://a/b/c/d;p#s}

test uri-rfc2396-2.10 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g\#s]
} http://a/b/c/g#s

test uri-rfc2396-2.11 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g?y\#s]
} http://a/b/c/g?y#s

test uri-rfc2396-2.12 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p \;x]
} {http://a/b/c/;x}

test uri-rfc2396-2.13 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g\;x]
} {http://a/b/c/g;x}

test uri-rfc2396-2.14 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p g\;x?y#s]
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-2.14a {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p {}]
} {http://a/b/c/d;p}

test uri-rfc2396-2.15 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p .]
} http://a/b/c/

test uri-rfc2396-2.16 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ./]
} http://a/b/c/

test uri-rfc2396-2.17 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ..]
} http://a/b/

test uri-rfc2396-2.18 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ../]
} http://a/b/

test uri-rfc2396-2.19 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ../g]
} http://a/b/g

test uri-rfc2396-2.20 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ../..]
} http://a/

test uri-rfc2396-2.21 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ../../]
} http://a/

test uri-rfc2396-2.22 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p ../../g]
} http://a/g

# Cf. the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# The tests below are similar, but the base URL has a fragment #f

test uri-rfc2396-3.1 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g:h]
} g:h

test uri-rfc2396-3.2 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g]
} http://a/b/c/g

test uri-rfc2396-3.3 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ./g]
} http://a/b/c/g

test uri-rfc2396-3.4 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g/]
} http://a/b/c/g/

test uri-rfc2396-3.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f /g]
} http://a/g

test uri-rfc2396-3.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f //g]
} http://g

test uri-rfc2396-3.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ?y]
} {http://a/b/c/d;p?y}

test uri-rfc2396-3.8 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g?y]
} http://a/b/c/g?y

test uri-rfc2396-3.9 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f \#s]
} {http://a/b/c/d;p?q#s}

test uri-rfc2396-3.10 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g\#s]
} http://a/b/c/g#s

test uri-rfc2396-3.11 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g?y\#s]
} http://a/b/c/g?y#s

test uri-rfc2396-3.12 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f \;x]
} {http://a/b/c/;x}

test uri-rfc2396-3.13 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g\;x]
} {http://a/b/c/g;x}

test uri-rfc2396-3.14 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f g\;x?y#s]
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-3.14a {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f {}]
} {http://a/b/c/d;p?q}

test uri-rfc2396-3.15 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f .]
} http://a/b/c/

test uri-rfc2396-3.16 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ./]
} http://a/b/c/

test uri-rfc2396-3.17 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ..]
} http://a/b/

test uri-rfc2396-3.18 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ../]
} http://a/b/

test uri-rfc2396-3.19 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ../g]
} http://a/b/g

test uri-rfc2396-3.20 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ../..]
} http://a/

test uri-rfc2396-3.21 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ../../]
} http://a/

test uri-rfc2396-3.22 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q#f ../../g]
} http://a/g


# Cf. the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# The tests below are similar, but the base URL omits the query-string "?q" and has a fragment #f.

test uri-rfc2396-4.1 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g:h]
} g:h

test uri-rfc2396-4.2 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g]
} http://a/b/c/g

test uri-rfc2396-4.3 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ./g]
} http://a/b/c/g

test uri-rfc2396-4.4 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g/]
} http://a/b/c/g/

test uri-rfc2396-4.5 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f /g]
} http://a/g

test uri-rfc2396-4.6 {uri::resolve} {} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f //g]
} http://g

test uri-rfc2396-4.7 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ?y]
} {http://a/b/c/d;p?y}

test uri-rfc2396-4.8 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g?y]
} http://a/b/c/g?y

test uri-rfc2396-4.9 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f \#s]
} {http://a/b/c/d;p#s}

test uri-rfc2396-4.10 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g\#s]
} http://a/b/c/g#s

test uri-rfc2396-4.11 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g?y\#s]
} http://a/b/c/g?y#s

test uri-rfc2396-4.12 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f \;x]
} {http://a/b/c/;x}

test uri-rfc2396-4.13 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g\;x]
} {http://a/b/c/g;x}

test uri-rfc2396-4.14 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f g\;x?y#s]
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-4.14a {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f {}]
} {http://a/b/c/d;p}

test uri-rfc2396-4.15 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f .]
} http://a/b/c/

test uri-rfc2396-4.16 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ./]
} http://a/b/c/

test uri-rfc2396-4.17 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ..]
} http://a/b/

test uri-rfc2396-4.18 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ../]
} http://a/b/

test uri-rfc2396-4.19 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ../g]
} http://a/b/g

test uri-rfc2396-4.20 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ../..]
} http://a/

test uri-rfc2396-4.21 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ../../]
} http://a/

test uri-rfc2396-4.22 {uri::resolve} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p#f ../../g]
} http://a/g

# Test the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# Without explicit canonicalization.

test uri-rfc2396-5.1 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g:h
} g:h

test uri-rfc2396-5.2 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g
} http://a/b/c/g

test uri-rfc2396-5.3 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ./g
} http://a/b/c/g

test uri-rfc2396-5.4 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g/
} http://a/b/c/g/

test uri-rfc2396-5.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q /g
} http://a/g

test uri-rfc2396-5.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p?q //g
} http://g

test uri-rfc2396-5.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ?y
} {http://a/b/c/d;p?y}

test uri-rfc2396-5.8 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g?y
} http://a/b/c/g?y

test uri-rfc2396-5.9 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q \#s
} {http://a/b/c/d;p?q#s}

test uri-rfc2396-5.10 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g\#s
} http://a/b/c/g#s

test uri-rfc2396-5.11 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g?y\#s
} http://a/b/c/g?y#s

test uri-rfc2396-5.12 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q \;x
} {http://a/b/c/;x}

test uri-rfc2396-5.13 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g\;x
} {http://a/b/c/g;x}

test uri-rfc2396-5.14 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q g\;x?y#s
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-5.14a {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q {}
} {http://a/b/c/d;p?q}

test uri-rfc2396-5.15 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q .
} http://a/b/c/

test uri-rfc2396-5.16 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ./
} http://a/b/c/

test uri-rfc2396-5.17 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ..
} http://a/b/

test uri-rfc2396-5.18 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ../
} http://a/b/

test uri-rfc2396-5.19 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ../g
} http://a/b/g

test uri-rfc2396-5.20 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ../..
} http://a/

test uri-rfc2396-5.21 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ../../
} http://a/

test uri-rfc2396-5.22 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q ../../g
} http://a/g


# Cf. the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# The tests below are similar, but the base URL omits the query-string "?q".
# Without explicit canonicalization.

test uri-rfc2396-6.1 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g:h
} g:h

test uri-rfc2396-6.2 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g
} http://a/b/c/g

test uri-rfc2396-6.3 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ./g
} http://a/b/c/g

test uri-rfc2396-6.4 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g/
} http://a/b/c/g/

test uri-rfc2396-6.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p /g
} http://a/g

test uri-rfc2396-6.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p //g
} http://g

test uri-rfc2396-6.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ?y
} {http://a/b/c/d;p?y}

test uri-rfc2396-6.8 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g?y
} http://a/b/c/g?y

test uri-rfc2396-6.9 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p \#s
} {http://a/b/c/d;p#s}

test uri-rfc2396-6.10 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g\#s
} http://a/b/c/g#s

test uri-rfc2396-6.11 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g?y\#s
} http://a/b/c/g?y#s

test uri-rfc2396-6.12 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p \;x
} {http://a/b/c/;x}

test uri-rfc2396-6.13 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g\;x
} {http://a/b/c/g;x}

test uri-rfc2396-6.14 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p g\;x?y#s
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-6.14a {uri::resolve} {
    uri::resolve http://a/b/c/d\;p {}
} {http://a/b/c/d;p}

test uri-rfc2396-6.15 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p .
} http://a/b/c/

test uri-rfc2396-6.16 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ./
} http://a/b/c/

test uri-rfc2396-6.17 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ..
} http://a/b/

test uri-rfc2396-6.18 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ../
} http://a/b/

test uri-rfc2396-6.19 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ../g
} http://a/b/g

test uri-rfc2396-6.20 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ../..
} http://a/

test uri-rfc2396-6.21 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ../../
} http://a/

test uri-rfc2396-6.22 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p ../../g
} http://a/g

# Cf. the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# The tests below are similar, but the base URL has a fragment #f
# Without explicit canonicalization.

test uri-rfc2396-7.1 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g:h
} g:h

test uri-rfc2396-7.2 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g
} http://a/b/c/g

test uri-rfc2396-7.3 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ./g
} http://a/b/c/g

test uri-rfc2396-7.4 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g/
} http://a/b/c/g/

test uri-rfc2396-7.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f /g
} http://a/g

test uri-rfc2396-7.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p?q#f //g
} http://g

test uri-rfc2396-7.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ?y
} {http://a/b/c/d;p?y}

test uri-rfc2396-7.8 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g?y
} http://a/b/c/g?y

test uri-rfc2396-7.9 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f \#s
} {http://a/b/c/d;p?q#s}

test uri-rfc2396-7.10 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g\#s
} http://a/b/c/g#s

test uri-rfc2396-7.11 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g?y\#s
} http://a/b/c/g?y#s

test uri-rfc2396-7.12 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f \;x
} {http://a/b/c/;x}

test uri-rfc2396-7.13 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g\;x
} {http://a/b/c/g;x}

test uri-rfc2396-7.14 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f g\;x?y#s
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-7.14a {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f {}
} {http://a/b/c/d;p?q}

test uri-rfc2396-7.15 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f .
} http://a/b/c/

test uri-rfc2396-7.16 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ./
} http://a/b/c/

test uri-rfc2396-7.17 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ..
} http://a/b/

test uri-rfc2396-7.18 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ../
} http://a/b/

test uri-rfc2396-7.19 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ../g
} http://a/b/g

test uri-rfc2396-7.20 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ../..
} http://a/

test uri-rfc2396-7.21 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ../../
} http://a/

test uri-rfc2396-7.22 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p?q#f ../../g
} http://a/g

# Cf. the "Normal Examples" from RFC 3986 Sec. 5.4.1.
# The tests below are similar, but the base URL omits the query-string "?q" and has a fragment #f.
# Without explicit canonicalization.

test uri-rfc2396-8.1 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g:h
} g:h

test uri-rfc2396-8.2 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g
} http://a/b/c/g

test uri-rfc2396-8.3 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ./g
} http://a/b/c/g

test uri-rfc2396-8.4 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g/
} http://a/b/c/g/

test uri-rfc2396-8.5 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f /g
} http://a/g

test uri-rfc2396-8.6 {uri::resolve} {} {
    uri::resolve http://a/b/c/d\;p#f //g
} http://g

test uri-rfc2396-8.7 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ?y
} {http://a/b/c/d;p?y}

test uri-rfc2396-8.8 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g?y
} http://a/b/c/g?y

test uri-rfc2396-8.9 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f \#s
} {http://a/b/c/d;p#s}

test uri-rfc2396-8.10 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g\#s
} http://a/b/c/g#s

test uri-rfc2396-8.11 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g?y\#s
} http://a/b/c/g?y#s

test uri-rfc2396-8.12 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f \;x
} {http://a/b/c/;x}

test uri-rfc2396-8.13 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g\;x
} {http://a/b/c/g;x}

test uri-rfc2396-8.14 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f g\;x?y#s
} {http://a/b/c/g;x?y#s}

test uri-rfc2396-8.14a {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f {}
} {http://a/b/c/d;p}

test uri-rfc2396-8.15 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f .
} http://a/b/c/

test uri-rfc2396-8.16 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ./
} http://a/b/c/

test uri-rfc2396-8.17 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ..
} http://a/b/

test uri-rfc2396-8.18 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ../
} http://a/b/

test uri-rfc2396-8.19 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ../g
} http://a/b/g

test uri-rfc2396-8.20 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ../..
} http://a/

test uri-rfc2396-8.21 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ../../
} http://a/

test uri-rfc2396-8.22 {uri::resolve} {
    uri::resolve http://a/b/c/d\;p#f ../../g
} http://a/g


# Now tests from RFC 3986 Sec. 5.4.2. "Abnormal Examples".

test uri-rfc2396-11.1  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../../../g]
} http://a/g

test uri-rfc2396-11.2  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ../../../../g]
} http://a/g

test uri-rfc2396-11.3  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q /./g]
} http://a/g

test uri-rfc2396-11.4  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q /../g]
} http://a/g

test uri-rfc2396-11.5  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g.]
} http://a/b/c/g.

test uri-rfc2396-11.6  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q .g]
} http://a/b/c/.g

test uri-rfc2396-11.7  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g..]
} http://a/b/c/g..

test uri-rfc2396-11.8  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ..g]
} http://a/b/c/..g

test uri-rfc2396-11.9  {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ./../g]
} http://a/b/g

test uri-rfc2396-11.10 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q ./g/.]
} http://a/b/c/g/

test uri-rfc2396-11.11 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g/./h]
} http://a/b/c/g/h

test uri-rfc2396-11.12 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g/../h]
} http://a/b/c/h

test uri-rfc2396-11.13 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g\;x=1/./y]
} {http://a/b/c/g;x=1/y}

test uri-rfc2396-11.14 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g\;x=1/../y]
} http://a/b/c/y

test uri-rfc2396-11.15 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g?y/./x]
} http://a/b/c/g?y/./x

test uri-rfc2396-11.16 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g?y/../x]
} http://a/b/c/g?y/../x

test uri-rfc2396-11.17 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g#s/./x]
} http://a/b/c/g#s/./x

test uri-rfc2396-11.18 {uri::resolve abnormal examples} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q g#s/../x]
} http://a/b/c/g#s/../x

test uri-rfc2396-11.19 {uri::resolve abnormal examples
    RFC 3986 Sec. 5.4.2 advises avoiding this usage which is a loophole
    in RFC 1630, which allows a relative URI to specify the scheme if it
    is the same as the scheme of the base URI.
    uri::resolve is a "strict parser" in the sense of RFC 3986 Sec. 5.2.2:
    however, it does not handle the loophole correctly and fails this test.
} {knownBug rfc1630-loophole-avoid-use} {
    uri::canonicalize [uri::resolve http://a/b/c/d\;p?q http:g]
} http:g

# Cf. tests from RFC 3986 Sec. 5.4.2. "Abnormal Examples".
# Without explicit canonicalization.

test uri-rfc2396-12.1  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q ../../../g
} http://a/g

test uri-rfc2396-12.2  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q ../../../../g
} http://a/g

test uri-rfc2396-12.3  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q /./g
} http://a/g

test uri-rfc2396-12.4  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q /../g
} http://a/g

test uri-rfc2396-12.5  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g.
} http://a/b/c/g.

test uri-rfc2396-12.6  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q .g
} http://a/b/c/.g

test uri-rfc2396-12.7  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g..
} http://a/b/c/g..

test uri-rfc2396-12.8  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q ..g
} http://a/b/c/..g

test uri-rfc2396-12.9  {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q ./../g
} http://a/b/g

test uri-rfc2396-12.10 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q ./g/.
} http://a/b/c/g/

test uri-rfc2396-12.11 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g/./h
} http://a/b/c/g/h

test uri-rfc2396-12.12 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g/../h
} http://a/b/c/h

test uri-rfc2396-12.13 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g\;x=1/./y
} {http://a/b/c/g;x=1/y}

test uri-rfc2396-12.14 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g\;x=1/../y
} http://a/b/c/y

test uri-rfc2396-12.15 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g?y/./x
} http://a/b/c/g?y/./x

test uri-rfc2396-12.16 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g?y/../x
} http://a/b/c/g?y/../x

test uri-rfc2396-12.17 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g#s/./x
} http://a/b/c/g#s/./x

test uri-rfc2396-12.18 {uri::resolve abnormal examples} {
    uri::resolve http://a/b/c/d\;p?q g#s/../x
} http://a/b/c/g#s/../x

test uri-rfc2396-12.19 {uri::resolve abnormal examples
    RFC 3986 Sec. 5.4.2 advises avoiding this usage which is a loophole
    in RFC 1630, which allows a relative URI to specify the scheme if it
    is the same as the scheme of the base URI.
    uri::resolve is a "strict parser" in the sense of RFC 3986 Sec. 5.2.2:
    however, it does not handle the loophole correctly and fails this test.
} {knownBug rfc1630-loophole-avoid-use} {
    uri::resolve http://a/b/c/d\;p?q http:g
} http:g



# ------------------------------------------------------------------------------

testsuiteCleanup
return

# ------------------------------------------------------------------------------
# Local Variables:
#   mode: tcl
#   indent-tabs-mode: nil
# End: