Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
TaskChainedTest.pm
Package: openkore-2.0.7.zip [view]
Upload User: market2
Upload Date: 2018-11-18
Package Size: 18786k
Code Size: 3k
Category:
Game Hook Crack
Development Platform:
Windows_Unix
- # Unit test for Task::Chained
- package TaskChainedTest;
- use strict;
- use Test::More;
- use Task::Chained;
- use Task::Testing;
- sub start {
- print "### Starting TaskChainedTestn";
- testBasicUsage();
- testMutexChanges();
- }
- sub testBasicUsage {
- print "Testing basic usage...n";
- my $taskA = new Task::Testing(name => 'A', mutexes => ['1', '2']);
- my $taskB = new Task::Testing(name => 'B', mutexes => []);
- my $taskC = new Task::Testing(name => 'C', mutexes => ['2', '3']);
- my $chain = new Task::Chained(tasks => [$taskA, $taskB, $taskC]);
- $chain->activate();
- ok($chain->getSubtask() == $taskA, "Current subtask is A.");
- is_deeply($chain->getMutexes(), ['1', '2'], "Chain has same mutexes as task A.");
- ok($chain->getStatus == Task::RUNNING, "Chain is running.");
- $chain->iterate();
- ok($chain->getSubtask() == $taskA, "Current subtask is still A.");
- is_deeply($chain->getMutexes(), ['1', '2'], "Chain still has same mutexes as task A.");
- ok($chain->getStatus == Task::RUNNING, "Chain is running.");
- $taskA->markDone();
- $chain->iterate();
- ok($chain->getSubtask() == $taskB, "Current subtask is B.");
- is_deeply($chain->getMutexes(), [], "Chain has same mutexes as task B.");
- ok($chain->getStatus == Task::RUNNING, "Chain is running.");
- $taskB->markDone();
- $chain->iterate();
- ok($chain->getSubtask() == $taskC, "Current subtask is C.");
- is_deeply($chain->getMutexes(), ['2', '3'], "Chain has same mutexes as task C.");
- ok($chain->getStatus == Task::RUNNING, "Chain is running.");
- $chain->iterate();
- ok($chain->getSubtask() == $taskC, "Current subtask is still C.");
- is_deeply($chain->getMutexes(), ['2', '3'], "Chain still has same mutexes as task C.");
- ok($chain->getStatus == Task::RUNNING, "Chain is running.");
- $taskC->markDone();
- $chain->iterate();
- ok(!defined($chain->getSubtask()), "No subtask active.");
- ok($chain->getStatus() == Task::DONE, "Chain is done.");
- }
- sub testMutexChanges {
- print "Testing dynamic mutex changes...n";
- my $taskA = new Task::Testing(name => 'A', mutexes => ['1', '2']);
- my $taskB = new Task::Testing(name => 'B', mutexes => []);
- my $taskC = new Task::Testing(name => 'C', mutexes => ['2', '3']);
- my $chain = new Task::Chained(tasks => [$taskA, $taskB, $taskC]);
- $chain->activate();
- $taskA->setMutexes('Foo', 'Bar');
- is_deeply($chain->getMutexes(), ['Foo', 'Bar']);
- $taskA->setMutexes();
- is_deeply($chain->getMutexes(), []);
- $taskA->setMutexes('Test');
- is_deeply($chain->getMutexes(), ['Test']);
- $taskB->setMutexes('hello');
- $taskA->markDone();
- $chain->iterate();
- ok($chain->getSubtask() == $taskB, "Current subtask is B.");
- is_deeply($chain->getMutexes(), ['hello']);
- $taskB->markDone();
- $chain->iterate();
- ok($chain->getSubtask() == $taskC, "Current subtask is C.");
- is_deeply($chain->getMutexes(), ['2', '3']);
- $taskC->setMutexes('2', '3', '4');
- is_deeply($chain->getMutexes(), ['2', '3', '4']);
- $taskC->markDone();
- $chain->iterate();
- ok(!defined($chain->getSubtask()), "No subtask active.");
- }
- 1;