mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Cleanup: Removed unused files
This commit is contained in:
parent
b41b56c00c
commit
68ba48e85f
14 changed files with 2 additions and 1335 deletions
2
test/.gitignore
vendored
2
test/.gitignore
vendored
|
@ -3,9 +3,7 @@ all.log
|
|||
classifier.t
|
||||
composite.t
|
||||
exclusion.t
|
||||
grammar.t
|
||||
interval.t
|
||||
lexer.t
|
||||
lr0.t
|
||||
rules.t
|
||||
util.t
|
||||
|
|
|
@ -11,7 +11,7 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||
include_directories (${CMAKE_INSTALL_PREFIX}/include)
|
||||
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
|
||||
|
||||
set (test_SRCS classifier.t composite.t exclusion.t grammar.t interval.t lexer.t lr0.t rules.t util.t)
|
||||
set (test_SRCS classifier.t composite.t exclusion.t interval.t lexer.t rules.t util.t)
|
||||
|
||||
add_custom_target (test ./run_all --verbose
|
||||
DEPENDS ${test_SRCS}
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Grammar.h>
|
||||
#include <test.h>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void testBadGrammarFile (UnitTest& t, File& file)
|
||||
{
|
||||
try
|
||||
{
|
||||
Grammar g;
|
||||
g.loadFromFile (file);
|
||||
t.fail ("Grammar::loadFromFile accepted a bad file");
|
||||
}
|
||||
catch (std::string error)
|
||||
{
|
||||
t.diag (error);
|
||||
t.pass ("Grammar::loadFromFile rejected a bad file");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void testBadGrammar (UnitTest& t, const std::string& bnf)
|
||||
{
|
||||
try
|
||||
{
|
||||
Grammar g;
|
||||
g.loadFromString (bnf);
|
||||
t.fail ("Grammar::loadFromFile accepted a bad grammar");
|
||||
}
|
||||
catch (std::string error)
|
||||
{
|
||||
t.diag (error);
|
||||
t.pass ("Grammar::loadFromFile rejected a bad grammar");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (20);
|
||||
|
||||
// Test loading from a missing file.
|
||||
File missing ("/tmp/does/not/exist");
|
||||
t.notok (missing.exists (), "Grammar file is recognized as missing");
|
||||
testBadGrammarFile (t, missing);
|
||||
|
||||
// Test error on parsing bad grammar.
|
||||
testBadGrammar (t, "");
|
||||
testBadGrammar (t, "# Comment\n"
|
||||
"# Comment\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"\n");
|
||||
|
||||
// Unreferenced rule 'two'.
|
||||
testBadGrammar (t, "one: \"foo\"\n"
|
||||
"\n"
|
||||
"two: \"bar\"\n");
|
||||
|
||||
// Undefined rule 'three'.
|
||||
testBadGrammar (t, "one: three\n"
|
||||
"\n"
|
||||
"two: \"foo\"\n");
|
||||
|
||||
// Test metadata access.
|
||||
Grammar g;
|
||||
g.loadFromString ("one: two\n"
|
||||
"\n"
|
||||
"two: three \"literal\"\n"
|
||||
" /regex/\n"
|
||||
"\n"
|
||||
"three: \"literal2\"\n");
|
||||
auto start = g.start ();
|
||||
auto rules = g.rules ();
|
||||
auto terminals = g.terminals ();
|
||||
auto augmented = g.augmented ();
|
||||
t.is (start, "one", "Located start rule");
|
||||
|
||||
t.is ((int)rules.size (), 3, "Found three rules");
|
||||
t.ok (std::find (rules.begin (), rules.end (), "one") != rules.end (), "Found rule 'one'");
|
||||
t.ok (std::find (rules.begin (), rules.end (), "two") != rules.end (), "Found rule 'two'");
|
||||
t.ok (std::find (rules.begin (), rules.end (), "three") != rules.end (), "Found rule 'three'");
|
||||
|
||||
t.ok (std::find (terminals.begin (), terminals.end (), "\"literal\"") != terminals.end (), "Found terminal '\"literal\"'");
|
||||
t.ok (std::find (terminals.begin (), terminals.end (), "/regex/") != terminals.end (), "Found terminal '/regex/'");
|
||||
t.ok (std::find (terminals.begin (), terminals.end (), "\"literal2\"") != terminals.end (), "Found terminal '\"literal2\"'");
|
||||
|
||||
t.is ((int)augmented.size (), 5, "augmented: 5 items");
|
||||
t.ok (augmented[0] == std::vector <std::string>{"S", "-->", "one"}, "augmented[0]: S --> one");
|
||||
t.ok (augmented[1] == std::vector <std::string>{"one", "-->", "two"}, "augmented[1]: one --> two");
|
||||
t.ok (augmented[2] == std::vector <std::string>{"three", "-->", "\"literal2\""}, "augmented[2]: three --> \"literal2\"");
|
||||
t.ok (augmented[3] == std::vector <std::string>{"two", "-->", "three", "\"literal\""}, "augmented[3]: two --> three \"literal\"");
|
||||
t.ok (augmented[4] == std::vector <std::string>{"two", "-->", "/regex/"}, "augmented[4]: two --> /regex/");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <LR0.h>
|
||||
#include <test.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (21);
|
||||
|
||||
// LR0::Item.
|
||||
LR0::Item item1 ({"E", "-->", "E", "*", "B"});
|
||||
t.is (item1.dump (), "E --> ● E * B", "E --> ● E * B");
|
||||
|
||||
t.ok (item1.advance (), "Item::advance true");
|
||||
t.is (item1.dump (), "E --> E ● * B", "E --> E ● * B");
|
||||
|
||||
t.ok (item1.advance (), "Item::advance true");
|
||||
t.is (item1.dump (), "E --> E * ● B", "E --> E * ● B");
|
||||
|
||||
t.notok (item1.done (), "Item::done false");
|
||||
t.ok (item1.advance (), "Item::advance true");
|
||||
t.ok (item1.done (), "Item::done true");
|
||||
t.is (item1.dump (), "E --> E * B ●", "E --> E * B ●");
|
||||
|
||||
t.notok (item1.advance (), "Item::advance false");
|
||||
|
||||
// LR0::Item special case for "A --> є".
|
||||
LR0::Item item2 ({"A", "-->", "є"});
|
||||
t.is (item2.dump (), "A --> ●", "A --> ●");
|
||||
t.notok (item2.advance (), "Item::advance false");
|
||||
t.ok (item2.done (), "Item::done true");
|
||||
|
||||
LR0::Item item3 ({"E", "-->", "E", "*", "B"});
|
||||
t.is (item3.next (), "E", "Item::next E");
|
||||
t.ok (item3.advance (), "Item::advance true");
|
||||
t.is (item3.next (), "*", "Item::next *");
|
||||
t.ok (item3.advance (), "Item::advance true");
|
||||
t.is (item3.next (), "B", "Item::next B");
|
||||
t.ok (item3.advance (), "Item::advance true");
|
||||
t.notok (item3.advance (), "Item::advance false");
|
||||
t.ok (item3.done (), "Item::done true");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue