Skip to content

Commit

Permalink
Fix a few minor bugs in Slim having to do with variables.
Browse files Browse the repository at this point in the history
git-svn-id: https://fitnesse.svn.sourceforge.net/svnroot/fitnesse/trunk@382 57a019cf-8a1a-0410-8d1a-f715e8e97b57
  • Loading branch information
robertmartin committed Nov 24, 2008
1 parent 4602004 commit 0ff71b6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
12 changes: 6 additions & 6 deletions FitNesseRoot/RecentChanges/content.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
|ProjectPage.JukeBox.JukeBoxStories.YouDecide||10:41:57 Mon, Nov 24, 2008|
|ProjectPage.JukeBox.SongInventory||08:37:03 Mon, Nov 24, 2008|
|ProjectPage.JukeBox.JukeBoxStories||08:28:29 Mon, Nov 24, 2008|
|ProjectPage.JukeBox.JukeBoxStories.PlayThreeSongs||21:44:03 Sun, Nov 23, 2008|
|ProjectPage.JukeBox.JukeBoxStories.PlayOneSong||21:40:17 Sun, Nov 23, 2008|
|ProjectPage.JukeBox.SetUp||21:39:37 Sun, Nov 23, 2008|
|JunkParent.SlimTest||18:24:48 Tue, Nov 18, 2008|
|FrontPage||10:27:05 Tue, Nov 18, 2008|
|ProjectPage.JukeBox.JukeBoxStories.PlayThreeSongs||01:49:19 Tue, Nov 18, 2008|
|ProjectPage.JukeBox.JukeBoxStories.PlayOneSong||01:49:07 Tue, Nov 18, 2008|
|ProjectPage.JukeBox.JukeBoxStories.CreditsAccumulateWithPayment||01:48:51 Tue, Nov 18, 2008|
|ProjectPage.JukeBox.SetUp||01:48:39 Tue, Nov 18, 2008|
|ProjectPage.JukeBox.JukeBoxStories||01:46:58 Tue, Nov 18, 2008|
|ProjectPage.JukeBox.SongInventory||12:37:10 Mon, Nov 17, 2008|
|ProjectPage.JukeBox||12:14:43 Mon, Nov 17, 2008|
|ProjectPage.JukeBox.JukeBoxStories.PaymentDeterminesCredits||12:04:43 Mon, Nov 17, 2008|
|ProjectPage||11:58:43 Mon, Nov 17, 2008|
Expand Down Expand Up @@ -97,4 +98,3 @@
|FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.ContentsTestsIncludeWithHelp||19:54:02 Sat, Oct 25, 2008|
|FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.TestContentsHelp||19:53:27 Sat, Oct 25, 2008|
|FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.TestContentsFilters||19:48:52 Sat, Oct 25, 2008|
|FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.ContentsTestsInclude||19:47:22 Sat, Oct 25, 2008|
2 changes: 1 addition & 1 deletion FitNesseRoot/RecentChanges/properties.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<properties>
<Files/>
<LastModified>20081118182448</LastModified>
<LastModified>20081124104157</LastModified>
<Properties/>
<RecentChanges/>
<Refactor/>
Expand Down
4 changes: 2 additions & 2 deletions FitNesseRoot/properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#FitNesse properties
#Tue Nov 18 18:50:46 CST 2008
#Mon Nov 24 10:12:56 CST 2008
WikiImportFormatUpdate=applied
PropertiesToXmlUpdate=applied
FilesAttributeUpdate=applied
SymLinkPropertyFormatUpdate=applied
VirtualWikiDeprecationUpdate=applied
RecentChangesAttributeUpdate=applied
WhereUsedAttributeUpdate=applied
RecentChangesAttributeUpdate=applied
13 changes: 12 additions & 1 deletion src/fitnesse/responders/run/slimResponder/TableScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class TableScanner implements Iterable<Table> {
public TableScanner(PageData data) throws Exception {
WikiPage page = data.getWikiPage();
String content = data.getContent();
content = replaceVariables(page, content);
content = removeUnprocessedLiteralsInTables(content);
content = replaceEvaluations(new WidgetRoot("", page), content);
widgetRoot = new WidgetRoot(content, page, new WidgetBuilder(tableWidgets));
Expand All @@ -45,7 +46,7 @@ private static void replaceProcessedLiterals(TextWidget textWidget) {
Matcher matcher = LiteralWidget.pattern.matcher(text);
while (matcher.find()) {
int literalNumber = Integer.parseInt(matcher.group(1));
String replacement = String.format("!-%s-!",textWidget.getParent().getLiteral(literalNumber));
String replacement = String.format("!-%s-!", textWidget.getParent().getLiteral(literalNumber));
text = text.replace(matcher.group(), replacement);
matcher = LiteralWidget.pattern.matcher(text);
}
Expand All @@ -71,6 +72,16 @@ static String removeUnprocessedLiteralsInTables(String text) {
return text;
}

private String replaceVariables(WikiPage page, String content) throws Exception {
Matcher matcher = VariableWidget.pattern.matcher(content);
while (matcher.find()) {
String replacement = page.getData().getVariable(matcher.group(1));
if (replacement != null)
content = content.replace(matcher.group(), replacement);
}
return content;
}

private String replaceEvaluations(ParentWidget root, String text) {
Matcher matcher = EvaluatorWidget.pattern.matcher(text);
while (matcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,11 @@ public void removeUnprocessedLiterals() throws Exception {
assertEquals("!-hi-!\n|x|\n!-there-!\n", ts.toWikiText());
}

@Test
public void replaceVariables() throws Exception {
TableScanner ts = scanTable("!define X {Y}\n|${X}|\n");
assertEquals("!define X {Y}\n|Y|\n", ts.toWikiText());
}


}

0 comments on commit 0ff71b6

Please sign in to comment.