Ejemplo n.º 1
0
        public IInterpreter ChannelDeadLockOnReceive()
        {
            var interpreter = new Interpreter.Interpreter();

            foreach (var mutability in Options.AllMutabilityModes)
            {
                var env = Language.Environment.Create(new Options()
                {
                    AllowInvalidMainResult = true
                }.SetMutability(mutability));
                var root_ns = env.Root;

                root_ns.AddBuilder(FunctionBuilder.Create(
                                       "main",
                                       ExpressionReadMode.OptionalUse,
                                       NameFactory.Int64NameReference(),
                                       Block.CreateStatement(new IExpression[] {
                    VariableDeclaration.CreateStatement("ch", null,
                                                        ExpressionFactory.HeapConstructor(NameFactory.ChannelNameReference(NameFactory.Int64NameReference()))),
                    ExpressionFactory.Readout(FunctionCall.Create(NameReference.Create("ch", NameFactory.ChannelReceive))),
                    Return.Create(Int64Literal.Create("0"))
                })));

                int task_id = Task.WaitAny(Task.Delay(TimeSpan.FromSeconds(Interpreter.Interpreter.TimeoutSeconds)), interpreter.TestRunAsync(env));
                Assert.AreEqual(0, task_id);
            }

            return(interpreter);
        }