Remove _new and actually run the new tests (#9006)

Merge conflict on develop meant this one got left with a new_test.
This commit is contained in:
AdRiley 2024-02-09 14:19:02 +00:00 committed by GitHub
parent 1dc8c1cb24
commit 9339672e0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 42 deletions

View File

@ -2674,7 +2674,7 @@ type Table
resolved_value_column = if value_column.is_nothing then Nothing else (self.at value_column)
java_value_column = if value_column.is_nothing then Nothing else resolved_value_column.java_column
unused_columns = columns_helper.internal_columns.filter (Filter_Condition.Not_In resolved_element_columns+resolved_attribute_columns+[resolved_value_column]) . map .name
unused_columns = columns_helper.internal_columns.filter (Filter_Condition.Is_In resolved_element_columns+resolved_attribute_columns+[resolved_value_column] Filter_Action.Remove) . map .name
if unused_columns.length > 0 then problem_builder.report_other_warning (Unexpected_Extra_Columns.Warning unused_columns)
problem_builder.attach_problems_before on_problems <|

View File

@ -6,12 +6,12 @@ import java.util.stream.Stream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.graalvm.polyglot.Context;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
public class TableToXml {
@ -60,13 +60,12 @@ public class TableToXml {
}
private static String convert_to_string(Document doc) throws XmlException {
var xmlObject = XmlObject.Factory.parse(doc);
var options = new XmlOptions();
options.setSavePrettyPrint();
String xmlString = xmlObject.xmlText(options);
return xmlString;
DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
lsSerializer.getDomConfig().setParameter("xml-declaration", false);
lsSerializer.setNewLine("\n");
return lsSerializer.writeToString(doc);
}
private static void get_set_attribute(

View File

@ -12,6 +12,7 @@ import project.In_Memory.Lossy_Conversions_Spec
import project.In_Memory.Parse_To_Table_Spec
import project.In_Memory.Split_Tokenize_Spec
import project.In_Memory.Table_Spec
import project.In_Memory.Table_Xml_Spec
import project.In_Memory.Table_Conversion_Spec
import project.In_Memory.Table_Date_Spec
import project.In_Memory.Table_Date_Time_Spec
@ -19,6 +20,7 @@ import project.In_Memory.Table_Time_Of_Day_Spec
add_specs suite_builder =
Table_Spec.add_specs suite_builder
Table_Xml_Spec.add_specs suite_builder
Column_Spec.add_specs suite_builder
Column_Format_Spec.add_specs suite_builder
Common_Spec.add_specs suite_builder

View File

@ -7,15 +7,15 @@ import Standard.Base.Errors.Common.Type_Error
# pretty printed xml actually makes the tests less pretty
# so all but one tests depretty the xml before comparing
depretty xmlText =
xmlText.replace (Regex.compile "(\r\n|\n)\s*") ""
xmlText.replace (Regex.compile "\n\s*") ""
type Data
# | Title | Author | Price | Year | Last Borrowed
#---+------------------------+---------------------+-------+------+------------------------------------------
# 0 | A Tale Of Two Cities | Charles Dickens | 9.99 | 1859 | 1999-01-02 03:40:00Z[Europe/London]
# 1 | The Great Gatsby | F. Scott Fitzgerald | 5.99 | 1925 | 2000-02-03 04:50:00Z[Europe/London]
# 2 | The Catcher In The Rye | J. D. Salinger | 6.99 | 1951 | 2001-03-04 05:25:00Z[Europe/London]
# 3 | The Grapes Of Wrath | John Steinbeck | 7.99 | 1939 | 2002-04-05 06:15:00+01:00[Europe/London]
# 0 | A Tale Of Two Cities | Charles Dickens | 9.99 | 1859 | 1999-01-02 03:40:00Z[UTC]
# 1 | The Great Gatsby | F. Scott Fitzgerald | 5.99 | 1925 | 2000-02-03 04:50:00Z[UTC]
# 2 | The Catcher In The Rye | J. D. Salinger | 6.99 | 1951 | 2001-03-04 05:25:00Z[UTC]
# 3 | The Grapes Of Wrath | John Steinbeck | 7.99 | 1939 | 2002-04-05 06:15:00+01:00[UTC]
Value ~table
setup =
@ -24,7 +24,7 @@ type Data
author = ["Author", ["Charles Dickens", "F. Scott Fitzgerald", "J. D. Salinger", "John Steinbeck"]]
price = ["Price", [9.99, 5.99, 6.99, 7.99]]
year = ["Year", [1859, 1925, 1951, 1939]]
last_borrowed = ["Last Borrowed", [Date_Time.new 1999 1 2 3 40, Date_Time.new 2000 2 3 4 50, Date_Time.new 2001 3 4 5 25, Date_Time.new 2002 4 5 6 15]]
last_borrowed = ["Last Borrowed", [Date_Time.new 1999 1 2 3 40 (zone = Time_Zone.utc), Date_Time.new 2000 2 3 4 50 (zone = Time_Zone.utc), Date_Time.new 2001 3 4 5 25 (zone = Time_Zone.utc), Date_Time.new 2002 4 5 6 15 (zone = Time_Zone.utc)]]
Table.new [title, author, price, year, last_borrowed]
Data.Value make_table
@ -36,7 +36,7 @@ add_specs suite_builder =
t = data.table . take 0
r = t.to_xml
e = "<Table/>"
r.should_equal e
(depretty r).should_equal (depretty e)
group_builder.specify "if no columns are specified all fields become child elements" <|
t = data.table . select_columns ['Title', 'Year']
r = t.to_xml
@ -128,7 +128,7 @@ add_specs suite_builder =
r = t.to_xml (Regex.compile ".*e") (Regex.compile ".*a.*") "Author"
e = '''
<Table>
<Row Last_Borrowed="1999-01-02T03:40Z[Europe/London]" Year="1859">
<Row Last_Borrowed="1999-01-02T03:40Z[UTC]" Year="1859">
Charles Dickens
<Title>A Tale Of Two Cities</Title>
<Price>9.99</Price>
@ -216,16 +216,16 @@ add_specs suite_builder =
# this one makes sure it actually is pretty printed for users
t = data.table . take 2
r = t.to_xml ["Year"] ["Author", "Price"] "Title"
e = '<Table>\r\n'
+ ' <Row Author="Charles Dickens" Price="9.99">\r\n'
+ ' A Tale Of Two Cities\r\n'
+ ' <Year>1859</Year>\r\n'
+ ' </Row>\r\n'
+ ' <Row Author="F. Scott Fitzgerald" Price="5.99">\r\n'
+ ' The Great Gatsby\r\n'
+ ' <Year>1925</Year>\r\n'
+ ' </Row>\r\n'
+ '</Table>'
e = '<Table>\n'
+ ' <Row Author="Charles Dickens" Price="9.99">\n'
+ ' A Tale Of Two Cities\n'
+ ' <Year>1859</Year>\n'
+ ' </Row>\n'
+ ' <Row Author="F. Scott Fitzgerald" Price="5.99">\n'
+ ' The Great Gatsby\n'
+ ' <Year>1925</Year>\n'
+ ' </Row>\n'
+ '</Table>\n'
r . should_equal e
group_builder.specify "Illegal xml names are cleaned up in root_name and row_name" <|
t = data.table . take 1
@ -241,18 +241,18 @@ add_specs suite_builder =
group_builder.specify "Illegal xml names are cleaned up" <|
numeric_column_name = ["1", [10]]
illegal_column_name = ["Bad <chars> & symbols", [1]]
last_borrowed = ["Last Borrowed", [Date_Time.new 1999 1 2 3 40]]
last_borrowed = ["Last Borrowed", [Date_Time.new 1999 1 2 3 40 (zone = Time_Zone.utc)]]
# | 1 | Bad <chars> & symbols | Last Borrowed
#---+----+-----------------------+-------------------------------------
# 0 | 10 | 1 | 1999-01-02 03:40:00Z[Europe/London]
# 0 | 10 | 1 | 1999-01-02 03:40:00Z[UTC]
t = Table.new [numeric_column_name, illegal_column_name, last_borrowed]
r = t.to_xml ["Bad <chars> & symbols", "Last Borrowed", "1"] ["Bad <chars> & symbols", "Last Borrowed", "1"]
e = '''
<Table>
<Row Bad__chars____symbols="1" Last_Borrowed="1999-01-02T03:40Z[Europe/London]" _1="10">
<Row Bad__chars____symbols="1" Last_Borrowed="1999-01-02T03:40Z[UTC]" _1="10">
<_1>10</_1>
<Bad__chars____symbols>1</Bad__chars____symbols>
<Last_Borrowed>1999-01-02T03:40Z[Europe/London]</Last_Borrowed>
<Last_Borrowed>1999-01-02T03:40Z[UTC]</Last_Borrowed>
</Row>
</Table>
(depretty r).should_equal (depretty e)
@ -355,19 +355,19 @@ add_specs suite_builder =
r = t.to_xml ["xml", "special"] ["xml", "special"] "xml"
e = '''
<Table>
<Row special="&lt;" xml="&lt;/Table>">
&lt;/Table>
<xml>&lt;/Table></xml>
<Row special="&lt;" xml="&lt;/Table&gt;">
&lt;/Table&gt;
<xml>&lt;/Table&gt;</xml>
<special>&lt;</special>
</Row>
<Row special="&amp;>" xml="&lt;tag>12&lt;/tag>">
&lt;tag>12&lt;/tag>
<xml>&lt;tag>12&lt;/tag></xml>
<special>&amp;></special>
<Row special="&amp;&gt;" xml="&lt;tag&gt;12&lt;/tag&gt;">
&lt;tag&gt;12&lt;/tag&gt;
<xml>&lt;tag&gt;12&lt;/tag&gt;</xml>
<special>&amp;&gt;</special>
</Row>
<Row special="'" xml="&lt;r>&lt;c v=&quot;1&quot;>&lt;/c>&lt;/r>">
&lt;r>&lt;c v="1">&lt;/c>&lt;/r>
<xml>&lt;r>&lt;c v="1">&lt;/c>&lt;/r></xml>
<Row special="'" xml="&lt;r&gt;&lt;c v=&quot;1&quot;&gt;&lt;/c&gt;&lt;/r&gt;">
&lt;r&gt;&lt;c v="1"&gt;&lt;/c&gt;&lt;/r&gt;
<xml>&lt;r&gt;&lt;c v="1"&gt;&lt;/c&gt;&lt;/r&gt;</xml>
<special>'</special>
</Row>
</Table>