5 |
--------------------------------------------------------------------------------
/testData/makefile_parsing/Makefile2.mk:
--------------------------------------------------------------------------------
1 | WAF=python tools/waf-light --jobs=1
2 |
3 | all:
4 | @$(WAF) build
5 |
6 | all-debug:
7 | @$(WAF) -v build
8 |
9 | all-progress:
10 | @$(WAF) -p build
11 |
12 | install:
13 | @$(WAF) install
14 |
15 | uninstall:
16 | @$(WAF) uninstall
17 |
18 | test: all
19 | python tools/test.py --mode=release simple
20 |
21 | test-all: all
22 | python tools/test.py --mode=debug,release
23 |
24 | test-release: all
25 | python tools/test.py --mode=release
26 |
27 | test-debug: all
28 | python tools/test.py --mode=debug
29 |
30 | test-simple: all
31 | python tools/test.py simple
32 |
33 | test-pummel: all
34 | python tools/test.py pummel
35 |
36 | test-internet: all
37 | python tools/test.py internet
38 |
39 | benchmark: all
40 | build/default/node benchmark/run.js
41 |
42 | doc: doc/node.1 doc/api.html doc/index.html doc/changelog.html
43 |
44 | doc/api.html: doc/api.txt
45 | asciidoc --unsafe \
46 | -a theme=pipe \
47 | -a toc \
48 | -a toclevels=1 \
49 | -a linkcss \
50 | -o doc/api.html doc/api.txt
51 |
52 | doc/changelog.html: ChangeLog
53 | echo 'Node.js ChangeLog Node.js ChangeLog
' > doc/changelog.html
54 | cat ChangeLog >> doc/changelog.html
55 | echo '
' >> doc/changelog.html
56 |
57 | doc/api.xml: doc/api.txt
58 | asciidoc -b docbook -d manpage -o doc/api.xml doc/api.txt
59 |
60 | doc/node.1: doc/api.xml
61 | xsltproc --output doc/node.1 --nonet doc/manpage.xsl doc/api.xml
62 |
63 | website-upload: doc
64 | scp doc/* ryan@nodejs.org:~/tinyclouds/node/
65 |
66 | docclean:
67 | @-rm -f doc/node.1 doc/api.xml doc/api.html doc/changelog.html
68 |
69 | clean:
70 | @$(WAF) clean
71 | @-find tools/ -name "*.pyc" -delete
72 |
73 | distclean: clean docclean
74 | @-rm -rf build/
75 |
76 | check:
77 | @tools/waf-light check
78 |
79 | VERSION=$(shell git describe)
80 | TARNAME=node-$(VERSION)
81 |
82 | dist: doc/node.1 doc/api.html
83 | git archive --prefix=$(TARNAME)/ HEAD > $(TARNAME).tar
84 | mkdir -p $(TARNAME)/doc
85 | cp doc/node.1 $(TARNAME)/doc/node.1
86 | cp doc/api.html $(TARNAME)/doc/api.html
87 | tar rf $(TARNAME).tar \
88 | $(TARNAME)/doc/node.1 \
89 | $(TARNAME)/doc/api.html
90 | rm -r $(TARNAME)
91 | gzip -f -9 $(TARNAME).tar
92 |
93 | .PHONY: benchmark clean docclean dist distclean check uninstall install all test test-all website-upload
94 |
--------------------------------------------------------------------------------
/testData/parsing/ParseWithMacrosDef.cpp:
--------------------------------------------------------------------------------
1 | void main () {
2 |
3 | #define C() \
4 | do \
5 | { \
6 | int z = 0; \
7 | if (z) { \
8 | } \
9 | z = z * 2; \
10 | } \
11 | while (false)
12 |
13 | for(;;) {
14 | if (1) {
15 | C ();
16 | }
17 | }
18 | C ();
19 | }
--------------------------------------------------------------------------------
/testData/parsing/ParseWithNs.cpp:
--------------------------------------------------------------------------------
1 | namespace Mode
2 | {
3 | class Mode_error: public Msg
4 | {
5 | public:
6 | typedef Mode_error const * R;
7 | Str::C const msg;
8 | Mode_error ( Str::C const _msg, Text::Seg const text);
9 | Mode_error (Msg::Kind const kind, Str::C const _msg, Text::Seg const text);
10 | virtual void out (Str::Buf<> & out, Text::Seg const text) const;
11 | };
12 |
13 | class Error;
14 | class Unknown;
15 | class Based;
16 | # define DefHash(Type,Init) class Type;
17 | # include "mode.tab.inc"
18 | # undef DefHash
19 |
20 | template
21 | M const * hash__clone (Allocate::T & store, M const * const src)
22 | { return POOL_NEW (store, M) (*src); }
23 |
24 | extern Function const * hash__clone (Allocate::T & store, Function const * const src);
25 |
26 | # include "mode.tab.h"
27 |
28 | class FunctionRequired: public Msg
29 | {
30 | public:
31 | FunctionRequired (Text::Seg const _text);
32 | virtual void out (Str::Buf<> & out, Text::Seg const text) const;
33 | };
34 | }
35 |
36 | // comment \
37 | continues
--------------------------------------------------------------------------------
/testData/parsing/SimpleParse.cpp:
--------------------------------------------------------------------------------
1 | #include "A.h"
2 | /**************************************************************************
3 | * Start cleaning up *
4 | **************************************************************************/
5 | void main() {
6 | warn(1,1,1,1);
7 | warn(1,1,1,1);
8 | a->*bbb(aaa[1]);
9 | if (true) {
10 | cout << errr << flush;
11 | }
12 | warn(1,1,1,1);
13 | }
14 |
15 | static STLInfo g_stlinfo[] =
16 | {
17 | // className baseClass1 baseClass2 templType1 templName1 templType2 templName2 virtInheritance // iterators
18 | { "overflow_error", "runtime_error", 0, 0, 0, 0, 0, FALSE, FALSE },
19 | { "underflow_error", "runtime_error", 0, 0, 0, 0, 0, FALSE, FALSE },
20 | { 0, 0, 0, 0, 0, 0, 0, FALSE, FALSE }
21 | };
22 |
23 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
24 | && (defined (__STDC__) || defined (__cplusplus)))
25 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
26 | # elif (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
27 | && (defined (__STDC__) || defined (__cplusplus)))
28 | void *malloc (size_t); /* INFRINGES ON USER NAME SPACE */
29 | # endif
30 |
31 | static void main(const char* p) {
32 | int a = 1;
33 | }
34 |
35 | void aaa();
36 | void bbb() {};
37 |
38 | #ifdef HAS_SIGNALS
39 | static void stopGen(int)
40 | {
41 | exit(1);
42 | }
43 | #endif
44 |
45 | # \
46 |
47 | # define W(name,default) \
48 | if (Str::eq (real_name, #name)) \
49 | project -> options -> warnings.name = state; \
50 | else
51 | WARNINGS_LIST
52 | # undef W
53 |
54 | class A {
55 | A &operator=(const A &);
56 | A &operator ==(const A &);
57 | ~A();
58 | };
59 |
--------------------------------------------------------------------------------
/testSrc/tests/CppParsingTest.java:
--------------------------------------------------------------------------------
1 | package tests;
2 |
3 | import com.intellij.codeInsight.TargetElementUtil;
4 | import com.intellij.psi.PsiElement;
5 | import com.intellij.psi.PsiReference;
6 | import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
7 |
8 | /**
9 | * @author maxim
10 | */
11 | public class CppParsingTest extends BaseCppTestCase {
12 |
13 | protected String getTestDataPath() {
14 | return "testData/parsing";
15 | }
16 |
17 | public void test() throws Throwable {
18 | doParseTest("SimpleParse");
19 | String docContent = myFixture.getEditor().getDocument().getCharsSequence().toString();
20 | String marker = "warn";
21 |
22 | PsiReference psiReference = myFixture.getFile().findReferenceAt(docContent.indexOf(marker) + marker.length());
23 | assertNotNull(psiReference);
24 | assertTrue(!(psiReference instanceof PsiMultiReference));
25 |
26 | marker = "operator ==";
27 | int offset = docContent.indexOf(marker) + marker.length() - 1;
28 | psiReference = myFixture.getFile().findReferenceAt(offset);
29 | assertNotNull(psiReference);
30 | assertTrue(!(psiReference instanceof PsiMultiReference));
31 |
32 | PsiElement psiElement = TargetElementUtil.getInstance().findTargetElement(myFixture.getEditor(), TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED |
33 | TargetElementUtil.ELEMENT_NAME_ACCEPTED, offset);
34 |
35 | assertNotNull(psiElement);
36 |
37 | marker = "operator=";
38 | offset = docContent.indexOf(marker) + marker.length() - 1;
39 | psiReference = myFixture.getFile().findReferenceAt(offset);
40 | assertNotNull(psiReference);
41 | assertTrue(!(psiReference instanceof PsiMultiReference));
42 | psiElement = TargetElementUtil.getInstance().findTargetElement(myFixture.getEditor(), TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED |
43 | TargetElementUtil.ELEMENT_NAME_ACCEPTED, offset);
44 | assertNotNull(psiElement);
45 | }
46 |
47 | public void testParseWithMacrosDef() throws Throwable {
48 | doParseTest(getTestName());
49 | }
50 |
51 | public void testParseWithNs() throws Throwable {
52 | doParseTest(getTestName());
53 | }
54 |
55 | private void doParseTest(String fileName) throws Throwable {
56 | super.doParseTest(fileName, "cpp");
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/testSrc/tests/HighlightCommandTest.java:
--------------------------------------------------------------------------------
1 | package tests;
2 |
3 | import com.advancedtools.cpp.hilighting.AnalyzeProcessor;
4 | import com.advancedtools.cpp.hilighting.Fix;
5 | import com.advancedtools.cpp.hilighting.HighlightCommand;
6 | import gnu.trove.TIntObjectHashMap;
7 | import junit.framework.TestCase;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | /**
13 | * Created by IntelliJ IDEA.
14 | * User: Maxim
15 | * Date: 16.08.2010
16 | * Time: 12:18:44
17 | */
18 | public class HighlightCommandTest extends TestCase {
19 | static class MessageInfo {
20 | final int start;
21 | final int end;
22 | final AnalyzeProcessor.MessageType type;
23 | final Fix[] fixes;
24 | final String text;
25 |
26 | public MessageInfo(int start, int end, String text, AnalyzeProcessor.MessageType type, Fix[] fixes) {
27 | this.start = start;
28 | this.end = end;
29 | this.text = text;
30 | this.type = type;
31 | this.fixes = fixes;
32 | }
33 | }
34 | public void test() {
35 | HighlightCommand.initErrorsDataInTest("16|SEMANTIC|Undefined identifier `%0'|1", "112|MODE|void function cannot return value|0");
36 | final List messages = new ArrayList(2);
37 | HighlightCommand.processErrorInfoFromString("27483|27486|16|res|112|fix:24|fix:27", new AnalyzeProcessor() {
38 | public String getAnalizedFileName() {
39 | return "foo.cpp";
40 | }
41 |
42 | public void startedAnalyzedFileName(String fileName) {}
43 |
44 | public void addMessage(MessageType type, int start, int end, String message, Fix... fixes) {
45 | messages.add(new MessageInfo(start, end, message, type, fixes));
46 | }
47 | });
48 |
49 | assertEquals(2, messages.size());
50 | MessageInfo messageInfo = messages.get(0);
51 | assertEquals(messageInfo.start, 27483);
52 | assertEquals(messageInfo.end, 27486);
53 | assertEquals(messageInfo.text, "Undefined identifier `res'");
54 | assertEquals(messageInfo.type, AnalyzeProcessor.MessageType.Error);
55 | assertEquals(2, messageInfo.fixes.length);
56 |
57 | messageInfo = messages.get(1);
58 | assertEquals(messageInfo.start, 27483);
59 | assertEquals(messageInfo.end, 27486);
60 | assertEquals(messageInfo.text, "void function cannot return value");
61 | assertEquals(messageInfo.type, AnalyzeProcessor.MessageType.Error);
62 | assertEquals(0, messageInfo.fixes.length);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/testSrc/tests/MakefileParsingTest.java:
--------------------------------------------------------------------------------
1 | package tests;
2 |
3 | import com.intellij.psi.PsiElement;
4 | import com.intellij.psi.PsiReference;
5 | import com.intellij.psi.ResolveResult;
6 | import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
7 |
8 | /**
9 | * @author maxim
10 | */
11 | public class MakefileParsingTest extends BaseCppTestCase {
12 | protected String getTestDataPath() {
13 | return "testData/makefile_parsing";
14 | }
15 |
16 | public void testMakefile1() throws Throwable {
17 | doParseTest(getTestName(),"mk");
18 | }
19 |
20 | public void testMakefile2() throws Throwable {
21 | doParseTest(getTestName(),"mk");
22 | }
23 |
24 | public void testMakefile3() throws Throwable {
25 | doParseTest(getTestName(),"mk");
26 | }
27 |
28 | public void testCheckRefResolve() throws Throwable {
29 | refTest();
30 | }
31 |
32 | private void refTest() throws Throwable {
33 | myFixture.testHighlighting(getTestName() + ".mk");
34 | PsiReference psiReference = myFixture.getFile().findReferenceAt(myFixture.getEditor().getCaretModel().getOffset());
35 | assertNotNull(psiReference);
36 | PsiElement psiElement = psiReference.resolve();
37 | assertNotNull(psiElement);
38 | }
39 |
40 | public void testCheckRefResolve2() throws Throwable {
41 | refTest();
42 | }
43 |
44 | public void testCheckRefResolve3() throws Throwable {
45 | myFixture.testHighlighting(getTestName() + ".mk");
46 | PsiReference psiReference = myFixture.getFile().findReferenceAt(myFixture.getEditor().getCaretModel().getOffset());
47 | assertTrue(psiReference instanceof PsiMultiReference);
48 | ResolveResult[] resolveResults = ((PsiMultiReference) psiReference).multiResolve(false);
49 | assertEquals(2, resolveResults.length);
50 |
51 | assertNotNull(resolveResults[0].getElement());
52 | assertNotNull(resolveResults[1].getElement());
53 |
54 | // TODO
55 | //assertEquals(2, ReferencesSearch.search(resolveResults[0].getElement()).findAll().size());
56 | //assertEquals(2, ReferencesSearch.search(resolveResults[1].getElement()).findAll().size());
57 | }
58 |
59 | public void testCompleteTargetRef() throws Throwable {
60 | myFixture.testCompletion(getTestName() + ".mk", getTestName() + "_after.mk");
61 | }
62 |
63 | public void testCompleteVar() throws Throwable {
64 | myFixture.testCompletion(getTestName() + ".mk", getTestName() + "_after.mk");
65 | }
66 | }
--------------------------------------------------------------------------------