From 4a48bedcd1d708a43d43dc6259a4e45c52ea3d00 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 3 Dec 2017 23:25:40 -0800 Subject: 4134 - 'input' = 'ingredient' --- html/064list.mu.html | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'html/064list.mu.html') diff --git a/html/064list.mu.html b/html/064list.mu.html index 937bf0b9..d9552c9a 100644 --- a/html/064list.mu.html +++ b/html/064list.mu.html @@ -72,20 +72,20 @@ if ('onhashchange' in window) { 10 11 def push x:_elem, l:&:list:_elem -> result:&:list:_elem/contained-in:l [ 12 local-scope - 13 load-ingredients + 13 load-inputs 14 result <- new {(list _elem): type} 15 *result <- merge x, l 16 ] 17 18 def first in:&:list:_elem -> result:_elem [ 19 local-scope - 20 load-ingredients + 20 load-inputs 21 result <- get *in, value:offset 22 ] 23 24 def rest in:&:list:_elem -> result:&:list:_elem/contained-in:in [ 25 local-scope - 26 load-ingredients + 26 load-inputs 27 result <- get *in, next:offset 28 ] 29 @@ -112,7 +112,7 @@ if ('onhashchange' in window) { 50 51 def length l:&:list:_elem -> result:num [ 52 local-scope - 53 load-ingredients + 53 load-inputs 54 result <- copy 0 55 { 56 ¦ break-unless l @@ -125,7 +125,7 @@ if ('onhashchange' in window) { 63 # insert 'x' after 'in' 64 def insert x:_elem, in:&:list:_elem -> in:&:list:_elem [ 65 local-scope - 66 load-ingredients + 66 load-inputs 67 new-node:&:list:_elem <- new {(list _elem): type} 68 *new-node <- put *new-node, value:offset, x 69 next-node:&:list:_elem <- get *in, next:offset @@ -217,7 +217,7 @@ if ('onhashchange' in window) { 155 # pointers to the head are now invalid. 156 def remove x:&:list:_elem/contained-in:in, in:&:list:_elem -> in:&:list:_elem [ 157 local-scope -158 load-ingredients +158 load-inputs 159 # if 'x' is null, return 160 return-unless x 161 next-node:&:list:_elem <- rest x @@ -327,7 +327,7 @@ if ('onhashchange' in window) { 265 # (contributed by Caleb Couch) 266 def reverse list:&:list:_elem temp:&:list:_elem/contained-in:result -> result:&:list:_elem [ 267 local-scope -268 load-ingredients +268 load-inputs 269 return-unless list, temp 270 object:_elem <- first, list 271 list <- rest list @@ -366,7 +366,7 @@ if ('onhashchange' in window) { 304 305 def to-text in:&:list:_elem -> result:text [ 306 local-scope -307 load-ingredients +307 load-inputs 308 buf:&:buffer:char <- new-buffer 80 309 buf <- to-buffer in, buf 310 result <- buffer-to-array buf @@ -375,7 +375,7 @@ if ('onhashchange' in window) { 313 # variant of 'to-text' which stops printing after a few elements (and so is robust to cycles) 314 def to-text-line in:&:list:_elem -> result:text [ 315 local-scope -316 load-ingredients +316 load-inputs 317 buf:&:buffer:char <- new-buffer 80 318 buf <- to-buffer in, buf, 6 # max elements to display 319 result <- buffer-to-array buf @@ -383,7 +383,7 @@ if ('onhashchange' in window) { 321 322 def to-buffer in:&:list:_elem, buf:&:buffer:char -> buf:&:buffer:char [ 323 local-scope -324 load-ingredients +324 load-inputs 325 { 326 ¦ break-if in 327 ¦ buf <- append buf, [[]] @@ -398,9 +398,9 @@ if ('onhashchange' in window) { 336 return-unless next 337 buf <- append buf, [ -> ] 338 # and recurse -339 remaining:num, optional-ingredient-found?:bool <- next-ingredient +339 remaining:num, optional-input-found?:bool <- next-input 340 { -341 ¦ break-if optional-ingredient-found? +341 ¦ break-if optional-input-found? 342 ¦ # unlimited recursion 343 ¦ buf <- to-buffer next, buf 344 ¦ return -- cgit 1.4.1-2-gfad0 href='#n270'>270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>

#include <stabber.h>
#include <expect.h>

#include "proftest.h"

void
sends_room_join(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/stabber'>"
            "<x xmlns='http://jabber.org/protocol/muc'/>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
sends_room_join_with_nick(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost nick testnick");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/testnick'>"
            "<x xmlns='http://jabber.org/protocol/muc'/>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
sends_room_join_with_password(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost password testpassword");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/stabber'>"
            "<x xmlns='http://jabber.org/protocol/muc'>"
                "<password>testpassword</password>"
            "</x>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
sends_room_join_with_nick_and_password(void **state)
{
    prof_connect();

    prof_input("/join testroom@conference.localhost nick testnick password testpassword");

    assert_true(stbbr_last_received(
        "<presence id='*' to='testroom@conference.localhost/testnick'>"
            "<x xmlns='http://jabber.org/protocol/muc'>"
                "<password>testpassword</password>"
            "</x>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' ver='*' node='http://profanity-im.github.io'/>"
        "</presence>"
    ));
}

void
shows_role_and_affiliation_on_join(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");

    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));
}

void
shows_subject_on_join(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost'>"
            "<subject>Test room subject</subject>"
            "<body>anothernick has set the subject to: Test room subject</body>"
        "</message>"
    );

    assert_true(prof_output_regex("Room subject: .+Test room subject"));
}

void
shows_history_message(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>an old message</body>"
            "<delay xmlns='urn:xmpp:delay' stamp='2015-12-19T23:55:25Z' from='testroom@conference.localhost'/>"
            "<x xmlns='jabber:x:delay' stamp='20151219T23:55:25'/>"
        "</message>"
    );

    assert_true(prof_output_regex("testoccupant: an old message"));
}

void
shows_occupant_join(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<presence to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='someuser@someserver.org/work' affiliation='none'/>"
            "</x>"
        "</presence>"
    );

    assert_true(prof_output_exact("-> testoccupant has joined the room, role: participant, affiliation: none"));
}

void
shows_message(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    assert_true(prof_output_regex("testoccupant: .+a new message"));
}

void
shows_me_message_from_occupant(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>/me did something</body>"
        "</message>"
    );

    assert_true(prof_output_exact("*testoccupant did something"));
}

void
shows_me_message_from_self(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<body>/me did something</body>"
        "</message>"
    );

    assert_true(prof_output_exact("*stabber did something"));
}

void
shows_all_messages_in_console_when_window_not_focussed(void **state)
{
    prof_connect();

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    prof_input("/win 1");
    assert_true(prof_output_exact("Profanity. Type /help for help information."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    assert_true(prof_output_exact("<< room message: testoccupant in testroom@conference.localhost (win 2)"));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
            "<body>some other message</body>"
        "</message>"
    );

    assert_true(prof_output_exact("<< room message: anotheroccupant in testroom@conference.localhost (win 2)"));
}

void
shows_first_message_in_console_when_window_not_focussed(void **state)
{
    prof_connect();

    prof_input("/console muc first");
    assert_true(prof_output_exact("Console MUC messages set: first"));

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    prof_input("/win 1");
    assert_true(prof_output_exact("Profanity. Type /help for help information."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    assert_true(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
    prof_input("/clear");
    prof_input("/about");
    assert_true(prof_output_exact("Type '/help' to show complete help."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/anotheroccupant'>"
            "<body>some other message</body>"
        "</message>"
    );

    prof_timeout(2);
    assert_false(prof_output_exact("<< room message: testroom@conference.localhost (win 2)"));
    prof_timeout_reset();
}

void
shows_no_message_in_console_when_window_not_focussed(void **state)
{
    prof_connect();

    prof_input("/console muc none");
    assert_true(prof_output_exact("Console MUC messages set: none"));

    stbbr_for_id("prof_join_4",
        "<presence id='prof_join_4' lang='en' to='stabber@localhost/profanity' from='testroom@conference.localhost/stabber'>"
            "<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='*'/>"
            "<x xmlns='http://jabber.org/protocol/muc#user'>"
                "<item role='participant' jid='stabber@localhost/profanity' affiliation='none'/>"
            "</x>"
            "<status code='110'/>"
        "</presence>"
    );

    prof_input("/join testroom@conference.localhost");
    assert_true(prof_output_exact("-> You have joined the room as stabber, role: participant, affiliation: none"));

    prof_input("/win 1");
    assert_true(prof_output_exact("Profanity. Type /help for help information."));

    stbbr_send(
        "<message type='groupchat' to='stabber@localhost/profanity' from='testroom@conference.localhost/testoccupant'>"
            "<body>a new message</body>"
        "</message>"
    );

    prof_timeout(2);
    assert_false(prof_output_exact("testroom@conference.localhost (win 2)"));
    prof_timeout_reset();
}