-
-
Save malthe/a0232817937a54eea8f7c0b5d6dfdcd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use "promises" | |
use "ponytest" | |
class val IPEndpoint | |
"""Represents a host and service name. | |
The endpoint can be resolved to an IP address. | |
""" | |
let _host: String | |
let _service: String | |
let _promise: Promise[IPAddress] = _promise.create() | |
new create(host: String, service: String) => | |
_host = host | |
_service = service | |
fun ref resolve(): Promise[IPAddress] => | |
// To-Do: Actually spawn an asynchronous `getaddrinfo_a` call and | |
//somehow connect the result to the promise. | |
_promise(IPAddress) | |
_promise | |
class iso _IPEndpointTest is UnitTest | |
fun name(): String => "net/IPEndpoint" | |
fun ref apply(h: TestHelper) => | |
let endpoint = IPEndpoint("localhost", "25") | |
let p = endpoint.resolve() | |
.next[String]( | |
recover lambda(ip_address: IPAddress)(x: U32 = 42): String => ip_address.string() end end | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment