PHP Classes
elePHPant
Icontem

File: Falcraft/examples/Data/Types/LexicographicList.php

Recommend this page to a friend!
  Classes of Asher Wolfstein  >  Abstract Data Types  >  Falcraft/examples/Data/Types/LexicographicList.php  >  Download  
File: Falcraft/examples/Data/Types/LexicographicList.php
Role: Example script
Content type: text/plain
Description: Alphabetic List Example
Class: Abstract Data Types
Set of abstract data types as pure PHP classes
Author: By
Last change:
Date: 3 years ago
Size: 2,078 bytes
 

Contents

Class file image Download
<?php

/* SOME TESTS ARE MEANT TO FAIL!
   If the entire script runs, it works. */

require_once('../../../Data/Types/LexicographicList.php');

use
Falcraft\Data\Types;

echo
"Falcraft\\Data\\Types\\LexicographicList.php Test\n";
echo
"----------------------------------------------\n\n";

echo
"Instantiate -> ";

$success = true;

$testList = null;

try {
   
$testList = new Types\LexicographicList();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Create Strict List -- ";

$success = true;

$testList = null;

try {
   
$testList = new Types\LexicographicList(array(), null, array('strict' => true,));
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
" Push Improper Value -> ";

$fail = true;

try {
   
$testList->push(5);
   
$fail = false;
} catch (\
Exception $e) {
   
}

if (
$fail) {
    echo
"Failure!\n";
} else {
    echo
"Success...\n";
}

echo
"Push 'abecedarian' -> ";

$success = true;

try {
   
$testList->push('abecedarian');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Push 'zygote' -> ";

$success = true;

try {
   
$testList->push('zygote');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Push 'green' -> ";

try {
   
$testList->push('green');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Push 'wash' -> ";

try {
   
$testList->push('wash');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"Push 'real' -> ";

try {
   
$testList->push('real');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"List Internals -- ";
var_dump($testList->getList());