912005267d
Change-Id: I46be49b2effec3e38a3dc44cd45cfe736f77fa78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182680 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Stephen Adams <sra@google.com>
67 lines
1.7 KiB
Dart
67 lines
1.7 KiB
Dart
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "native_testing.dart";
|
|
|
|
// Test for values of some basic types.
|
|
|
|
@Native("A")
|
|
class A {
|
|
returnNull() native;
|
|
returnUndefined() native;
|
|
returnEmptyString() native;
|
|
returnZero() native;
|
|
}
|
|
|
|
A makeA() native;
|
|
|
|
void setup() {
|
|
JS('', r"""
|
|
(function(){
|
|
function A() {}
|
|
A.prototype.returnNull = function() { return null; };
|
|
A.prototype.returnUndefined = function() { return void 0; };
|
|
A.prototype.returnEmptyString = function() { return ""; };
|
|
A.prototype.returnZero = function() { return 0; };
|
|
self.makeA = function(){return new A()};
|
|
self.nativeConstructor(A);
|
|
})()""");
|
|
applyTestExtensions(['A']);
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
staticTests() {
|
|
A a = makeA();
|
|
Expect.equals(null, a.returnNull());
|
|
Expect.equals(null, a.returnUndefined());
|
|
|
|
Expect.equals('', a.returnEmptyString());
|
|
Expect.isTrue(a.returnEmptyString().isEmpty);
|
|
Expect.isTrue(a.returnEmptyString() is String);
|
|
|
|
Expect.isTrue(a.returnZero() is int);
|
|
Expect.equals(0, a.returnZero());
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
dynamicTests() {
|
|
A a = makeA();
|
|
Expect.equals(null, confuse(a).returnNull());
|
|
Expect.equals(null, confuse(a).returnUndefined());
|
|
|
|
Expect.equals('', confuse(a).returnEmptyString());
|
|
Expect.isTrue(confuse(a).returnEmptyString().isEmpty);
|
|
Expect.isTrue(confuse(a).returnEmptyString() is String);
|
|
|
|
Expect.isTrue(confuse(a).returnZero() is int);
|
|
Expect.equals(0, confuse(a).returnZero());
|
|
}
|
|
|
|
main() {
|
|
nativeTesting();
|
|
setup();
|
|
staticTests();
|
|
dynamicTests();
|
|
}
|