PageRenderTime 106ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/test/org/jetbrains/plugins/clojure/parser/ParserTest.java

https://github.com/JetBrains/la-clojure
Java | 209 lines | 151 code | 43 blank | 15 comment | 0 complexity | a695c3cf4415c1147b66657b82d96ee7 MD5 | raw file
  1. package org.jetbrains.plugins.clojure.parser;
  2. import com.intellij.openapi.fileTypes.FileTypeManager;
  3. import com.intellij.openapi.util.io.FileUtil;
  4. import com.intellij.psi.PsiFile;
  5. import com.intellij.psi.impl.DebugUtil;
  6. import junit.framework.Assert;
  7. import org.jetbrains.plugins.clojure.base.ClojureBaseTestCase;
  8. import org.junit.Test;
  9. import java.io.File;
  10. import java.io.IOException;
  11. /**
  12. * Created by IntelliJ IDEA.
  13. * User: peter
  14. * Date: Jan 5, 2009
  15. * Time: 2:11:20 PM
  16. * Copyright 2007, 2008, 2009 Red Shark Technology
  17. * <p/>
  18. * http://www.apache.org/licenses/LICENSE-2.0
  19. * <p/>
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. public class ParserTest extends ClojureBaseTestCase {
  27. private static final String DATA_PATH = System.getProperty("user.dir") + "/testdata/parser/";
  28. public String getDataPath() {
  29. return DATA_PATH;
  30. }
  31. public void doParse(String fileName) {
  32. String contents = fetchFile("", fileName, TEST_FILE_EXT);
  33. PsiFile psiFile = createPseudoPhysicalFile(getProject(), "clj_98.clj", contents);
  34. String psiTree = DebugUtil.psiToString(psiFile, false);
  35. try {
  36. final String expected = FileUtil.loadFile(new File(getDataPath() + fileName + "-tree.txt"), true);
  37. assertEquals(expected, psiTree);
  38. } catch (IOException e) {
  39. throw new RuntimeException(e);
  40. }
  41. }
  42. @Test
  43. public void testClojureFileType() {
  44. Assert.assertNotNull(FileTypeManager.getInstance().getFileTypeByFileName("foo.clj"));
  45. }
  46. @Test
  47. public void testSymbol() {
  48. doParse("symbol");
  49. }
  50. @Test
  51. public void testSymbol2() {
  52. doParse("symbol2");
  53. }
  54. @Test
  55. public void testInteger() {
  56. doParse("integer");
  57. }
  58. @Test
  59. public void testFloat() {
  60. doParse("float");
  61. }
  62. @Test
  63. public void testString() {
  64. doParse("string");
  65. }
  66. public void testMultilineString() {
  67. doParse("multiline_string");
  68. }
  69. public void testUnicodeSymbol() {
  70. doParse("unicode_symbol");
  71. }
  72. public void testNameApostrophe() {
  73. doParse(getTestName(true));
  74. }
  75. @Test
  76. public void testSexp1() {
  77. doParse("sexp");
  78. }
  79. @Test
  80. public void testSexp2() {
  81. doParse("sexp2");
  82. }
  83. @Test
  84. public void testQuote() {
  85. doParse("quote");
  86. }
  87. @Test
  88. public void testVector() {
  89. doParse("vector");
  90. }
  91. @Test
  92. public void testEmptyList() {
  93. doParse("empty_list");
  94. }
  95. @Test
  96. public void testEmptyVector() {
  97. doParse("empty_vector");
  98. }
  99. @Test
  100. public void testEmptyMap() {
  101. doParse("empty_map");
  102. }
  103. @Test
  104. public void testMap() {
  105. doParse("map");
  106. }
  107. @Test
  108. public void testMetadata() {
  109. doParse("meta");
  110. }
  111. @Test
  112. public void testLet() {
  113. doParse("let");
  114. }
  115. @Test
  116. public void testFn() {
  117. doParse("fn");
  118. }
  119. @Test
  120. public void testSexp3() {
  121. doParse("sexp3");
  122. }
  123. @Test
  124. public void testSexp4() {
  125. doParse("sexp4");
  126. }
  127. @Test
  128. public void testSexp45() {
  129. doParse("sexp45");
  130. }
  131. @Test
  132. public void testDefn() {
  133. doParse("defn");
  134. }
  135. @Test
  136. public void testDefn2() {
  137. doParse("defn2");
  138. }
  139. public void testDefn3() {
  140. doParse("defn3");
  141. }
  142. public void testString1() {
  143. doParse("str1");
  144. }
  145. public void testString2() {
  146. doParse("uncompl");
  147. }
  148. public void testString4() {
  149. doParse("str4");
  150. }
  151. public void testSym1() {
  152. doParse("symbols/sym1");
  153. }
  154. public void testSym2() {
  155. doParse("symbols/sym2");
  156. }
  157. public void testSym3() {
  158. doParse("symbols/sym3");
  159. }
  160. public void testSym4() {
  161. doParse("symbols/sym4");
  162. }
  163. public void testSym5() {
  164. doParse("symbols/sym5");
  165. }
  166. }