在我看来,为了测试处理恶意响应的客户端代码,拥有一个总是返回500的URL是有用的.而且我可以想到其他项目可以从总是返回404,重定向等的URL中受益.是否有人知道提供此功能的免费网站?
我正在与Ragel一起评估FSA,我想嵌入一个用户操作,只要我的机器完成测试输入就会运行.无论机器是否以接受状态结束,我都需要执行此操作.我从Ragel指南中获取了这个修改过的示例,说明了我的目标:
#include <string.h>
#include <stdio.h>
%%{
machine foo;
main := ( 'foo' | 'bar' ) 0 @{ res = 1; } $/{ finished = 1; };
}%%
%% write data;
int main( int argc, char **argv ) {
int cs, res = 0, finished = 0;
if ( argc > 1 ) {
char *p = argv[1];
char *pe = p + strlen(p) + 1;
char* eof = pe;
%% write init;
%% write exec;
}
printf("result = %i\n", res …Run Code Online (Sandbox Code Playgroud) Java 8 添加了函数式编程结构,包括Function类及其关联identity()方法。
这是此方法的当前结构:
// Current implementation of this function in the [JDK source][1]
static <T> Function<T, T> identity() {
return t -> t;
}
// Can be used like this
List<T> sameList = list.stream().map(Function.identity()).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
但是,还有第二种构造它的方法:
// Alternative implementation of the method
static <T> T identity(T in) {
return in;
}
// Can be used like this
List<T> sameList = list.stream().map(Function::identity).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
甚至还有第三种方式来构建它:
// Third implementation
static final Function<T, T> IDENTITY_FUNCTION = t -> t;
// Can …Run Code Online (Sandbox Code Playgroud)