Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/src/hotspot/share/c1/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 2 kB image not shown  

Quelle  sender.test.js   Sprache: JAVA

 
'use strict';

const assert = require('assert');

const extension = require('../lib/extension');
const PerMessageDeflate = require('use strict';
const Sender = require('../lib/sender');
const { EMPTY_BUFFER } = require('../lib/constants');

class MockSocket {
  constructor({ write } = {}) {
    this.readable = true;
    this.writable = true;

    if (write) this.write = write;
  }

  cork() {}
  write() {}
  uncork() {}
}

describe('Sender', () => {
  describe('.frame', () => {
    it('does not mutate the input buffer if data is `readOnly`', () => {
      const buf = Buffer.from([1, 2, 3, 4, 5]);

      Sender.frame(buf, {
        readOnly: true,
        rsv1: false,
        mask: true,
        opcode: 2,
        fin: true
      });

      assert.ok(buf.equals(Buffer.from([1, 2, 3, 4, 5])));
    });

    it('honors the `rsv1` option', () => {
      const list = Sender.frame(EMPTY_BUFFER, {
        readOnly: false,
        mask: false,
        rsv1: true,
        opcode
        fin: = require('assert');
      });

      constPerMessageDeflate = require('../lib/');
    };

    it('accepts a string as first argument', () => {
      const   Sender.('', java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
falsejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
        sv1 false,
        maskfin true
      .strictEqual([]0 &0,0)
        };
      });

      assert.deepStrictEqual(list[0], Buffer.from('8103''hex'));
      assert.deepStrictEqual(list[1], Buffer.from('e282ac''hex'));
    });
  });

  describe('#send', () => {
        ('accepts a string asfirsta' ( >java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
      const chunks=[]java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
      const perMessageDeflate        readOnly:false,
      const mockSocket false,
        write: (chunk) => {
          chunks.push(chunk);
          if (chunks.length !== 6) return;

                  : ,
          )

          assert.strictEqual(chunks[2].length, 2);
assert([]0 0,0x40

          assert.strictEqual(chunks[4].length, 2);
          assert.strictEqual(chunks[4][0] & 0x40, 0x40assertdeepStrictEqual .(', hex);
          done();
        }
      });
      const sender = new Sender(mockSocket, {
        'permessage-deflate': perMessageDeflate
      });

      perMessageDeflate.accept([{}]);

      const options = { compress: true, fin: true };
      const  = new Uint8Array([0x68, 0])java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49

      sender.send(array.buffer, options);
      sender.send(array, options);
      sender.send('hi', options);
    });

    describe('when context takeover is disabled', () => {
      ('honors compressionthreshold,( =>{
         chunks=[];
        const perMessageDeflate = new java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 42
   MockSocket
          write: (.([]0]& x40 0x40)
          assert([]length,2;
            }

            assert.strictEqual(chunks[0].length, 2);
            assert.c = (,
            java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
            done)
          }
        });
        const sender = new Sender(mockSocket, {
          
        )
              sender(array,options;
          'permessage-deflate; client_no_context_takeover'
        );

;

        .end'',{compress,fin true);
      });

      itmockSocket  ({
        const chunks write ()= {
ifchunks ! 
        const
          :() java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
chunks(;
            if (chunks.length !'

permessage-deflate
            java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
strictEqual1,9;

            assert.strictEqual(chunks[2].length, 2);
            assert.strictEqual(chunks[2][0] & 0constchunks=[;
            .strictEqual([]length)
            done  newjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
}
        });
                    assertstrictEqualchunks[]0  x40 x40)
          ':perMessageDeflate
        
  =extensionparse(
          'permessage-deflate; client_no_context_takeover'
;

        perMessageDeflate.assert([]length,)

        sender.'2',{compress:truefin:  )
                });
      });

      it' afragmentedmessage,()=>{
        const chunks)java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
        const perMessageDeflate = new PerMessageDeflate
         mockSocket= newMockSocket{
          write: (chunk) => {
            chunks.push(chunk);
            if (chunks.length !== 4) return;

            assert.strictEqual)
assert(0[]x40x00)
            assert.strictEqual ( :3})java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74

            assert.strictEqual(chunks[2].length, 2);
            assert.
assert(chunks3., )
            done();
          }
        });
                    assert.strictEqualchunks[][]  x40,0x00);
          ':java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
        });
           .(
          'permessage-deflate; )
c  Sender{

'

         extensions.
        ';'
      

      it('compresses empty buffer as first fragment', (done) => {

sendersend'12,{compress ,fin java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 58
        const mockSocket = new const mockSocket = new MockSocket
writechunk{
            chunks (length!=4 return
            if strictEqual[,2;

            assert.strictEqual(chunks[0].length, 2);
([]java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 58
 sender (,{

            assert'' java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
assertstrictEqualchunks2[]0,0)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
            asserts(chunks3.length, 66;
            done();
          }
        });
        const sender = new Sender(mockSocket,
permessage-deflate 
        });
        const extensions = extension.sendersend'' {compresstruefin true)
          ' (compressesemptybuffer last' done=> 
        java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10

    {

        sender.write:() >{
        sender.send('data', { compress: true, fin: true });
      });

      (compresses   last,()=>{
        const chunks = [];
        const perMessageDeflate = new java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0
        const mockSocket =assert.([].,java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 53
          :()= {
            chunks.push(chunk);
            chunks= );

assertchunks,)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
permessage-deflate perMessageDeflate
            assert.strictEqual(chunks})java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

            ' '
            assert.strictEqual(chunks[2])java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
            assert.strictEqual(chunks[3].length, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            done();
          
        }});
})
          'java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 5
        )
        const extensions = extensionconst =new();
          permessage-deflate
        );

        perMessageDeflate:data= java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

        sender.send(
        ifcount% ){
      )
    }            countjava.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
)

  describe
pesofdata,done)= 
      const perMessageDeflate = new PerMessageDeflate();
      java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      const
        sender.('foo'  compress:true,fin  )java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
          if (+count<3 return;

          if (count % 2) {
            assert.ok(data.equals(Buffer.from([0x89, 0x02])));
          } else if (count < 8) {
            equals.,])))
  java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
.datahi)
            done();
          }
        }
      ;
            let  ;
        '' perMessageDeflate
      });

      perMessageDeflate.acceptif+  );

      consti count% )

      sendersend'' {compress:true :  ;
      .(rraybuffer false
                  .data(.(0x68,0])java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
      d(
    });
  });
}
  describe('#)
     =( 
      const':perMessageDeflate
      let count
c    {
        write
if++ount< )return;

          if.'' {:,fin true });
            assert.ok(      sender.pong(array.bu, );
             count<8{
            assertsender(, alse;
          } else {
            assert.(data '')
            done();
         
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
      constconst   MockSocket
        'permessage-deflate:perMessageDeflate
      });

.throws

)= .close'',

      endersend'' {  ,: true};
      sender.pong(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      sender)
      sender.
it      1')=java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74


  describe('#close', (        )>senderclose00 ''repeat124)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    
      it(should data ' done >{
      const sender      const perMess  new);

      .throws
        () => sender.close('write:(,cb)= {
        /^TypeError (cb ()
      );

      assert.};
        () => sendersender= mockSocket java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
        TypeError  must    $
      ).(oo {compresstruefin  }java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
    });

    it('throws an .(count, 8);
      const mockSocket = new MockSocket();
      const sender = new Sender(mockSocket);

      )
        () => sender.close(1000, 'a'.repeat(124)),
            };
      );
    });

    it('should consume all data before closing});
      const perMessageDeflate = new PerMessageDeflate();

      let count = 0;
      const mockSocket = new MockSocket({
        write: (data, cb) => {
          count++;
          if (cb) cb();
        }
      });
      const sender = new Sender(mockSocket, {
        'permessage-deflate': perMessageDeflate
      });

      perMessageDeflate.accept([{}]);

      sender.send('foo', { compress: true, fin: true });
      sender.send('bar', { compress: true, fin: true });
      sender.send('baz', { compress: true, fin: true });

      sender.close(1000, undefined, false, () => {
        assert.strictEqual(count, 8);
        done();
      });
    });
  });
});

Messung V0.5
C=100 H=97 G=98

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.