Skip to content

Commit 90f7106

Browse files
committed
First approximation to integration with new AST parser
SVN: trunk@4197
1 parent 0726118 commit 90f7106

File tree

127 files changed

+53237
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+53237
-32
lines changed

lib/net/2.0/Antlr3.Runtime.dll

114 KB
Binary file not shown.

lib/net/3.5/Antlr3.Runtime.dll

114 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using log4net.Config;
4+
using NHibernate.Cfg;
5+
using NHibernate.Engine;
6+
using NHibernate.Hql.Ast.ANTLR;
7+
using NHibernate.Tool.hbm2ddl;
8+
using NUnit.Framework;
9+
10+
namespace NHibernate.Test.HQL.Ast
11+
{
12+
// This test need the new NUnit
13+
//[TestFixture]
14+
//public class ParsingFixture
15+
//{
16+
// /// <summary>
17+
// /// Key test for HQL strings -> HQL AST's - takes the query and returns a string
18+
// /// representation of the resultant tree
19+
// /// </summary>
20+
// /// <param name="query"></param>
21+
// /// <returns></returns>
22+
// [Test]
23+
// [TestCaseSource(typeof(QueryFactoryClass), "TestCases")]
24+
// public string HqlParse(string query)
25+
// {
26+
// // This test need the new NUnit
27+
// var p = new HqlParseEngine(query, false, null);
28+
// p.Parse();
29+
30+
// return " " + p.Ast.ToStringTree();
31+
// }
32+
33+
// /// <summary>
34+
// /// Used to test individual queries "by hand", since td.net doesn't let me run a
35+
// /// single test out of a data set
36+
// /// </summary>
37+
// [Test]
38+
// public void ManualTest()
39+
// {
40+
// var p = new HqlParseEngine(@"select all s, s.Other from s in class Simple where s = :s", false, null);
41+
42+
// p.Parse();
43+
44+
// Console.WriteLine(p.Ast.ToStringTree());
45+
// }
46+
47+
// /// <summary>
48+
// /// Helper "test" to display queries that are ignored
49+
// /// </summary>
50+
// [Test]
51+
// public void ShowIgnoredQueries()
52+
// {
53+
// foreach (string query in QueryFactoryClass.GetIgnores)
54+
// {
55+
// Console.WriteLine(query);
56+
// }
57+
// }
58+
59+
// /// <summary>
60+
// /// Helper "test" to display queries that don't parse in H3
61+
// /// </summary>
62+
// [Test]
63+
// public void ShowExceptionQueries()
64+
// {
65+
// foreach (string query in QueryFactoryClass.GetExceptions)
66+
// {
67+
// Console.WriteLine(query);
68+
// }
69+
// }
70+
71+
// /// <summary>
72+
// /// Goes all the way to the DB and back. Just here until there's a better place to put it...
73+
// /// </summary>
74+
// [Test]
75+
// public void BasicQuery()
76+
// {
77+
// XmlConfigurator.Configure();
78+
79+
// string input = "select o.id, li.id from NHibernate.Test.CompositeId.Order o join o.LineItems li";// join o.LineItems li";
80+
81+
// ISessionFactoryImplementor sfi = SetupSFI();
82+
83+
// ISession session = sfi.OpenSession();
84+
// session.CreateQuery(input).List();
85+
// /*
86+
// foreach (Animal o in session.CreateQuery(input).Enumerable())
87+
// {
88+
// Console.WriteLine(o.Description);
89+
// }*/
90+
// }
91+
92+
// ISessionFactoryImplementor SetupSFI()
93+
// {
94+
// Configuration cfg = new Configuration();
95+
// cfg.AddAssembly(this.GetType().Assembly);
96+
// new SchemaExport(cfg).Create(false, true);
97+
// return (ISessionFactoryImplementor)cfg.BuildSessionFactory();
98+
// }
99+
100+
// /// <summary>
101+
// /// Class used by Nunit 2.5 to drive the data into the HqlParse test
102+
// /// </summary>
103+
// public class QueryFactoryClass
104+
// {
105+
// public static IEnumerable<TestCaseData> TestCases
106+
// {
107+
// get
108+
// {
109+
// // TODO - need to handle Ignore better (it won't show in results...)
110+
// return EnumerateTests(td => !td.Ignore && !td.Result.StartsWith("Exception"),
111+
// td => new TestCaseData(td.Query)
112+
// .Returns(td.Result)
113+
// .SetCategory(td.Category)
114+
// .SetName(td.Name)
115+
// .SetDescription(td.Description));
116+
// }
117+
// }
118+
119+
// public static IEnumerable<string> GetIgnores
120+
// {
121+
// get
122+
// {
123+
// return EnumerateTests(td => td.Ignore,
124+
// td => td.Query);
125+
// }
126+
// }
127+
128+
// public static IEnumerable<string> GetExceptions
129+
// {
130+
// get
131+
// {
132+
// return EnumerateTests(td => td.Result.StartsWith("Exception"),
133+
// td => td.Query);
134+
// }
135+
// }
136+
137+
// static IEnumerable<T> EnumerateTests<T>(Func<QueryTestData, bool> predicate, Func<QueryTestData , T> projection)
138+
// {
139+
// XDocument doc = XDocument.Load(@"HQL Parsing\TestQueriesWithResults.xml");
140+
141+
// foreach (XElement testGroup in doc.Element("Tests").Elements("TestGroup"))
142+
// {
143+
// string category = testGroup.Attribute("Name").Value;
144+
145+
// foreach (XElement test in testGroup.Elements("Test"))
146+
// {
147+
// QueryTestData testData = new QueryTestData(category, test);
148+
149+
// if (predicate(testData))
150+
// {
151+
// yield return projection(testData);
152+
// }
153+
// }
154+
// }
155+
// }
156+
157+
// class QueryTestData
158+
// {
159+
// internal QueryTestData(string category, XElement xml)
160+
// {
161+
// Category = category;
162+
// Query = xml.Element("Query").Value;
163+
// Result = xml.Element("Result") != null ? xml.Element("Result").Value : "barf";
164+
// Name = xml.Element("Name") != null ? xml.Element("Name").Value : null;
165+
// Description = xml.Element("Description") != null ? xml.Element("Description").Value : null;
166+
// Ignore = xml.Attribute("Ignore") != null ? bool.Parse(xml.Attribute("Ignore").Value) : false;
167+
// }
168+
169+
// internal string Category;
170+
// internal string Query;
171+
// internal string Result;
172+
// internal string Name;
173+
// internal string Description;
174+
// internal bool Ignore;
175+
// }
176+
// }
177+
//}
178+
}

0 commit comments

Comments
 (0)