OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/savannah_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__savannah_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const savannah_test = Object.create(null); |
| 11 let MapOfBigGame$String = () => (MapOfBigGame$String = dart.constFn(core.Map$(
savannah_test.BigGame, core.String)))(); |
| 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 13 savannah_test.BigGame = class BigGame extends core.Object {}; |
| 14 savannah_test.Giraffe = class Giraffe extends core.Object { |
| 15 new(name) { |
| 16 this.name = name; |
| 17 this.identityHash_ = savannah_test.Giraffe.nextId(); |
| 18 } |
| 19 get hashCode() { |
| 20 return this.identityHash_; |
| 21 } |
| 22 static nextId() { |
| 23 if (savannah_test.Giraffe.nextId_ == null) { |
| 24 savannah_test.Giraffe.nextId_ = 17; |
| 25 } |
| 26 let x = savannah_test.Giraffe.nextId_; |
| 27 savannah_test.Giraffe.nextId_ = dart.notNull(x) + 1; |
| 28 return x; |
| 29 } |
| 30 }; |
| 31 savannah_test.Giraffe[dart.implements] = () => [savannah_test.BigGame]; |
| 32 dart.setSignature(savannah_test.Giraffe, { |
| 33 constructors: () => ({new: dart.definiteFunctionType(savannah_test.Giraffe,
[core.String])}), |
| 34 statics: () => ({nextId: dart.definiteFunctionType(core.int, [])}), |
| 35 names: ['nextId'] |
| 36 }); |
| 37 savannah_test.Giraffe.nextId_ = null; |
| 38 savannah_test.Zebra = class Zebra extends core.Object { |
| 39 new(name) { |
| 40 this.name = name; |
| 41 } |
| 42 }; |
| 43 savannah_test.Zebra[dart.implements] = () => [savannah_test.BigGame]; |
| 44 dart.setSignature(savannah_test.Zebra, { |
| 45 constructors: () => ({new: dart.definiteFunctionType(savannah_test.Zebra, [c
ore.String])}) |
| 46 }); |
| 47 savannah_test.SavannahTest = class SavannahTest extends core.Object { |
| 48 static testMain() { |
| 49 let savannah = MapOfBigGame$String().new(); |
| 50 let giraffe1 = new savannah_test.Giraffe("Tony"); |
| 51 let giraffe2 = new savannah_test.Giraffe("Rose"); |
| 52 savannah[dartx.set](giraffe1, giraffe1.name); |
| 53 savannah[dartx.set](giraffe2, giraffe2.name); |
| 54 core.print(dart.str`giraffe1 hash: ${giraffe1.hashCode}`); |
| 55 core.print(dart.str`giraffe2 hash: ${giraffe2.hashCode}`); |
| 56 let count = savannah[dartx.length]; |
| 57 core.print(dart.str`getCount is ${count}`); |
| 58 expect$.Expect.equals(2, count); |
| 59 core.print(dart.str`giraffe1: ${savannah[dartx.get](giraffe1)}`); |
| 60 core.print(dart.str`giraffe2: ${savannah[dartx.get](giraffe2)}`); |
| 61 expect$.Expect.equals("Tony", savannah[dartx.get](giraffe1)); |
| 62 expect$.Expect.equals("Rose", savannah[dartx.get](giraffe2)); |
| 63 let zebra1 = new savannah_test.Zebra("Paolo"); |
| 64 let zebra2 = new savannah_test.Zebra("Zeeta"); |
| 65 savannah[dartx.set](zebra1, zebra1.name); |
| 66 savannah[dartx.set](zebra2, zebra2.name); |
| 67 core.print(dart.str`zebra1 hash: ${zebra1.hashCode}`); |
| 68 core.print(dart.str`zebra2 hash: ${zebra2.hashCode}`); |
| 69 count = savannah[dartx.length]; |
| 70 core.print(dart.str`getCount is ${count}`); |
| 71 expect$.Expect.equals(4, count); |
| 72 core.print(dart.str`zebra1: ${savannah[dartx.get](zebra1)}`); |
| 73 core.print(dart.str`zebra2: ${savannah[dartx.get](zebra2)}`); |
| 74 expect$.Expect.equals("Paolo", savannah[dartx.get](zebra1)); |
| 75 expect$.Expect.equals("Zeeta", savannah[dartx.get](zebra2)); |
| 76 } |
| 77 }; |
| 78 dart.setSignature(savannah_test.SavannahTest, { |
| 79 statics: () => ({testMain: dart.definiteFunctionType(dart.void, [])}), |
| 80 names: ['testMain'] |
| 81 }); |
| 82 savannah_test.main = function() { |
| 83 savannah_test.SavannahTest.testMain(); |
| 84 }; |
| 85 dart.fn(savannah_test.main, VoidTodynamic()); |
| 86 // Exports: |
| 87 exports.savannah_test = savannah_test; |
| 88 }); |
OLD | NEW |