Prechádzať zdrojové kódy

added npm package typescript-collections

Oliver 9 rokov pred
rodič
commit
719daae419
4 zmenil súbory, kde vykonal 36 pridanie a 1 odobranie
  1. 1 0
      .gitignore
  2. 1 0
      package.json
  3. 32 0
      test/Common/DataObjects/fraction_Test.ts
  4. 2 1
      tsconfig.json

+ 1 - 0
.gitignore

@@ -52,3 +52,4 @@ typings
 .vscode/
 .idea/encodings.xml
 *.md
+node_modules/

+ 1 - 0
package.json

@@ -27,6 +27,7 @@
         "jszip": "",
         "vexflow": "",
         "es6-promise": "",
+        "typescript-collections": "",
 
         "chai": "^3.4.1",
         "mocha": "^2.3.4",

+ 32 - 0
test/Common/DataObjects/fraction_Test.ts

@@ -2,6 +2,7 @@
  * Created by Oliver on 16.03.2016.
  */
 import { Fraction } from "../../../src/Common/DataObjects/fraction";
+import * as Collections from "../../../node_modules/typescript-collections";
 
 describe("Fraction Unit Tests:", () => {
     describe("Construct Fraction, check properties", () => {
@@ -33,4 +34,35 @@ describe("Fraction Unit Tests:", () => {
         done();
       });
     });
+    // Todo: remove when typescript porting phase 2 is done an project is compiling properly again
+    describe("blablabla", () => {
+        let dict: Collections.Dictionary<Fraction, Fraction> = new Collections.Dictionary<Fraction, Fraction>();
+        //     new Collections.Dictionary<Fraction, Fraction>(
+        //     function(f: Fraction): string {
+        //         return f.toString();
+        // });
+
+        let keys: Fraction[] = [];
+        let values: Fraction[] = [];
+
+        for (let i: number = 0; i < 10; ++i) {
+            keys.push(new Fraction(1, i));
+            values.push(new Fraction(i, 1));
+            dict.setValue(keys[i], values[i]);
+        }
+
+        it("retrieved fractions should be equal", (done: MochaDone) => {
+            for (let i: number = 9; i > -1; --i) {
+                let key: Fraction = keys[i];
+                let value: Fraction = values[i];
+
+                //console.log(values[i].toString() + "== " + dict.getValue(key));
+                console.log(values[i].toString() + "== " + dict.getValue(new Fraction(key.Numerator, key.Denominator)));
+                // chai.expect(dict.getValue(key)).to.equal(value);
+                chai.expect(dict.getValue(new Fraction(key.Numerator, key.Denominator))).to.equal(value);
+            }
+
+            done();
+        });
+    });
 });

+ 2 - 1
tsconfig.json

@@ -1,6 +1,7 @@
 {
   "compilerOptions": {
-    "target": "ES5"
+    "target": "ES5",
+    "moduleResolution": "node"
   },
   "exclude": [
     "node_modules",