Skip to content

Commit b96d1e9

Browse files
Move URI examples to tests
1 parent f1f777e commit b96d1e9

File tree

3 files changed

+67
-33
lines changed

3 files changed

+67
-33
lines changed

examples/stdlib/io/uri.check

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/ !
2+
Hallo Welt!/&^$@^*(&$)(*!_!_+")
3+
Hallo%20Welt%21%2F%26^%24%40^%2A%28%26%24%29%28%2A%21_%21_%2B"%29
4+
Hallo Welt!/&^$@^*(&$)(*!_!_+")
5+
Hallo%20Welt%21%2F%26%5E%24%40%5E%2A%28%26%24%29%28%2A%21_%21_%2B%22%29
6+
ftp://ftp.is.co.za/rfc/rfc1808.txt
7+
Scheme: ftp
8+
Host: ftp.is.co.za
9+
Path: /rfc/rfc1808.txt
10+
http://www.ietf.org/rfc/rfc2396.txt
11+
Scheme: http
12+
Host: www.ietf.org
13+
Path: /rfc/rfc2396.txt
14+
ldap://[2001:db8::7]/c=GB?objectClass?one
15+
Scheme: ldap
16+
Host: [2001:db8::7]
17+
Path: /c=GB
18+
Query: objectClass?one
19+
20+
Scheme: mailto
21+
22+
news:comp.infosystems.www.servers.unix
23+
Scheme: news
24+
Path: comp.infosystems.www.servers.unix
25+
tel:+1-816-555-1212
26+
Scheme: tel
27+
Path: +1-816-555-1212
28+
telnet://192.0.2.16:80/
29+
Scheme: telnet
30+
Host: 192.0.2.16
31+
Port: 80
32+
Path: /
33+
urn:oasis:names:specification:docbook:dtd:xml:4.1
34+
Scheme: urn
35+
Path: oasis:names:specification:docbook:dtd:xml:4.1

examples/stdlib/io/uri.effekt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import io/uri
2+
3+
def report(uri: String): Unit = {
4+
with on[WrongFormat].panic
5+
println(uri)
6+
try parseURI(uri) with URIBuilder {
7+
def scheme(s) = resume(println(" Scheme: " ++ s))
8+
def userinfo(u) = resume(println(" Userinfo: " ++ u))
9+
def host(h) = resume(println(" Host: " ++ h))
10+
def path(p) = resume(println(" Path: " ++ p))
11+
def port(p) = resume(println(" Port: " ++ p.show))
12+
def query(q) = resume(println(" Query: " ++ q))
13+
def fragment(q) = resume(println(" Fragment: " ++ q))
14+
}
15+
}
16+
def main() = {
17+
println(urldecode("%2F%20%20!"))
18+
println(urldecode(urlencode("Hallo Welt!/&^$@^*(&$)(*!_!_+\")")))
19+
println(urlencode("Hallo Welt!/&^$@^*(&$)(*!_!_+\")"))
20+
println(urldecode(urlencodeStrict("Hallo Welt!/&^$@^*(&$)(*!_!_+\")")))
21+
println(urlencodeStrict("Hallo Welt!/&^$@^*(&$)(*!_!_+\")"))
22+
23+
// examples from the spec
24+
report("ftp://ftp.is.co.za/rfc/rfc1808.txt")
25+
report("http://www.ietf.org/rfc/rfc2396.txt")
26+
report("ldap://[2001:db8::7]/c=GB?objectClass?one")
27+
report("mailto:[email protected]")
28+
report("news:comp.infosystems.www.servers.unix")
29+
report("tel:+1-816-555-1212")
30+
report("telnet://192.0.2.16:80/")
31+
report("urn:oasis:names:specification:docbook:dtd:xml:4.1")
32+
}

libraries/common/io/uri.effekt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -215,37 +215,4 @@ def parseURI(uri: String): Unit / { URIBuilder, Exception[WrongFormat] } = {
215215
} with stop { () =>
216216
do raise(WrongFormat(), "Could not parse URI")
217217
}
218-
}
219-
220-
namespace example {
221-
def report(uri: String): Unit = {
222-
with on[WrongFormat].panic
223-
println(uri)
224-
try parseURI(uri) with URIBuilder {
225-
def scheme(s) = resume(println(" Scheme: " ++ s))
226-
def userinfo(u) = resume(println(" Userinfo: " ++ u))
227-
def host(h) = resume(println(" Host: " ++ h))
228-
def path(p) = resume(println(" Path: " ++ p))
229-
def port(p) = resume(println(" Port: " ++ p.show))
230-
def query(q) = resume(println(" Query: " ++ q))
231-
def fragment(q) = resume(println(" Fragment: " ++ q))
232-
}
233-
}
234-
def main() = {
235-
println(urldecode("%2F%20%20!"))
236-
println(urldecode(urlencode("Hallo Welt!/&^$@^*(&$)(*!_!_+\")")))
237-
println(urlencode("Hallo Welt!/&^$@^*(&$)(*!_!_+\")"))
238-
println(urldecode(urlencodeStrict("Hallo Welt!/&^$@^*(&$)(*!_!_+\")")))
239-
println(urlencodeStrict("Hallo Welt!/&^$@^*(&$)(*!_!_+\")"))
240-
241-
// examples from the spec
242-
report("ftp://ftp.is.co.za/rfc/rfc1808.txt")
243-
report("http://www.ietf.org/rfc/rfc2396.txt")
244-
report("ldap://[2001:db8::7]/c=GB?objectClass?one")
245-
report("mailto:[email protected]")
246-
report("news:comp.infosystems.www.servers.unix")
247-
report("tel:+1-816-555-1212")
248-
report("telnet://192.0.2.16:80/")
249-
report("urn:oasis:names:specification:docbook:dtd:xml:4.1")
250-
}
251218
}

0 commit comments

Comments
 (0)