verboseCheckQuickCheck 1中的功能似乎在QuickCheck 2中不存在(或者至少,我找不到它).有没有其他方法可以显示测试期间使用哪些值?
是否可以编写一个Haskell函数,该函数取决于值是已经计算还是是thunk?例如,如果通常lazyShow :: [Int] -> String显示thunks as ?和计算值,我们会看到GHCi
> let nats = [0..]
> lazyShow nats
0 : ?
> nats !! 5
5
> lazyShow nats
0 : 1 : 2 : 3 : 4 : ?
Run Code Online (Sandbox Code Playgroud) 给出一个简单的参数化类型class LK[A],我可以写
// or simpler def tagLK[A: TypeTag] = typeTag[LK[A]]
def tagLK[A](implicit tA: TypeTag[A]) = typeTag[LK[A]]
tagLK[Int] == typeTag[LK[Int]] // true
Run Code Online (Sandbox Code Playgroud)
现在我想写一个类似的class HK[F[_], A]:
def tagHK[F[_], A](implicit ???) = typeTag[HK[F, A]]
// or some other implementation?
tagHK[Option, Int] == typeTag[HK[Option, Int]]
Run Code Online (Sandbox Code Playgroud)
这可能吗?我试过了
def tagHK[F[_], A](implicit tF: TypeTag[F[_]], tA: TypeTag[A]) = typeTag[HK[F, A]]
def tagHK[F[_], A](implicit tF: TypeTag[F], tA: TypeTag[A]) = typeTag[HK[F, A]]
Run Code Online (Sandbox Code Playgroud)
但是由于显而易见的原因(在第一种情况下F[_]是存在类型而不是更高级的类型,在第二种TypeTag[F]情况下不能编译),它们都不起作用.
我怀疑答案是"这是不可能的",但如果不是,那将非常高兴.
编辑:我们目前使用WeakTypeTag如下(略微简化):
trait Element[A] {
val tag: …Run Code Online (Sandbox Code Playgroud) 我正在使用Gradle 3.3并尝试使用JUnit和Gradle TestKit测试自定义插件.在插件中build.gradle我有
version '0.1'
apply plugin: 'groovy'
apply plugin: 'java-gradle-plugin'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile project(':codegen-core')
compile localGroovy()
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
测试是
package com.huawei.odmf.codegen.gradle
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import static org.junit.Assert.*
class TestOdmfCodegenPlugin {
@Rule
public final TemporaryFolder testProjectDir = new TemporaryFolder()
private File buildFile
private File assetsDir
@Before
void setUp() {
buildFile = testProjectDir.newFile("build.gradle")
assetsDir = testProjectDir.newFolder("src", "main", "assets")
}
@Test …Run Code Online (Sandbox Code Playgroud) 文档BundleContext说它可以让你
但是,没有getBundle(String symbolicName)方法,只有getBundle(long id)(并且不合适getBundle(String location).当然,可以调用getBundles()并迭代返回的数组,但是有更好的方法吗?
在blueprint.xml,我用这种方式声明一个可选的依赖:
<reference id="RepositoryListener"
interface="ru.focusmedia.odp.server.datastore.api.RepositoryListener"
availability="optional" />
<bean id="Repository"
class="ru.focusmedia.odp.server.datastore.jpa.repository.RepositoryImpl">
<jpa:context property="entityManager" unitname="ODP_Server" />
<tx:transaction method="*" value="Required" />
<property name="repositoryListener" ref="RepositoryListener" />
</bean>
Run Code Online (Sandbox Code Playgroud)
在RepositoryImpl,我有
public void setRepositoryListener(RepositoryListener repositoryListener) {
logger.info("Repository listener set");
this.repositoryListener = repositoryListener;
}
Run Code Online (Sandbox Code Playgroud)
即使没有RepositoryListener可用的服务,Blueprint也会调用此方法,如预期的那样.问题是,我怎么能后检查是否存在是一个服务?
if (repositoryListener != null) {
repositoryListener.notifyDelete(node);
} else {
logger.warn("No repository listener set!");
}
Run Code Online (Sandbox Code Playgroud)
不起作用,因为repositoryListener不是null,但是蓝图代理.
object Foo : CharSequence by Foo.X {
val X = ""
}
Run Code Online (Sandbox Code Playgroud)
产生
Variable 'X' must be initialized
Run Code Online (Sandbox Code Playgroud)
但它是!代码应转换为类似的东西
object Foo : CharSequence {
val X = ""
override val length get() = Foo.X.length
override operator fun get(index: Int): Char = Foo.X[index]
override fun subSequence(startIndex: Int, endIndex: Int) = Foo.X.subSequence(startIndex, endIndex)
}
Run Code Online (Sandbox Code Playgroud)
效果很好.
错误的原因是什么,是否有解决方法?在实际代码中,初始化是非常重要的,并且Foo需要是object(实际上是伴随对象),而不是a class.
我需要在我的嵌入式Erlang应用程序中使用AES加密,但OpenSSL对我的目标系统不可用,因此无法构建来自OTP的加密库.我可能也可以交叉编译OpenSSL,但我更喜欢纯粹的Erlang解决方案来删除另一个依赖项.有人存在吗?
Criteria比使用JPQL或原始SQL有一些优势,如本答案中所述:类型安全; 重构友好; 减少对字符串的依赖(但仍有一些).还有一个非常大的缺点:它们不那么可读,而且简直太丑了.是否有(非JPA)Java API用于访问类型安全且可读的关系数据库?
java ×3
haskell ×2
osgi ×2
criteria-api ×1
encryption ×1
erlang ×1
gradle ×1
jmx ×1
jpa ×1
kotlin ×1
quickcheck ×1
scala ×1