public void Eval_IdentifiersAndKeywordsCoexistIndependently() { _env.Bind(ClSymbol.And, Value.One); var expr = BuiltIn.ListOf(ClSymbol.And, ClBool.True, Value.Foo); Assert.That(ClSymbol.And.Reduce(_ctx).Value, Is.EqualTo(Value.One)); Assert.That(expr.Reduce(_ctx).Value, Is.EqualTo(Value.Foo)); }
public void EvalApplication_ThrowInvalidFunctionCall_WhenCarIsNotCallable() { _env.Bind(Var.Fn, Value.One); var expr = BuiltIn.ListOf(Var.Fn, Value.One); var errorMessage = $"{nameof(ClInt)} is neither callable nor special from"; Assert.That(() => expr.Reduce(_ctx), Throws.Exception.TypeOf <SyntaxError>().With.Message.EqualTo(errorMessage)); }
public void EvalDefinition_CreateSharedReference() { _env.Bind(Var.Bar, Value.Bar); var expr = BuiltIn.ListOf(ClSymbol.Define, Var.Foo, Var.Bar); Ignore(expr.Reduce(_ctx)); Assert.That(Object.ReferenceEquals(_env.Lookup(Var.Foo), _env.Lookup(Var.Bar)), Is.True); }
public async Task Run() { using (var socket = await _env.Bind(_port)) { while (!_env.Token.IsCancellationRequested) { var conn = await socket.Accept(); HandleAsync(conn); } } }
async Task EventLoop() { try { using (var socket = await _env.Bind(_port)) { while (!_env.Token.IsCancellationRequested) { var conn = await socket.Accept(); HandleRequest(conn); } } } catch (TaskCanceledException) { return; } }
public void EvalAssignment_SharedReference() { _env.Bind(Var.Foo, Value.Foo); _env.Bind(Var.Bar, Value.Bar); var expr = BuiltIn.ListOf(ClSymbol.Set, Var.Foo, Var.Bar); var ctx = expr.Reduce(_ctx); Assert.That(Object.ReferenceEquals(ctx.Env.Lookup(Var.Foo), _env.Lookup(Var.Bar)), Is.True); }
public static Task <ISocket> Bind(this IEnv env, ushort port) { return(env.Bind(port, Timeout.InfiniteTimeSpan)); }