小编jia*_*gok的帖子

使用打字稿和业力进行单元测试

我正在使用karma,jasmine,typescript来编写来自https://angular.io/docs/js/latest/quickstart.html的helloworld应用程序的单元测试.

以下是测试代码:

///<reference path="../typings/jasmine/jasmine.d.ts"/>

import {
    MyAppComponent
} from '../spray1';

describe("name is Alice", () => {
    var comp = new MyAppComponent();

    it("verify name", () => {
        expect(comp.name).toBe("Alice"); 
    });
});
Run Code Online (Sandbox Code Playgroud)

tsc(带"--module commonjs")将此测试代码转换为:

///<reference path="../typings/jasmine/jasmine.d.ts"/>
var spray1_1 = require('../spray1');
describe("name is Alice", function () {
    var comp = new myAppComponent_1.MyAppComponent();
    it("verify name", function () {
        expect(comp.name).toBe("Alice");
    });
});
Run Code Online (Sandbox Code Playgroud)

业力未能运行单元测试:

未捕获错误:尚未为上下文加载模块名称"../myAppComponent":_.使用require([]) http://requirejs.org/docs/errors.html#notloaded at /Users/spray1/web2/node_modules/requirejs/require.js:141

Chrome 43.0.2357(Mac OS X 10.10.3):执行0 0成功(0秒/ 0秒)

如果我使用tsc"--module amd",则转换后的测试代码为:

define(["require", "exports", '../spray1'], function (require, exports, spray1_1) { …
Run Code Online (Sandbox Code Playgroud)

amd typescript karma-runner

11
推荐指数
1
解决办法
4303
查看次数

是否有针对.NET 4.0的CLR分析器?

我从这里下载链接文本的CLR分析器不适用于使用.NET 4.0实现的我的应用程序.是否有.NET 4.0版本?谢谢.

clr profiler

9
推荐指数
1
解决办法
5912
查看次数

为什么scala类需要显式扩展AnyRef

我从库中看到了一些代码:

trait A extends scala.AnyRef
trait B extends scala.AnyRef with A
Run Code Online (Sandbox Code Playgroud)

为什么A需要明确扩展AnyRef?是不是AnyRef已经隐式派生出所有类?

为什么B需要扩展AnyRef即使A已经这样做了?将上述代码更改为以下内容有何不同:

trait A
trait B extends A
Run Code Online (Sandbox Code Playgroud)

scala

8
推荐指数
1
解决办法
1745
查看次数

以异步方式使用Powershell的BeginInvoke()和EndInvoke()

有没有办法以真正的异步方式使用Powershell的BeginInvoke()和EndInvoke().那就是,我只是调用BeginInvoke()然后忘记而不是使用EndInvoke来等待返回或结果.我喜欢EndInvoke是一个在BeginInvoke()完成时自动调用的回调函数. MSDN上的示例实际上是同步的.

如何以真正的异步方式使用BeginInvoke()和EndInvoke()?谢谢.

powershell asynchronous

4
推荐指数
1
解决办法
2936
查看次数

Start-Sleep 内存泄漏(或导致 powershell 内存泄漏)?

这个问题来自https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/365ca396-400d-4401-bd7f-05d5d6c22cc8/powershells-startsleep-causes-memory-growth?forum=winserverpowershell

我在那里没有得到有效的答案,所以试试这个论坛是否可以提供帮助。这阻碍了我的工作。

这是我的两个 powershell 脚本。第一个是创建事件源,第二个是使用 4 个线程生成事件。每个线程中使用 Start-Sleep 来控制事件生成率。如果我删除 Start-Sleep,那么 powershell 内存使用量是恒定的,否则它会快速增长,直到使用完所有系统内存并且系统变得非常慢。

这是一个已知的问题?任何解决方法?欣赏任何线索。

# use this script to create channel and source if they does not exist.

$logName = "TestLog"
$sourceName = "TestSource"

New-EventLog -LogName $logName -Source $sourceName

# maximumSize's max is 4G.
Limit-EventLog -LogName $logName -OverflowAction OverWriteOlder -RetentionDays 30 -MaximumSize 3080000KB
Run Code Online (Sandbox Code Playgroud)

事件生成脚本:

# use this script to generate events in TestLog channel.

Param(
  [int]$sleepIntervalInMilliSeconds = 0
)

$eventGenScript = {
  $logName = "TestLog"
  $sourceName = "TestSource"

  while($true) { …
Run Code Online (Sandbox Code Playgroud)

powershell

0
推荐指数
1
解决办法
1612
查看次数