Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
f0ef450b
Commit
f0ef450b
authored
Oct 05, 2020
by
aniket-engg
Committed by
Aniket
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed legacy tests
parent
74c31b4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
101 deletions
+0
-101
LegacyTest.ts
libs/remix-astwalker/tests/LegacyTest.ts
+0
-101
No files found.
libs/remix-astwalker/tests/LegacyTest.ts
deleted
100644 → 0
View file @
74c31b4b
import
tape
from
"tape"
;
import
{
AstWalker
,
AstNodeLegacy
}
from
"../src"
;
import
node
from
"./resources/legacyAST"
;
tape
(
"ASTWalker Legacy"
,
(
t
:
tape
.
Test
)
=>
{
t
.
test
(
"ASTWalker.walk && .walkAST"
,
(
st
:
tape
.
Test
)
=>
{
st
.
plan
(
17
);
// New Ast Object
const
astWalker
=
new
AstWalker
();
// EventListener
astWalker
.
on
(
"node"
,
node
=>
{
if
(
node
.
name
===
"ContractDefinition"
)
{
checkContract
(
st
,
node
);
}
if
(
node
.
name
===
"FunctionDefinition"
)
{
checkSetFunction
(
st
,
node
);
checkGetFunction
(
st
,
node
);
}
if
(
node
.
name
===
"VariableDeclaration"
)
{
checkSetFunction
(
st
,
node
);
checkGetFunction
(
st
,
node
);
}
});
// Callback pattern
astWalker
.
walk
(
node
.
legacyAST
,
(
node
:
AstNodeLegacy
)
=>
{
if
(
node
.
name
===
"ContractDefinition"
)
{
checkContract
(
st
,
node
);
}
if
(
node
.
name
===
"FunctionDefinition"
)
{
checkSetFunction
(
st
,
node
);
checkGetFunction
(
st
,
node
);
}
if
(
node
.
name
===
"VariableDeclaration"
)
{
checkSetFunction
(
st
,
node
);
checkGetFunction
(
st
,
node
);
}
});
// Callback Object
var
callback
:
any
=
{};
callback
.
FunctionDefinition
=
function
(
node
:
AstNodeLegacy
):
boolean
{
st
.
equal
(
node
.
name
,
"FunctionDefinition"
);
return
true
;
};
// Calling walk function with cb
astWalker
.
walk
(
node
.
legacyAST
,
callback
);
// Calling walk function without cb
astWalker
.
walk
(
node
.
legacyAST
);
// Calling WALKASTLIST function
astWalker
.
walkAstList
(
node
);
// Calling walkASTList with new AST format
astWalker
.
walkAstList
(
node
);
// Calling WALKASTLIST function with cb
astWalker
.
walkAstList
(
node
,
node
=>
{
return
true
;
});
st
.
end
();
});
});
function
checkContract
(
st
:
tape
.
Test
,
node
:
AstNodeLegacy
)
{
st
.
equal
(
node
.
attributes
.
name
,
"Greeter"
);
st
.
equal
(
node
.
children
[
1
].
attributes
.
name
,
"greeting"
);
st
.
equal
(
node
.
children
[
1
].
attributes
.
type
,
"string"
);
st
.
equal
(
node
.
children
[
2
].
name
,
"FunctionDefinition"
);
st
.
equal
(
node
.
children
[
2
].
attributes
.
name
,
""
);
}
function
checkSetFunction
(
st
:
tape
.
Test
,
node
:
AstNodeLegacy
)
{
if
(
node
.
attributes
.
name
===
"set"
)
{
st
.
equal
(
node
.
children
[
0
].
name
,
"ParameterList"
);
st
.
equal
(
node
.
children
[
1
].
name
,
"ParameterList"
);
st
.
equal
(
node
.
children
[
2
].
name
,
"Block"
);
st
.
equal
(
node
.
children
[
2
].
children
[
1
].
name
,
"ExpressionStatement"
);
checkExpressionStatement
(
st
,
node
.
children
[
2
].
children
[
0
]);
}
}
function
checkGetFunction
(
st
:
tape
.
Test
,
node
:
AstNodeLegacy
)
{
if
(
node
.
attributes
.
name
===
"get"
)
{
st
.
equal
(
node
.
children
[
0
].
name
,
"ParameterList"
);
st
.
equal
(
node
.
children
[
1
].
name
,
"ParameterList"
);
st
.
equal
(
node
.
children
[
2
].
name
,
"Block"
);
}
}
function
checkExpressionStatement
(
st
:
tape
.
Test
,
node
:
AstNodeLegacy
)
{
st
.
equal
(
node
.
children
[
0
].
name
,
"Assignment"
);
st
.
equal
(
node
.
children
[
0
].
attributes
.
operator
,
"="
);
st
.
equal
(
node
.
children
[
0
].
attributes
.
type
,
"int256"
);
st
.
equal
(
node
.
children
[
0
].
children
[
0
].
name
,
"Identifier"
);
st
.
equal
(
node
.
children
[
0
].
children
[
0
].
attributes
.
value
,
"x"
);
st
.
equal
(
node
.
children
[
0
].
children
[
1
].
name
,
"Identifier"
);
st
.
equal
(
node
.
children
[
0
].
children
[
1
].
attributes
.
value
,
"_x"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment