public void InvalidVariableInNegationTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Control, 0, 0, "!")); ass.Add(new Token(TokenType.Name, 0, 0, "bar")); }
public void InvalidLiteralInNegationTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Control, 0, 0, "!")); ass.Add(new Token(TokenType.Number, 0, 0, "4")); }
public void InvalidOperatorTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Number, 0, 0, "15")); ass.Add(new Token(TokenType.Control, 0, 0, ")")); }
public void UndefinedVariableInNegationTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Control, 0, 0, "!")); ass.Add(new Token(TokenType.Name, 0, 0, "Alice")); }
/**************************************************************** * Assignment Node ***************************************************************/ public Node Assignment() { var assgnResult = new Assignment(); if (this.labelCache != null) { assgnResult.Add(this.labelCache); this.labelCache = null; } var id = new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }; if (CurrentToken == TokenCategory.PARENTHESIS_OPEN) { id.Add(ArrayDeclaration()); } var assgnToken = Expect(TokenCategory.ASSIGN); var expr = Expression(); assgnResult.Add(id); assgnResult.Add(expr); assgnResult.AnchorToken = assgnToken; return(assgnResult); }
public void InvalidTokenInNegationTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Control, 0, 0, "!")); ass.Add(new Token(TokenType.Control, 0, 0, ")")); }
public void InvalidBinaryOperatorTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Number, 0, 0, "15")); ass.Add(new Token(TokenType.Name, 0, 0, "Alice")); }
public void WhenSomeoneJoins(IEnumerable <int> moveTimes, DateTime expectedTime) { var tribe = Substitute.For <ITribe>(); var targetCity = Substitute.For <ICity>(); ICity stubCity; var stub = CreateStub(out stubCity); var formula = Substitute.For <Formula>(); var dbManager = Substitute.For <IDbManager>(); var gameObjectLocator = Substitute.For <IGameObjectLocator>(); var scheduler = Substitute.For <IScheduler>(); var procedure = Substitute.For <Procedure>(); var radiusLocator = Substitute.For <ITileLocator>(); var actionFactory = Substitute.For <IActionFactory>(); var locker = new LockerStub(gameObjectLocator); var initializer = Substitute.For <ITroopObjectInitializerFactory>(); ICity newCity; var newStub = CreateStub(out newCity); ICity newCity2; var newStub2 = CreateStub(out newCity2); SystemClock.SetClock(startTime); Queue <int> moveTimeReturns = new Queue <int>(); foreach (var moveTime in moveTimes) { moveTimeReturns.Enqueue(moveTime); } formula.MoveTimeTotal(Arg.Any <ITroopStub>(), 0, true).Returns(x => moveTimeReturns.Dequeue()); Assignment assignment = new Assignment(tribe, TARGET_X, TARGET_Y, targetCity, AttackMode.Normal, targetTime, "Description", true, formula, dbManager, gameObjectLocator, scheduler, procedure, radiusLocator, actionFactory, locker, initializer); assignment.Add(stub); assignment.Add(newStub); assignment.Add(newStub2); assignment.TroopCount.Should().Be(3); dbManager.Received(3).Save(assignment); scheduler.Received(3).Put(assignment); assignment.Callback(null); assignment.Time.Should().Be(expectedTime); }
public void UndefinedSecondOperand() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Name, 0, 0, "bar")); ass.Add(new Token(TokenType.Control, 0, 0, "+")); ass.Add(new Token(TokenType.Name, 0, 0, "Alice")); }
public void Subpart2HangingParen() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.String, 0, 0, "bar")); ass.Add(new Token(TokenType.Control, 0, 0, "+")); ass.Add(new Token(TokenType.Control, 0, 0, ")")); }
public void Sub1BadParenTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Control, 0, 0, "(")); ass.Add(new Token(TokenType.Number, 0, 0, "1")); ass.Add(new Token(TokenType.Control, 0, 0, "+")); ass.Add(new Token(TokenType.Control, 0, 0, ")")); }
public void CompletedAssignmentAddTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.String, 0, 0, "fuu")); ass.Add(new Token(TokenType.Control, 0, 0, "+")); ass.Add(new Token(TokenType.String, 0, 0, "bar")); ass.Add(new Token(TokenType.Number, 0, 0, "4")); }
public void NegationOfDefinition() { Assignment ass = new Assignment(_mock.Definitions["bla"], _mock, 0, 0); ass.Add(new Token(TokenType.Control, 0, 0, "!")); ass.Add(new Token(TokenType.Name, 0, 0, "bla")); ass.Exit(); ass.Run(); Assert.IsTrue(((MplBoolean)_mock.Definitions["bla"].GetValue()).Val); Assert.IsTrue(((MplBoolean)ass.Value).Val); }
public void NamedSecondOperandTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Name, 0, 0, "bar")); ass.Add(new Token(TokenType.Control, 0, 0, "+")); ass.Add(new Token(TokenType.Name, 0, 0, "baz")); ass.Exit(); ass.Run(); string v = ((MplString)ass.Value).Val; Assert.AreEqual("barbaz", v); }
public void TestLess() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Number, 0, 0, "1")); ass.Add(new Token(TokenType.Control, 0, 0, "<")); ass.Add(new Token(TokenType.Number, 0, 0, "2")); ass.Exit(); ass.Run(); bool v = ((MplBoolean)ass.Value).Val; Assert.IsTrue(v); }
public void Assign(TopicPartition partition) { if (!offsets.ContainsKey(partition.Topic)) { offsets.Add(partition.Topic, new SyncConsumerOffset()); Assignment.Add(partition); } }
public void Assign(TopicPartition partition) { if (!offsets.ContainsKey(partition.Topic)) { offsets.Add(partition.Topic, 0L); Assignment.Add(partition); } }
public Node Assignment() { var result = new Assignment(); Expect(TokenCategory.ASSIGN); result.Add(Expression()); Expect(TokenCategory.SEMICOLON); return(result); }
public void Subscribe(string topic) { Subscription.Add(topic); if (!offsets.ContainsKey(topic)) { offsets.Add(topic, new SyncConsumerOffset(0L)); Assignment.Add(new TopicPartition(topic, 0)); } Listener?.PartitionsAssigned(this, Assignment); }
public void IncrementalAssign(IEnumerable <TopicPartition> partitions) { cluster.IncrementalAssign(this, partitions); foreach (var tp in partitions) { if (!Assignment.Contains(tp)) { Assignment.Add(tp); } } }
public void SimpleAssignmentTest() { Assignment ass = new Assignment(_mock, 0, 0); ass.Add(new Token(TokenType.Number, 0, 0, "2")); ass.Exit(); ass.Run(); int v = ((MplInteger)ass.Value).Val; Assert.AreEqual(2, v); }
public Node assignStatement(Token identifier) { var id = new Identifier() { AnchorToken = identifier }; var result = new Assignment(); if (CurrentToken == TokenCategory.SQUAREDBRACKET_OPEN) { Expect(TokenCategory.SQUAREDBRACKET_OPEN); id.Add(Expression()); Expect(TokenCategory.SQUAREDBRACKET_CLOSE); } result.Add(id); result.AnchorToken = Expect(TokenCategory.ASSIGN); result.Add(Expression()); Expect(TokenCategory.SEMICOL); return(result); }
public Node StmtAssign(Token id) { var assignment = new Assignment() { AnchorToken = id }; Expect(TokenCategory.ASSIGN); assignment.Add(Expr()); Expect(TokenCategory.SEMICOLON); return(assignment); }
public void Assign(TopicPartitionOffset partition) { if (!offsets.ContainsKey(partition.Topic)) { offsets.Add(partition.Topic, new SyncConsumerOffset(partition.Offset)); Assignment.Add(partition.TopicPartition); } else { offsets[partition.Topic] = new SyncConsumerOffset(partition.Offset); } }
public void Sequence() { Solver solver = new Solver("Solver"); IntervalVar[] intervals = solver.MakeFixedDurationIntervalVarArray(10, 0, 10, 5, false, "task"); DisjunctiveConstraint disjunctive = intervals.Disjunctive("Sequence"); SequenceVar var = disjunctive.SequenceVar(); Assignment ass = solver.MakeAssignment(); ass.Add(var); ass.SetForwardSequence(var, new int[] { 1, 3, 5 }); int[] seq = ass.ForwardSequence(var); Assert.Equal(3, seq.Length); }
public void Assign(TopicPartitionOffset partition) { if (!offsets.ContainsKey(partition.Topic)) { offsets.Add(partition.Topic, partition.Offset); Assignment.Add(partition.TopicPartition); } else { offsets[partition.Topic] = partition.Offset; } }
public void Subscribe(IEnumerable <string> topics) { Subscription.AddRange(topics); foreach (var t in topics) { if (!offsets.ContainsKey(t)) { offsets.Add(t, new SyncConsumerOffset(0L)); Assignment.Add(new TopicPartition(t, 0)); } } Listener?.PartitionsAssigned(this, Assignment); }
internal void OnPartitionsAssigned(string topicName, IReadOnlyCollection <Partition> partitions) { _temporaryAssignment.RemoveAll(topicPartitionOffset => topicPartitionOffset.Topic == topicName); _temporaryAssignment.AddRange( partitions.Select(partition => new TopicPartitionOffset(topicName, partition, Offset.Unset))); if (!_topicAssignments.Contains(topicName)) { _topicAssignments.Add(topicName); } if (_topicAssignments.Count < Subscription.Count) { return; } var partitionOffsets = _temporaryAssignment; var revokeHandlerResult = InvokePartitionsRevokedHandler(topicName); if (revokeHandlerResult != null && revokeHandlerResult.Count > 0) { partitionOffsets = partitionOffsets .Union(revokeHandlerResult) .GroupBy(partitionOffset => partitionOffset.TopicPartition) .Select( group => new TopicPartitionOffset( group.Key, group.Max(topicPartitionOffset => topicPartitionOffset.Offset))) .ToList(); } ClearPartitionsAssignment(); var assignHandlerResult = InvokePartitionsAssignedHandler(partitionOffsets); if (assignHandlerResult != null) { partitionOffsets = assignHandlerResult; } foreach (var partitionOffset in partitionOffsets) { Assignment.Add(partitionOffset.TopicPartition); Seek(GetStartingOffset(partitionOffset)); } PartitionsAssigned = true; }
public Node Assignment() { //Expect (TokenType.IDENTIFIER); var n1 = new Assignment() { AnchorToken = Expect(TokenType.ASSIGN) }; n1.Add(Expression()); // TODO: See if we remove this. // if (CurrentToken == TokenType.INSTRUCTION_END) { // Expect (TokenType.INSTRUCTION_END); // } return(n1); }
public void Assign(TopicPartitionOffset partition) { long offset = 0; if (partition.Offset.Value >= 0) { offset = partition.Offset.Value; } if (!offsets.ContainsKey(partition.Topic)) { offsets.Add(partition.Topic, new SyncConsumerOffset(offset)); Assignment.Add(partition.TopicPartition); } else { offsets[partition.Topic] = new SyncConsumerOffset(offset); } }