aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/net/udp.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/world/net/udp.lux')
-rw-r--r--stdlib/source/test/lux/world/net/udp.lux66
1 files changed, 0 insertions, 66 deletions
diff --git a/stdlib/source/test/lux/world/net/udp.lux b/stdlib/source/test/lux/world/net/udp.lux
deleted file mode 100644
index 44765acab..000000000
--- a/stdlib/source/test/lux/world/net/udp.lux
+++ /dev/null
@@ -1,66 +0,0 @@
-(.module:
- [lux #*
- data/text/format
- ["r" math/random (#+ Random)]
- ["_" test (#+ Test)]
- ["." abstract/monad (#+ do)]
- [control
- ["." io]
- [concurrency
- ["." promise]]
- [security
- ["!" capability]]]
- [data
- ["." error]
- ["." text]]
- [world
- ["." binary]
- ["." net]]]
- {1
- ["." /]}
- [///
- ["_." binary]])
-
-(def: localhost net.Address "127.0.0.1")
-(def: port
- (r.Random net.Port)
- (|> r.nat
- (:: r.monad map
- (|>> (n/% 1000)
- (n/+ 8000)))))
-
-(def: #export test
- Test
- (<| (_.context (%name (name-of /._)))
- (do r.monad
- [port ..port
- size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
- from (_binary.binary size)
- to (_binary.binary size)]
- ($_ _.and
- (wrap (do promise.monad
- [result (promise.future
- (do (error.with io.monad)
- [server (/.server port)
- client /.client
- ####################
- _ (!.use (:: client write) [[localhost port] from])
- [bytes-from [from-address from-port] temp] (!.use (:: server read) size)
- #let [from-worked? (and (n/= size bytes-from)
- (:: binary.equivalence = from temp))]
- ####################
- _ (!.use (:: server write) [[from-address from-port] to])
- [bytes-to [to-address to-port] temp] (!.use (:: client read) size)
- #let [to-worked? (and (n/= size bytes-to)
- (:: binary.equivalence = to temp)
- (n/= port to-port))]
- ####################
- _ (!.use (:: client close) [])
- _ (!.use (:: server close) [])]
- ## (wrap false)
- (wrap (and from-worked?
- to-worked?))
- ))]
- (_.assert "Can communicate between client and server."
- (error.default #0 result))))
- ))))