在我升级到Angular的新版本之后,我以前工作过的一个测试打破了,我不知道为什么.即我有一个记录错误的功能:
import { Observable, of } from 'rxjs';
export function handleError<T>(operation='operation', result?: T) {
return (error: any): Observable<T> => {
console.error(error);
console.info(`${operation} failed: ${error.message}`);
return of(result as T);
}
}
Run Code Online (Sandbox Code Playgroud)
我测试它:
it('#handleError return function should return an object', () => {
let errorFunction = handleError('dummyFetch', [{}]);
expect(typeof errorFunction({ message: 'Something went wrong.'})).toEqual('object');
expect(errorFunction({ message: 'Something went wrong.'})).toEqual(of([{}]));
});
Run Code Online (Sandbox Code Playgroud)
失败的行是,expect(errorFunction({ message: 'Something went wrong.'})).toEqual(of([{}]));并报告错误:Expected $._subscribe = Function to equal Function..由于异步错误功能,测试是否失败?
编辑:这是我解决的解决方案:
it('#handleError return function should return …Run Code Online (Sandbox Code Playgroud) NUMBERS='1,2,3 4,5,6 7,8,9'
for TOUPLE in $NUMBERS;
do IFS=',';
set -- $TOUPLE
echo \($1, $2, $3\)
done
echo ''
for TRIPLE in $NUMBERS;
do IFS=',';
set -- $TRIPLE
echo \($1, $2, $3\)
done
Run Code Online (Sandbox Code Playgroud)
这些应该基本上是相同的循环,并且它们应该打印相同的输出.但是,当我执行脚本时,我得到以下输出:
(1, 2, 3)
(4, 5, 6)
(7, 8, 9)
(1, , )
(2, , )
(3 4, , )
(5, , )
(6 7, , )
(8, , )
(9, , )
Run Code Online (Sandbox Code Playgroud)
为什么第二个循环的行为与第一个循环不同?
使用 ansible 2.7.5 我试图创建一个多行布尔参数。
我首先验证它是否按预期单行工作:
FOOD: apple
IS_FRUIT: '{% if FOOD == "carrot" %}false{% elif FOOD == "apple" or FOOD == "banana" %}true{% endif %}'
Run Code Online (Sandbox Code Playgroud)
然后是一个任务:
- name: "FOOD is: {{ FOOD }}"
debug: msg="FOOD is {{ FOOD }} where IS_FRUIT {{ IS_FRUIT | bool }}"
Run Code Online (Sandbox Code Playgroud)
打印:
ok: [localhost] => {
"msg": "FOOD is apple where IS_FRUIT [ True ]"
}
Run Code Online (Sandbox Code Playgroud)
运行时如预期。
基于:
然后我尝试过:
IS_FRUIT: >-
{% if FOOD == "carrot" %}false
{% elif FOOD == "apple" …Run Code Online (Sandbox Code Playgroud) 为什么poc在每次乘法完成后我的变量值都没有更新System.out.println();?
public static void main(String[] args) {
byte poc = 0b0001;
System.out.println("The value of byte " + poc + " when multiplied by 0010 is: " + poc*0b0010);
System.out.println("The value of byte " + poc + " when multiplied by 0010 is: " + poc*0b0010);
System.out.println("The value of byte " + poc + " when multiplied by 0010 is: " + poc*0b0010);
System.out.println("The value of byte " + poc + " when multiplied by 0010 is: …Run Code Online (Sandbox Code Playgroud)