Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
39dc1a1c
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
39dc1a1c
编写于
6月 01, 2012
作者:
P
pTalanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revert
9f0fcc28
上级
fd708484
变更
19
展开全部
隐藏空白更改
内联
并排
Showing
19 changed file
with
33 addition
and
3963 deletion
+33
-3963
js/js.libraries/src/junit/core.kt
js/js.libraries/src/junit/core.kt
+0
-4
js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java
js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java
+1
-1
js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java
...org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java
+0
-44
js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java
...est/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java
+13
-9
js/js.tests/test/org/jetbrains/k2js/test/utils/TranslationUtils.java
.../test/org/jetbrains/k2js/test/utils/TranslationUtils.java
+4
-7
js/js.translator/qunit/deepEqual.js
js/js.translator/qunit/deepEqual.js
+0
-1432
js/js.translator/qunit/headless.html
js/js.translator/qunit/headless.html
+0
-24
js/js.translator/qunit/index.html
js/js.translator/qunit/index.html
+0
-19
js/js.translator/qunit/logs.html
js/js.translator/qunit/logs.html
+0
-13
js/js.translator/qunit/logs.js
js/js.translator/qunit/logs.js
+0
-180
js/js.translator/qunit/qunit.css
js/js.translator/qunit/qunit.css
+0
-236
js/js.translator/qunit/qunit.js
js/js.translator/qunit/qunit.js
+0
-1803
js/js.translator/qunit/swarminject.js
js/js.translator/qunit/swarminject.js
+0
-9
js/js.translator/src/org/jetbrains/k2js/config/Config.java
js/js.translator/src/org/jetbrains/k2js/config/Config.java
+1
-2
js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java
...nslator/src/org/jetbrains/k2js/facade/K2JSTranslator.java
+8
-11
js/js.translator/src/org/jetbrains/k2js/generate/CodeGenerator.java
...slator/src/org/jetbrains/k2js/generate/CodeGenerator.java
+3
-8
js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java
...rains/k2js/translate/general/JetTestFunctionDetector.java
+0
-86
js/js.translator/src/org/jetbrains/k2js/translate/general/Translation.java
...src/org/jetbrains/k2js/translate/general/Translation.java
+3
-59
libraries/stdlib/test/js/SimpleTest.kt
libraries/stdlib/test/js/SimpleTest.kt
+0
-16
未找到文件。
js/js.libraries/src/junit/core.kt
已删除
100644 → 0
浏览文件 @
fd708484
package
org.junit;
native
annotation
class
Test
(
name
:
String
=
""
)
{}
\ No newline at end of file
js/js.tests/test/org/jetbrains/k2js/test/BasicTest.java
浏览文件 @
39dc1a1c
...
...
@@ -102,7 +102,7 @@ public abstract class BasicTest extends TestWithEnvironment {
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EnumSet
<
EcmaVersion
>
ecmaVersions
)
throws
Exception
{
for
(
EcmaVersion
version
:
ecmaVersions
)
{
TranslationUtils
.
translateFiles
(
getProject
(),
files
,
getOutputFilePath
(
testName
,
version
),
mainCallParameters
,
version
,
null
);
TranslationUtils
.
translateFiles
(
getProject
(),
files
,
getOutputFilePath
(
testName
,
version
),
mainCallParameters
,
version
);
}
}
...
...
js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java
已删除
100644 → 0
浏览文件 @
fd708484
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.k2js.test.semantics
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Sets
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.cli.common.ExitCode
;
import
org.jetbrains.jet.cli.js.K2JSCompiler
;
import
org.jetbrains.jet.cli.js.K2JSCompilerArguments
;
import
org.jetbrains.k2js.config.Config
;
import
org.jetbrains.k2js.config.EcmaVersion
;
import
org.jetbrains.k2js.facade.MainCallParameters
;
import
org.jetbrains.k2js.test.SingleFileTranslationTest
;
import
java.io.File
;
import
java.util.EnumSet
;
import
java.util.List
;
import
java.util.Set
;
/**
*/
public
class
StdLibTestToJSTest
extends
StdLibToJSTest
{
public
void
testCompileJavaScriptFiles
()
throws
Exception
{
generateJavaScriptFiles
(
EcmaVersion
.
all
(),
"libraries/stdlib/test"
,
"js/SimpleTest.kt"
);
}
}
js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java
浏览文件 @
39dc1a1c
...
...
@@ -24,6 +24,7 @@ import org.jetbrains.jet.cli.js.K2JSCompiler;
import
org.jetbrains.jet.cli.js.K2JSCompilerArguments
;
import
org.jetbrains.k2js.config.Config
;
import
org.jetbrains.k2js.config.EcmaVersion
;
import
org.jetbrains.k2js.facade.MainCallParameters
;
import
org.jetbrains.k2js.test.SingleFileTranslationTest
;
import
java.io.File
;
...
...
@@ -33,24 +34,27 @@ import java.util.Set;
/**
*/
public
class
StdLibToJSTest
extends
SingleFileTranslationTest
{
public
final
class
StdLibToJSTest
extends
SingleFileTranslationTest
{
public
StdLibToJSTest
()
{
super
(
"stdlib/"
);
}
public
void
testCompile
JavaScript
Files
()
throws
Exception
{
public
void
testCompile
StandardLibrary
Files
()
throws
Exception
{
generateJavaScriptFiles
(
EcmaVersion
.
all
(),
"libraries/stdlib/src"
,
"kotlin/Preconditions.kt"
,
"kotlin/dom/Dom.kt"
,
"kotlin/support/AbstractIterator.kt"
);
generateJavaScriptFiles
(
MainCallParameters
.
noCall
(),
EcmaVersion
.
all
(),
"kotlin/Preconditions.kt"
,
"kotlin/dom/Dom.kt"
,
"kotlin/support/AbstractIterator.kt"
);
}
protected
void
generateJavaScriptFiles
(
@NotNull
EnumSet
<
EcmaVersion
>
ecmaVersions
,
@NotNull
String
sourceDir
,
@NotNull
String
...
stdLibFiles
)
throws
Exception
{
protected
void
generateJavaScriptFiles
(
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EnumSet
<
EcmaVersion
>
ecmaVersions
,
String
...
stdLibFiles
)
throws
Exception
{
List
<
String
>
files
=
Lists
.
newArrayList
();
File
stdlibDir
=
new
File
(
sourceDir
);
File
stdlibDir
=
new
File
(
"libraries/stdlib/src"
);
assertTrue
(
"Cannot find stdlib source: "
+
stdlibDir
,
stdlibDir
.
exists
());
for
(
String
file
:
stdLibFiles
)
{
files
.
add
(
new
File
(
stdlibDir
,
file
).
getPath
());
...
...
@@ -74,12 +78,12 @@ public class StdLibToJSTest extends SingleFileTranslationTest {
// now lets try invoke the compiler
for
(
EcmaVersion
version
:
ecmaVersions
)
{
System
.
out
.
println
(
"Compiling with version: "
+
version
);
K2JSCompiler
compiler
=
new
K2JSCompiler
();
K2JSCompilerArguments
arguments
=
new
K2JSCompilerArguments
();
arguments
.
outputFile
=
getOutputFilePath
(
getTestName
(
false
)
+
".compiler.kt"
,
version
);
arguments
.
sourceFiles
=
files
;
arguments
.
verbose
=
true
;
System
.
out
.
println
(
"Compiling with version: "
+
version
+
" to: "
+
arguments
.
outputFile
);
ExitCode
answer
=
compiler
.
exec
(
System
.
out
,
arguments
);
assertEquals
(
"Compile failed"
,
ExitCode
.
OK
,
answer
);
}
...
...
js/js.tests/test/org/jetbrains/k2js/test/utils/TranslationUtils.java
浏览文件 @
39dc1a1c
...
...
@@ -48,20 +48,17 @@ public final class TranslationUtils {
public
static
void
translateFile
(
@NotNull
Project
project
,
@NotNull
String
inputFile
,
@NotNull
String
outputFile
,
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EcmaVersion
version
)
throws
Exception
{
translateFiles
(
project
,
Collections
.
singletonList
(
inputFile
),
outputFile
,
mainCallParameters
,
version
,
null
);
translateFiles
(
project
,
Collections
.
singletonList
(
inputFile
),
outputFile
,
mainCallParameters
,
version
);
}
public
static
void
translateFiles
(
@NotNull
Project
project
,
@NotNull
List
<
String
>
inputFiles
,
@NotNull
String
outputFile
,
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EcmaVersion
version
,
List
<
String
>
rawStatements
)
throws
Exception
{
@NotNull
String
outputFile
,
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EcmaVersion
version
)
throws
Exception
{
List
<
JetFile
>
psiFiles
=
createPsiFileList
(
inputFiles
,
project
);
JsProgram
program
=
getTranslator
(
project
,
version
).
generateProgram
(
psiFiles
,
mainCallParameters
,
rawStatements
);
JsProgram
program
=
getTranslator
(
project
,
version
).
generateProgram
(
psiFiles
,
mainCallParameters
);
FileWriter
writer
=
new
FileWriter
(
new
File
(
outputFile
));
try
{
writer
.
write
(
"\"use strict\";\n"
);
writer
.
write
(
CodeGenerator
.
toString
(
program
,
null
));
writer
.
write
(
CodeGenerator
.
toString
(
program
));
}
finally
{
writer
.
close
();
...
...
js/js.translator/qunit/deepEqual.js
已删除
100644 → 0
浏览文件 @
fd708484
此差异已折叠。
点击以展开。
js/js.translator/qunit/headless.html
已删除
100644 → 0
浏览文件 @
fd708484
<!DOCTYPE html>
<html>
<head>
<title>
QUnit Test Suite
</title>
<link
rel=
"stylesheet"
href=
"qunit.css"
type=
"text/css"
media=
"screen"
>
<script
type=
"text/javascript"
src=
"qunit.js"
></script>
<script
type=
"text/javascript"
src=
"test.js"
></script>
<script
type=
"text/javascript"
src=
"deepEqual.js"
></script>
<script>
var
logs
=
[
"
begin
"
,
"
testStart
"
,
"
testDone
"
,
"
log
"
,
"
moduleStart
"
,
"
moduleDone
"
,
"
done
"
];
for
(
var
i
=
0
;
i
<
logs
.
length
;
i
++
)
{
(
function
()
{
var
log
=
logs
[
i
];
QUnit
[
log
]
=
function
()
{
console
.
log
(
log
,
arguments
);
};
})();
}
</script>
</head>
<body>
<div
id=
"qunit-fixture"
>
test markup
</div>
</body>
</html>
js/js.translator/qunit/index.html
已删除
100644 → 0
浏览文件 @
fd708484
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
/>
<title>
Kotlin QUnit Test Suite
</title>
<link
rel=
"stylesheet"
href=
"qunit.css"
>
<script
src=
"qunit.js"
></script>
<script
src=
"../testFiles/kotlin_lib.js"
></script>
<script
src=
"../testFiles/stdlib/out/CompileJavaScriptFiles.compiler_v3.js"
></script>
<script
src=
"deepEqual.js"
></script>
<script
src=
"swarminject.js"
></script>
</head>
<body>
<div
id=
"qunit"
></div>
<div
id=
"qunit-fixture"
>
test markup
</div>
</body>
</html>
js/js.translator/qunit/logs.html
已删除
100644 → 0
浏览文件 @
fd708484
<!DOCTYPE html>
<html>
<head>
<title>
QUnit Test Suite
</title>
<link
rel=
"stylesheet"
href=
"qunit.css"
type=
"text/css"
media=
"screen"
>
<script
type=
"text/javascript"
src=
"qunit.js"
></script>
<script
type=
"text/javascript"
src=
"logs.js"
></script>
</head>
<body>
<div
id=
"qunit"
></div>
<div
id=
"qunit-fixture"
>
test markup
</div>
</body>
</html>
js/js.translator/qunit/logs.js
已删除
100644 → 0
浏览文件 @
fd708484
// TODO disable reordering for this suite!
var
begin
=
0
,
moduleStart
=
0
,
moduleDone
=
0
,
testStart
=
0
,
testDone
=
0
,
log
=
0
,
moduleContext
,
moduleDoneContext
,
testContext
,
testDoneContext
,
logContext
;
QUnit
.
begin
(
function
()
{
begin
++
;
});
QUnit
.
done
(
function
()
{
});
QUnit
.
moduleStart
(
function
(
context
)
{
moduleStart
++
;
moduleContext
=
context
;
});
QUnit
.
moduleDone
(
function
(
context
)
{
moduleDone
++
;
moduleDoneContext
=
context
;
});
QUnit
.
testStart
(
function
(
context
)
{
testStart
++
;
testContext
=
context
;
});
QUnit
.
testDone
(
function
(
context
)
{
testDone
++
;
testDoneContext
=
context
;
});
QUnit
.
log
(
function
(
context
)
{
log
++
;
logContext
=
context
;
});
var
logs
=
[
"
begin
"
,
"
testStart
"
,
"
testDone
"
,
"
log
"
,
"
moduleStart
"
,
"
moduleDone
"
,
"
done
"
];
for
(
var
i
=
0
;
i
<
logs
.
length
;
i
++
)
{
(
function
()
{
var
log
=
logs
[
i
];
QUnit
[
log
](
function
()
{
console
.
log
(
log
,
arguments
);
});
})();
}
module
(
"
logs1
"
);
test
(
"
test1
"
,
13
,
function
()
{
equal
(
begin
,
1
);
equal
(
moduleStart
,
1
);
equal
(
testStart
,
1
);
equal
(
testDone
,
0
);
equal
(
moduleDone
,
0
);
deepEqual
(
logContext
,
{
result
:
true
,
message
:
undefined
,
actual
:
0
,
expected
:
0
});
equal
(
"
foo
"
,
"
foo
"
,
"
msg
"
);
deepEqual
(
logContext
,
{
result
:
true
,
message
:
"
msg
"
,
actual
:
"
foo
"
,
expected
:
"
foo
"
});
strictEqual
(
testDoneContext
,
undefined
);
deepEqual
(
testContext
,
{
module
:
"
logs1
"
,
name
:
"
test1
"
});
strictEqual
(
moduleDoneContext
,
undefined
);
deepEqual
(
moduleContext
,
{
name
:
"
logs1
"
});
equal
(
log
,
12
);
});
test
(
"
test2
"
,
10
,
function
()
{
equal
(
begin
,
1
);
equal
(
moduleStart
,
1
);
equal
(
testStart
,
2
);
equal
(
testDone
,
1
);
equal
(
moduleDone
,
0
);
deepEqual
(
testDoneContext
,
{
module
:
"
logs1
"
,
name
:
"
test1
"
,
failed
:
0
,
passed
:
13
,
total
:
13
});
deepEqual
(
testContext
,
{
module
:
"
logs1
"
,
name
:
"
test2
"
});
strictEqual
(
moduleDoneContext
,
undefined
);
deepEqual
(
moduleContext
,
{
name
:
"
logs1
"
});
equal
(
log
,
22
);
});
module
(
"
logs2
"
);
test
(
"
test1
"
,
9
,
function
()
{
equal
(
begin
,
1
);
equal
(
moduleStart
,
2
);
equal
(
testStart
,
3
);
equal
(
testDone
,
2
);
equal
(
moduleDone
,
1
);
deepEqual
(
testContext
,
{
module
:
"
logs2
"
,
name
:
"
test1
"
});
deepEqual
(
moduleDoneContext
,
{
name
:
"
logs1
"
,
failed
:
0
,
passed
:
23
,
total
:
23
});
deepEqual
(
moduleContext
,
{
name
:
"
logs2
"
});
equal
(
log
,
31
);
});
test
(
"
test2
"
,
8
,
function
()
{
equal
(
begin
,
1
);
equal
(
moduleStart
,
2
);
equal
(
testStart
,
4
);
equal
(
testDone
,
3
);
equal
(
moduleDone
,
1
);
deepEqual
(
testContext
,
{
module
:
"
logs2
"
,
name
:
"
test2
"
});
deepEqual
(
moduleContext
,
{
name
:
"
logs2
"
});
equal
(
log
,
39
);
});
var
testAutorun
=
true
;
QUnit
.
done
(
function
()
{
if
(
!
testAutorun
)
{
return
;
}
testAutorun
=
false
;
module
(
"
autorun
"
);
test
(
"
reset
"
,
0
,
function
()
{});
moduleStart
=
moduleDone
=
0
;
test
(
"
first
"
,
function
(){
equal
(
moduleStart
,
1
,
"
test started
"
);
equal
(
moduleDone
,
0
,
"
test in progress
"
);
});
test
(
"
second
"
,
function
(){
equal
(
moduleStart
,
2
,
"
test started
"
);
equal
(
moduleDone
,
1
,
"
test in progress
"
);
});
});
js/js.translator/qunit/qunit.css
已删除
100644 → 0
浏览文件 @
fd708484
/**
* QUnit v1.7.0pre - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
* Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
/** Font Family and Sizes */
#qunit-tests
,
#qunit-header
,
#qunit-banner
,
#qunit-testrunner-toolbar
,
#qunit-userAgent
,
#qunit-testresult
{
font-family
:
"Helvetica Neue Light"
,
"HelveticaNeue-Light"
,
"Helvetica Neue"
,
Calibri
,
Helvetica
,
Arial
,
sans-serif
;
}
#qunit-testrunner-toolbar
,
#qunit-userAgent
,
#qunit-testresult
,
#qunit-tests
li
{
font-size
:
small
;
}
#qunit-tests
{
font-size
:
smaller
;
}
/** Resets */
#qunit-tests
,
#qunit-tests
ol
,
#qunit-header
,
#qunit-banner
,
#qunit-userAgent
,
#qunit-testresult
{
margin
:
0
;
padding
:
0
;
}
/** Header */
#qunit-header
{
padding
:
0.5em
0
0.5em
1em
;
color
:
#8699a4
;
background-color
:
#0d3349
;
font-size
:
1.5em
;
line-height
:
1em
;
font-weight
:
normal
;
border-radius
:
15px
15px
0
0
;
-moz-border-radius
:
15px
15px
0
0
;
-webkit-border-top-right-radius
:
15px
;
-webkit-border-top-left-radius
:
15px
;
}
#qunit-header
a
{
text-decoration
:
none
;
color
:
#c2ccd1
;
}
#qunit-header
a
:hover
,
#qunit-header
a
:focus
{
color
:
#fff
;
}
#qunit-header
label
{
display
:
inline-block
;
padding-left
:
0.5em
;
}
#qunit-banner
{
height
:
5px
;
}
#qunit-testrunner-toolbar
{
padding
:
0.5em
0
0.5em
2em
;
color
:
#5E740B
;
background-color
:
#eee
;
}
#qunit-userAgent
{
padding
:
0.5em
0
0.5em
2.5em
;
background-color
:
#2b81af
;
color
:
#fff
;
text-shadow
:
rgba
(
0
,
0
,
0
,
0.5
)
2px
2px
1px
;
}
/** Tests: Pass/Fail */
#qunit-tests
{
list-style-position
:
inside
;
}
#qunit-tests
li
{
padding
:
0.4em
0.5em
0.4em
2.5em
;
border-bottom
:
1px
solid
#fff
;
list-style-position
:
inside
;
}
#qunit-tests
.hidepass
li
.pass
,
#qunit-tests
.hidepass
li
.running
{
display
:
none
;
}
#qunit-tests
li
strong
{
cursor
:
pointer
;
}
#qunit-tests
li
a
{
padding
:
0.5em
;
color
:
#c2ccd1
;
text-decoration
:
none
;
}
#qunit-tests
li
a
:hover
,
#qunit-tests
li
a
:focus
{
color
:
#000
;
}
#qunit-tests
ol
{
margin-top
:
0.5em
;
padding
:
0.5em
;
background-color
:
#fff
;
border-radius
:
15px
;
-moz-border-radius
:
15px
;
-webkit-border-radius
:
15px
;
box-shadow
:
inset
0px
2px
13px
#999
;
-moz-box-shadow
:
inset
0px
2px
13px
#999
;
-webkit-box-shadow
:
inset
0px
2px
13px
#999
;
}
#qunit-tests
table
{
border-collapse
:
collapse
;
margin-top
:
.2em
;
}
#qunit-tests
th
{
text-align
:
right
;
vertical-align
:
top
;
padding
:
0
.5em
0
0
;
}
#qunit-tests
td
{
vertical-align
:
top
;
}
#qunit-tests
pre
{
margin
:
0
;
white-space
:
pre-wrap
;
word-wrap
:
break-word
;
}
#qunit-tests
del
{
background-color
:
#e0f2be
;
color
:
#374e0c
;
text-decoration
:
none
;
}
#qunit-tests
ins
{
background-color
:
#ffcaca
;
color
:
#500
;
text-decoration
:
none
;
}
/*** Test Counts */
#qunit-tests
b
.counts
{
color
:
black
;
}
#qunit-tests
b
.passed
{
color
:
#5E740B
;
}
#qunit-tests
b
.failed
{
color
:
#710909
;
}
#qunit-tests
li
li
{
margin
:
0.5em
;
padding
:
0.4em
0.5em
0.4em
0.5em
;
background-color
:
#fff
;
border-bottom
:
none
;
list-style-position
:
inside
;
}
/*** Passing Styles */
#qunit-tests
li
li
.pass
{
color
:
#5E740B
;
background-color
:
#fff
;
border-left
:
26px
solid
#C6E746
;
}
#qunit-tests
.pass
{
color
:
#528CE0
;
background-color
:
#D2E0E6
;
}
#qunit-tests
.pass
.test-name
{
color
:
#366097
;
}
#qunit-tests
.pass
.test-actual
,
#qunit-tests
.pass
.test-expected
{
color
:
#999999
;
}
#qunit-banner
.qunit-pass
{
background-color
:
#C6E746
;
}
/*** Failing Styles */
#qunit-tests
li
li
.fail
{
color
:
#710909
;
background-color
:
#fff
;
border-left
:
26px
solid
#EE5757
;
white-space
:
pre
;
}
#qunit-tests
>
li
:last-child
{
border-radius
:
0
0
15px
15px
;
-moz-border-radius
:
0
0
15px
15px
;
-webkit-border-bottom-right-radius
:
15px
;
-webkit-border-bottom-left-radius
:
15px
;
}
#qunit-tests
.fail
{
color
:
#000000
;
background-color
:
#EE5757
;
}
#qunit-tests
.fail
.test-name
,
#qunit-tests
.fail
.module-name
{
color
:
#000000
;
}
#qunit-tests
.fail
.test-actual
{
color
:
#EE5757
;
}
#qunit-tests
.fail
.test-expected
{
color
:
green
;
}
#qunit-banner
.qunit-fail
{
background-color
:
#EE5757
;
}
/** Result */
#qunit-testresult
{
padding
:
0.5em
0.5em
0.5em
2.5em
;
color
:
#2b81af
;
background-color
:
#D2E0E6
;
border-bottom
:
1px
solid
white
;
}
#qunit-testresult
.module-name
{
font-weight
:
bold
;
}
/** Fixture */
#qunit-fixture
{
position
:
absolute
;
top
:
-10000px
;
left
:
-10000px
;
width
:
1000px
;
height
:
1000px
;
}
js/js.translator/qunit/qunit.js
已删除
100644 → 0
浏览文件 @
fd708484
此差异已折叠。
点击以展开。
js/js.translator/qunit/swarminject.js
已删除
100755 → 0
浏览文件 @
fd708484
// load testswarm agent
(
function
()
{
var
url
=
window
.
location
.
search
;
url
=
decodeURIComponent
(
url
.
slice
(
url
.
indexOf
(
"
swarmURL=
"
)
+
9
)
);
if
(
!
url
||
url
.
indexOf
(
"
http
"
)
!==
0
)
{
return
;
}
document
.
write
(
"
<scr
"
+
"
ipt src='http://swarm.jquery.org/js/inject.js?
"
+
(
new
Date
).
getTime
()
+
"
'></scr
"
+
"
ipt>
"
);
})();
js/js.translator/src/org/jetbrains/k2js/config/Config.java
浏览文件 @
39dc1a1c
...
...
@@ -68,8 +68,7 @@ public abstract class Config {
"/dom/domcore.kt"
,
"/dom/html/htmlcore.kt"
,
"/dom/html5/canvas.kt"
,
"/dom/html/window.kt"
,
"/junit/core.kt"
"/dom/html/window.kt"
);
public
static
final
String
LIBRARIES_LOCATION
=
"js/js.libraries/src"
;
...
...
js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java
浏览文件 @
39dc1a1c
...
...
@@ -67,38 +67,35 @@ public final class K2JSTranslator {
@NotNull
public
String
translateStringWithCallToMain
(
@NotNull
String
programText
,
@NotNull
String
argumentsString
)
throws
TranslationException
{
JetFile
file
=
JetFileUtils
.
createPsiFile
(
"test"
,
programText
,
getProject
());
String
programCode
=
generateProgramCode
(
file
,
MainCallParameters
.
mainWithArguments
(
parseString
(
argumentsString
))
,
null
)
+
"\n"
;
String
programCode
=
generateProgramCode
(
file
,
MainCallParameters
.
mainWithArguments
(
parseString
(
argumentsString
)))
+
"\n"
;
String
flushOutput
=
"Kotlin.System.flush();\n"
;
String
programOutput
=
"Kotlin.System.output();\n"
;
return
flushOutput
+
programCode
+
programOutput
;
}
@NotNull
public
String
generateProgramCode
(
@NotNull
JetFile
file
,
@NotNull
MainCallParameters
mainCallParameters
,
List
<
String
>
rawStatements
)
throws
TranslationException
{
JsProgram
program
=
generateProgram
(
Arrays
.
asList
(
file
),
mainCallParameters
,
rawStatements
);
public
String
generateProgramCode
(
@NotNull
JetFile
file
,
@NotNull
MainCallParameters
mainCallParameters
)
throws
TranslationException
{
JsProgram
program
=
generateProgram
(
Arrays
.
asList
(
file
),
mainCallParameters
);
CodeGenerator
generator
=
new
CodeGenerator
();
return
generator
.
generateToString
(
program
,
rawStatements
);
return
generator
.
generateToString
(
program
);
}
@NotNull
public
String
generateProgramCode
(
@NotNull
List
<
JetFile
>
files
,
@NotNull
MainCallParameters
mainCallParameters
)
throws
TranslationException
{
List
<
String
>
rawStatements
=
Lists
.
newArrayList
();
JsProgram
program
=
generateProgram
(
files
,
mainCallParameters
,
rawStatements
);
JsProgram
program
=
generateProgram
(
files
,
mainCallParameters
);
CodeGenerator
generator
=
new
CodeGenerator
();
return
generator
.
generateToString
(
program
,
rawStatements
);
return
generator
.
generateToString
(
program
);
}
@NotNull
public
JsProgram
generateProgram
(
@NotNull
List
<
JetFile
>
filesToTranslate
,
@NotNull
MainCallParameters
mainCallParameters
,
List
<
String
>
rawStatements
)
public
JsProgram
generateProgram
(
@NotNull
List
<
JetFile
>
filesToTranslate
,
@NotNull
MainCallParameters
mainCallParameters
)
throws
TranslationException
{
JetStandardLibrary
.
initialize
(
config
.
getProject
());
BindingContext
bindingContext
=
AnalyzerFacadeForJS
.
analyzeFilesAndCheckErrors
(
filesToTranslate
,
config
);
Collection
<
JetFile
>
files
=
AnalyzerFacadeForJS
.
withJsLibAdded
(
filesToTranslate
,
config
);
return
Translation
.
generateAst
(
bindingContext
,
Lists
.
newArrayList
(
files
),
mainCallParameters
,
config
.
getTarget
()
,
rawStatements
);
return
Translation
.
generateAst
(
bindingContext
,
Lists
.
newArrayList
(
files
),
mainCallParameters
,
config
.
getTarget
());
}
@NotNull
...
...
js/js.translator/src/org/jetbrains/k2js/generate/CodeGenerator.java
浏览文件 @
39dc1a1c
...
...
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.NotNull;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.List
;
/**
* @author Pavel.Talanov
...
...
@@ -44,8 +43,8 @@ public final class CodeGenerator {
}
@NotNull
public
static
String
toString
(
@NotNull
JsProgram
program
,
List
<
String
>
rawStatements
)
{
return
(
new
CodeGenerator
()).
generateToString
(
program
,
rawStatements
);
public
static
String
toString
(
@NotNull
JsProgram
program
)
{
return
(
new
CodeGenerator
()).
generateToString
(
program
);
}
public
void
generateToFile
(
@NotNull
JsProgram
program
,
@NotNull
File
file
)
throws
IOException
{
...
...
@@ -59,12 +58,8 @@ public final class CodeGenerator {
}
@NotNull
public
String
generateToString
(
@NotNull
JsProgram
program
,
List
<
String
>
rawStatements
)
{
public
String
generateToString
(
@NotNull
JsProgram
program
)
{
generateCode
(
program
);
for
(
String
statement
:
rawStatements
)
{
output
.
print
(
statement
);
output
.
newline
();
}
return
output
.
toString
();
}
...
...
js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java
已删除
100644 → 0
浏览文件 @
fd708484
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.k2js.translate.general
;
import
com.google.common.collect.Lists
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.descriptors.FunctionDescriptor
;
import
org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.resolve.BindingContext
;
import
org.jetbrains.jet.lang.types.JetType
;
import
org.jetbrains.k2js.translate.utils.BindingUtils
;
import
java.util.List
;
/**
* Helps find functions which are annotated with a @Test annotation from junit
*/
public
class
JetTestFunctionDetector
{
private
JetTestFunctionDetector
()
{
}
public
static
boolean
isTest
(
@NotNull
BindingContext
bindingContext
,
@NotNull
JetNamedFunction
function
)
{
FunctionDescriptor
functionDescriptor
=
BindingUtils
.
getFunctionDescriptor
(
bindingContext
,
function
);
if
(
functionDescriptor
!=
null
)
{
List
<
AnnotationDescriptor
>
annotations
=
functionDescriptor
.
getAnnotations
();
if
(
annotations
!=
null
)
{
for
(
AnnotationDescriptor
annotation
:
annotations
)
{
// TODO ideally we should find the fully qualified name here...
JetType
type
=
annotation
.
getType
();
String
name
=
type
.
toString
();
if
(
name
.
equals
(
"Test"
))
{
return
true
;
}
}
}
}
if
(
function
.
getName
().
startsWith
(
"test"
))
{
List
<
JetParameter
>
parameters
=
function
.
getValueParameters
();
return
parameters
.
size
()
==
0
;
}
return
false
;
}
@Nullable
public
static
List
<
JetNamedFunction
>
findTestFunctions
(
@NotNull
BindingContext
bindingContext
,
@NotNull
List
<
JetFile
>
files
)
{
List
<
JetNamedFunction
>
answer
=
Lists
.
newArrayList
();
for
(
JetFile
file
:
files
)
{
answer
.
addAll
(
getTestFunctions
(
bindingContext
,
file
.
getDeclarations
()));
}
return
answer
;
}
@Nullable
private
static
List
<
JetNamedFunction
>
getTestFunctions
(
@NotNull
BindingContext
bindingContext
,
@NotNull
List
<
JetDeclaration
>
declarations
)
{
List
<
JetNamedFunction
>
answer
=
Lists
.
newArrayList
();
for
(
JetDeclaration
declaration
:
declarations
)
{
if
(
declaration
instanceof
JetClass
)
{
JetClass
klass
=
(
JetClass
)
declaration
;
answer
.
addAll
(
getTestFunctions
(
bindingContext
,
klass
.
getDeclarations
()));
}
else
if
(
declaration
instanceof
JetNamedFunction
)
{
JetNamedFunction
candidateFunction
=
(
JetNamedFunction
)
declaration
;
if
(
isTest
(
bindingContext
,
candidateFunction
))
{
answer
.
add
(
candidateFunction
);
}
}
}
return
answer
;
}
}
js/js.translator/src/org/jetbrains/k2js/translate/general/Translation.java
浏览文件 @
39dc1a1c
...
...
@@ -19,10 +19,7 @@ package org.jetbrains.k2js.translate.general;
import
com.google.dart.compiler.backend.js.JsNamer
;
import
com.google.dart.compiler.backend.js.JsPrettyNamer
;
import
com.google.dart.compiler.backend.js.ast.*
;
import
com.intellij.openapi.util.text.StringUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.descriptors.ClassDescriptor
;
import
org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
;
import
org.jetbrains.jet.lang.descriptors.FunctionDescriptor
;
import
org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
;
import
org.jetbrains.jet.lang.psi.*
;
...
...
@@ -49,7 +46,6 @@ import org.jetbrains.k2js.translate.utils.JsAstUtils;
import
org.jetbrains.k2js.translate.utils.dangerous.DangerousData
;
import
org.jetbrains.k2js.translate.utils.dangerous.DangerousTranslator
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -148,10 +144,10 @@ public final class Translation {
@NotNull
public
static
JsProgram
generateAst
(
@NotNull
BindingContext
bindingContext
,
@NotNull
List
<
JetFile
>
files
,
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EcmaVersion
ecmaVersion
,
List
<
String
>
rawStatements
)
@NotNull
EcmaVersion
ecmaVersion
)
throws
TranslationException
{
try
{
return
doGenerateAst
(
bindingContext
,
files
,
mainCallParameters
,
ecmaVersion
,
rawStatements
);
return
doGenerateAst
(
bindingContext
,
files
,
mainCallParameters
,
ecmaVersion
);
}
catch
(
UnsupportedOperationException
e
)
{
throw
new
UnsupportedFeatureException
(
"Unsupported feature used."
,
e
);
...
...
@@ -164,7 +160,7 @@ public final class Translation {
@NotNull
private
static
JsProgram
doGenerateAst
(
@NotNull
BindingContext
bindingContext
,
@NotNull
List
<
JetFile
>
files
,
@NotNull
MainCallParameters
mainCallParameters
,
@NotNull
EcmaVersion
ecmaVersion
,
List
<
String
>
rawStatements
)
throws
MainFunctionNotFoundException
{
@NotNull
EcmaVersion
ecmaVersion
)
throws
MainFunctionNotFoundException
{
//TODO: move some of the code somewhere
JetStandardLibrary
standardLibrary
=
JetStandardLibrary
.
getInstance
();
StaticContext
staticContext
=
StaticContext
.
generateStaticContext
(
standardLibrary
,
bindingContext
,
ecmaVersion
);
...
...
@@ -174,7 +170,6 @@ public final class Translation {
if
(
mainCallParameters
.
shouldBeGenerated
())
{
block
.
getStatements
().
add
(
generateCallToMain
(
context
,
files
,
mainCallParameters
.
arguments
()));
}
generateTestCalls
(
context
,
files
,
block
,
rawStatements
);
JsNamer
namer
=
new
JsPrettyNamer
();
namer
.
exec
(
context
.
program
());
return
context
.
program
();
...
...
@@ -192,7 +187,6 @@ public final class Translation {
return
translatedCall
.
makeStmt
();
}
@NotNull
private
static
JsInvocation
generateInvocation
(
@NotNull
TranslationContext
context
,
@NotNull
JetNamedFunction
mainFunction
)
{
FunctionDescriptor
functionDescriptor
=
getFunctionDescriptor
(
context
.
bindingContext
(),
mainFunction
);
...
...
@@ -207,54 +201,4 @@ public final class Translation {
arrayLiteral
.
getExpressions
().
addAll
(
toStringLiteralList
(
arguments
,
context
.
program
()));
JsAstUtils
.
setArguments
(
translatedCall
,
Collections
.<
JsExpression
>
singletonList
(
arrayLiteral
));
}
@NotNull
private
static
void
generateTestCalls
(
@NotNull
TranslationContext
context
,
@NotNull
List
<
JetFile
>
files
,
@NotNull
JsBlock
block
,
List
<
String
>
rawStatements
)
{
ClassDescriptor
lastClassDescriptor
=
null
;
boolean
declaredVar
=
false
;
List
<
JetNamedFunction
>
functions
=
JetTestFunctionDetector
.
findTestFunctions
(
context
.
bindingContext
(),
files
);
for
(
JetNamedFunction
function
:
functions
)
{
FunctionDescriptor
functionDescriptor
=
getFunctionDescriptor
(
context
.
bindingContext
(),
function
);
String
funName
=
functionDescriptor
.
getName
().
getName
();
DeclarationDescriptor
containingDeclaration
=
functionDescriptor
.
getContainingDeclaration
();
if
(
containingDeclaration
instanceof
ClassDescriptor
)
{
ClassDescriptor
classDescriptor
=
(
ClassDescriptor
)
containingDeclaration
;
String
className
=
getQualifiedName
(
classDescriptor
);
if
(
lastClassDescriptor
!=
classDescriptor
)
{
lastClassDescriptor
=
classDescriptor
;
String
prefix
=
""
;
if
(!
declaredVar
)
{
prefix
=
"var "
;
declaredVar
=
true
;
}
rawStatements
.
add
(
prefix
+
"_testCase = new "
+
className
+
"();"
);
}
rawStatements
.
add
(
"QUnit.test( \""
+
className
+
"."
+
funName
+
"()\" , function() {"
);
rawStatements
.
add
(
" expect(0);"
);
rawStatements
.
add
(
" _testCase."
+
funName
+
"();"
);
}
else
{
rawStatements
.
add
(
"QUnit.test( \""
+
funName
+
"()\", function() {"
);
rawStatements
.
add
(
" expect(0);"
);
rawStatements
.
add
(
" "
+
funName
+
"();"
);
}
rawStatements
.
add
(
"});"
);
}
}
public
static
String
getQualifiedName
(
ClassDescriptor
classDescriptor
)
{
List
<
String
>
parts
=
new
ArrayList
<
String
>();
DeclarationDescriptor
current
=
classDescriptor
;
while
(
current
!=
null
)
{
String
name
=
current
.
getName
().
getName
();
if
(
name
.
startsWith
(
"<"
))
break
;
parts
.
add
(
name
);
current
=
current
.
getContainingDeclaration
();
}
Collections
.
reverse
(
parts
);
return
StringUtil
.
join
(
parts
,
"."
);
}
}
libraries/stdlib/test/js/SimpleTest.kt
已删除
100644 → 0
浏览文件 @
fd708484
package
testPackage
import
org.junit.Test
as
test
class
SimpleTest
{
public
fun
testFoo
()
{
val
name
=
"world"
val
message
=
"hello $name!"
}
test
fun
cheese
()
{
val
name
=
"world"
val
message
=
"bye $name!"
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录